mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-01-01 12:46:12 +00:00
a/ogl: Add Vulkan to OpenGL conversion function
This commit is contained in:
parent
3c1d8dafaa
commit
1a543cb0c0
|
@ -1,4 +1,4 @@
|
|||
# Copyright 2019-2022, Collabora, Ltd.
|
||||
# Copyright 2019-2023, Collabora, Ltd.
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
add_library(
|
||||
|
@ -9,7 +9,7 @@ add_library(
|
|||
ogl_helpers.c
|
||||
ogl_helpers.h
|
||||
)
|
||||
target_link_libraries(aux_ogl PUBLIC aux-includes xrt-external-glad)
|
||||
target_link_libraries(aux_ogl PUBLIC aux-includes xrt-external-glad aux_util)
|
||||
|
||||
if(XRT_HAVE_OPENGL_GLX AND XRT_HAVE_XLIB)
|
||||
target_sources(aux_ogl PRIVATE glx_api.c glx_api.h)
|
||||
|
|
|
@ -7,9 +7,14 @@
|
|||
* @ingroup aux_ogl
|
||||
*/
|
||||
|
||||
#include "util/u_logging.h"
|
||||
|
||||
#include "ogl_helpers.h"
|
||||
#include "ogl_api.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
void
|
||||
ogl_texture_target_for_swapchain_info(const struct xrt_swapchain_create_info *info,
|
||||
uint32_t *out_tex_target,
|
||||
|
@ -39,3 +44,31 @@ ogl_texture_target_for_swapchain_info(const struct xrt_swapchain_create_info *in
|
|||
*out_tex_target = GL_TEXTURE_2D;
|
||||
*out_tex_param_name = GL_TEXTURE_BINDING_2D;
|
||||
}
|
||||
|
||||
XRT_CHECK_RESULT uint32_t
|
||||
ogl_vk_format_to_gl(int64_t vk_format)
|
||||
{
|
||||
switch (vk_format) {
|
||||
case 4 /* VK_FORMAT_R5G6B5_UNORM_PACK16 */: return 0; // GL_RGB565?
|
||||
case 23 /* VK_FORMAT_R8G8B8_UNORM */: return GL_RGB8; // Should not be used, colour precision.
|
||||
case 29 /* VK_FORMAT_R8G8B8_SRGB */: return GL_SRGB8;
|
||||
case 30 /* VK_FORMAT_B8G8R8_UNORM */: return 0;
|
||||
case 37 /* VK_FORMAT_R8G8B8A8_UNORM */: return GL_RGBA8; // Should not be used, colour precision.
|
||||
case 43 /* VK_FORMAT_R8G8B8A8_SRGB */: return GL_SRGB8_ALPHA8;
|
||||
case 44 /* VK_FORMAT_B8G8R8A8_UNORM */: return 0;
|
||||
case 50 /* VK_FORMAT_B8G8R8A8_SRGB */: return 0;
|
||||
case 64 /* VK_FORMAT_A2B10G10R10_UNORM_PACK32 */: return GL_RGB10_A2;
|
||||
case 84 /* VK_FORMAT_R16G16B16_UNORM */: return GL_RGB16;
|
||||
case 90 /* VK_FORMAT_R16G16B16_SFLOAT */: return GL_RGB16F;
|
||||
case 91 /* VK_FORMAT_R16G16B16A16_UNORM */: return GL_RGBA16;
|
||||
case 97 /* VK_FORMAT_R16G16B16A16_SFLOAT */: return GL_RGBA16F;
|
||||
case 100 /* VK_FORMAT_R32_SFLOAT */: return 0;
|
||||
case 124 /* VK_FORMAT_D16_UNORM */: return GL_DEPTH_COMPONENT16;
|
||||
case 125 /* VK_FORMAT_X8_D24_UNORM_PACK32 */: return 0; // GL_DEPTH_COMPONENT24?
|
||||
case 126 /* VK_FORMAT_D32_SFLOAT */: return GL_DEPTH_COMPONENT32F;
|
||||
case 127 /* VK_FORMAT_S8_UINT */: return 0; // GL_STENCIL_INDEX8?
|
||||
case 129 /* VK_FORMAT_D24_UNORM_S8_UINT */: return GL_DEPTH24_STENCIL8;
|
||||
case 130 /* VK_FORMAT_D32_SFLOAT_S8_UINT */: return GL_DEPTH32F_STENCIL8;
|
||||
default: U_LOG_W("Cannot convert VK format %" PRIu64 " to GL format!", vk_format); return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
* @file
|
||||
* @brief Common OpenGL code header.
|
||||
* @author Ryan Pavlik <ryan.pavlik@collabora.com>
|
||||
* @author Jakob Bornecrantz <jakob@collabora.com>
|
||||
* @ingroup aux_ogl
|
||||
*/
|
||||
|
||||
|
@ -26,6 +27,16 @@ ogl_texture_target_for_swapchain_info(const struct xrt_swapchain_create_info *in
|
|||
uint32_t *out_tex_target,
|
||||
uint32_t *out_tex_param_name);
|
||||
|
||||
/*!
|
||||
* Converts a Vulkan format to corresponding OpenGL format,
|
||||
* will return 0 if no mapping exist for the given format.
|
||||
*
|
||||
* @ingroup aux_ogl
|
||||
*/
|
||||
XRT_CHECK_RESULT uint32_t
|
||||
ogl_vk_format_to_gl(int64_t vk_format);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue