From 00e8dcdb71c6ae3fefd83958ead19b1d72f544e4 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 26 Jan 2020 15:21:35 -0800 Subject: More .h -> .hpp renamings --- Graphics/GraphicsEngineOpenGL/CMakeLists.txt | 2 +- .../include/GLTypeConversions.h | 308 --------------------- .../include/GLTypeConversions.hpp | 308 +++++++++++++++++++++ Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp | 2 +- .../GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp | 2 +- .../src/DeviceContextGLImpl.cpp | 2 +- .../src/EngineFactoryOpenGL.cpp | 2 +- .../GraphicsEngineOpenGL/src/GLContextState.cpp | 2 +- .../GraphicsEngineOpenGL/src/GLContextWindows.cpp | 2 +- .../GraphicsEngineOpenGL/src/GLTypeConversions.cpp | 2 +- .../src/RenderDeviceGLImpl.cpp | 2 +- .../GraphicsEngineOpenGL/src/SamplerGLImpl.cpp | 2 +- .../src/Texture1DArray_OGL.cpp | 2 +- .../GraphicsEngineOpenGL/src/Texture1D_OGL.cpp | 2 +- .../src/Texture2DArray_OGL.cpp | 2 +- .../GraphicsEngineOpenGL/src/Texture2D_OGL.cpp | 2 +- .../GraphicsEngineOpenGL/src/Texture3D_OGL.cpp | 2 +- .../GraphicsEngineOpenGL/src/TextureBaseGL.cpp | 2 +- .../src/TextureCubeArray_OGL.cpp | 2 +- .../GraphicsEngineOpenGL/src/TextureCube_OGL.cpp | 2 +- Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp | 2 +- 21 files changed, 327 insertions(+), 327 deletions(-) delete mode 100644 Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.h create mode 100644 Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp (limited to 'Graphics/GraphicsEngineOpenGL') diff --git a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt index c0d3bd36..2ee218be 100644 --- a/Graphics/GraphicsEngineOpenGL/CMakeLists.txt +++ b/Graphics/GraphicsEngineOpenGL/CMakeLists.txt @@ -15,7 +15,7 @@ set(INCLUDE include/GLProgramResourceCache.hpp include/GLPipelineResourceLayout.hpp include/GLProgramResources.hpp - include/GLTypeConversions.h + include/GLTypeConversions.hpp include/pch.h include/PipelineStateGLImpl.hpp include/QueryGLImpl.hpp diff --git a/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.h b/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.h deleted file mode 100644 index 4f149399..00000000 --- a/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.h +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright 2019-2020 Diligent Graphics LLC - * Copyright 2015-2019 Egor Yusov - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * In no event and under no legal theory, whether in tort (including negligence), - * contract, or otherwise, unless required by applicable law (such as deliberate - * and grossly negligent acts) or agreed to in writing, shall any Contributor be - * liable for any damages, including any direct, indirect, special, incidental, - * or consequential damages of any character arising as a result of this License or - * out of the use or inability to use the software (including but not limited to damages - * for loss of goodwill, work stoppage, computer failure or malfunction, or any and - * all other commercial damages or losses), even if such Contributor has been advised - * of the possibility of such damages. - */ - -#pragma once - -namespace Diligent -{ - -// clang-format off -static const GLenum PrimTopologyToGLTopologyMap[] = -{ - 0, //PRIMITIVE_TOPOLOGY_UNDEFINED = 0 - GL_TRIANGLES, //PRIMITIVE_TOPOLOGY_TRIANGLE_LIST - GL_TRIANGLE_STRIP, //PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, - GL_POINTS, //PRIMITIVE_TOPOLOGY_POINT_LIST - GL_LINES //PRIMITIVE_TOPOLOGY_LINE_LIST -}; -// clang-format on - -inline GLenum PrimitiveTopologyToGLTopology(PRIMITIVE_TOPOLOGY PrimTopology) -{ - VERIFY_EXPR(PrimTopology < _countof(PrimTopologyToGLTopologyMap)); - auto GLTopology = PrimTopologyToGLTopologyMap[PrimTopology]; -#ifdef _DEBUG - switch (PrimTopology) - { - // clang-format off - case PRIMITIVE_TOPOLOGY_UNDEFINED: VERIFY_EXPR(GLTopology == 0); break; - case PRIMITIVE_TOPOLOGY_TRIANGLE_LIST: VERIFY_EXPR(GLTopology == GL_TRIANGLES); break; - case PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP: VERIFY_EXPR(GLTopology == GL_TRIANGLE_STRIP); break; - case PRIMITIVE_TOPOLOGY_POINT_LIST: VERIFY_EXPR(GLTopology == GL_POINTS); break; - case PRIMITIVE_TOPOLOGY_LINE_LIST: VERIFY_EXPR(GLTopology == GL_LINES); break; - default: UNEXPECTED("Unexpected primitive topology"); - // clang-format on - } -#endif - return GLTopology; -} - -// clang-format off -static const GLenum TypeToGLTypeMap[] = -{ - 0, //VT_UNDEFINED = 0 - GL_BYTE, //VT_INT8 - GL_SHORT, //VT_INT16 - GL_INT, //VT_INT32 - GL_UNSIGNED_BYTE, //VT_UINT8 - GL_UNSIGNED_SHORT, //VT_UINT16 - GL_UNSIGNED_INT, //VT_UINT32 - 0, //VT_FLOAT16 - GL_FLOAT //VT_FLOAT32 -}; -// clang-format on - -inline GLenum TypeToGLType(VALUE_TYPE Value) -{ - VERIFY_EXPR(Value < _countof(TypeToGLTypeMap)); - auto GLType = TypeToGLTypeMap[Value]; -#ifdef _DEBUG - switch (Value) - { - // clang-format off - case VT_INT8: VERIFY_EXPR(GLType == GL_BYTE); break; - case VT_INT16: VERIFY_EXPR(GLType == GL_SHORT); break; - case VT_INT32: VERIFY_EXPR(GLType == GL_INT); break; - case VT_UINT8: VERIFY_EXPR(GLType == GL_UNSIGNED_BYTE); break; - case VT_UINT16: VERIFY_EXPR(GLType == GL_UNSIGNED_SHORT); break; - case VT_UINT32: VERIFY_EXPR(GLType == GL_UNSIGNED_INT); break; - case VT_FLOAT32: VERIFY_EXPR(GLType == GL_FLOAT); break; - default: UNEXPECTED("Unexpected value type"); - // clang-format on - } -#endif - return GLType; -} - -inline GLenum UsageToGLUsage(const BufferDesc& Desc) -{ - // http://www.informit.com/articles/article.aspx?p=2033340&seqNum=2 - // https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glBufferData.xml - switch (Desc.Usage) - { - // STATIC: The data store contents will be modified once and used many times. - // STREAM: The data store contents will be modified once and used at MOST a few times. - // DYNAMIC: The data store contents will be modified repeatedly and used many times. - - // clang-format off - case USAGE_STATIC: return GL_STATIC_DRAW; - case USAGE_DEFAULT: return GL_STATIC_DRAW; - case USAGE_DYNAMIC: return GL_DYNAMIC_DRAW; - case USAGE_STAGING: - if(Desc.CPUAccessFlags & CPU_ACCESS_READ) - return GL_STATIC_READ; - else - return GL_STATIC_COPY; - - default: UNEXPECTED( "Unknow usage" ); return 0; - // clang-format on - } -} - -inline void FilterTypeToGLFilterType(FILTER_TYPE Filter, GLenum& GLFilter, Bool& bIsAnisotropic, Bool& bIsComparison) -{ - switch (Filter) - { - case FILTER_TYPE_UNKNOWN: - UNEXPECTED("Unspecified filter type"); - bIsAnisotropic = false; - bIsComparison = false; - GLFilter = GL_NEAREST; - break; - - case FILTER_TYPE_POINT: - bIsAnisotropic = false; - bIsComparison = false; - GLFilter = GL_NEAREST; - break; - - case FILTER_TYPE_LINEAR: - bIsAnisotropic = false; - bIsComparison = false; - GLFilter = GL_LINEAR; - break; - - case FILTER_TYPE_ANISOTROPIC: - bIsAnisotropic = true; - bIsComparison = false; - GLFilter = GL_LINEAR; - break; - - case FILTER_TYPE_COMPARISON_POINT: - bIsAnisotropic = false; - bIsComparison = true; - GLFilter = GL_NEAREST; - break; - - case FILTER_TYPE_COMPARISON_LINEAR: - bIsAnisotropic = false; - bIsComparison = true; - GLFilter = GL_LINEAR; - break; - - case FILTER_TYPE_COMPARISON_ANISOTROPIC: - bIsAnisotropic = true; - bIsComparison = true; - GLFilter = GL_LINEAR; - break; - - default: - UNEXPECTED("Unknown filter type"); - bIsAnisotropic = false; - bIsComparison = false; - GLFilter = GL_NEAREST; - break; - } -} - -GLenum TexFormatToGLInternalTexFormat(TEXTURE_FORMAT TexFormat, Uint32 BindFlags = 0); -TEXTURE_FORMAT GLInternalTexFormatToTexFormat(GLenum GlFormat); -GLenum CorrectGLTexFormat(GLenum GLTexFormat, Uint32 BindFlags); - -inline GLenum TexAddressModeToGLAddressMode(TEXTURE_ADDRESS_MODE Mode) -{ - switch (Mode) - { - // clang-format off - case TEXTURE_ADDRESS_UNKNOWN: UNEXPECTED( "Texture address mode is not specified" ); return GL_CLAMP_TO_EDGE; - case TEXTURE_ADDRESS_WRAP: return GL_REPEAT; - case TEXTURE_ADDRESS_MIRROR: return GL_MIRRORED_REPEAT; - case TEXTURE_ADDRESS_CLAMP: return GL_CLAMP_TO_EDGE; - case TEXTURE_ADDRESS_BORDER: return GL_CLAMP_TO_BORDER; - case TEXTURE_ADDRESS_MIRROR_ONCE: return GL_MIRROR_CLAMP_TO_EDGE; // only available with OpenGL 4.4 - // This mode seems to be different from D3D11_TEXTURE_ADDRESS_MIRROR_ONCE - // The texture coord is clamped to the [-1, 1] range, but mirrors the - // negative direction with the positive. Basically, it acts as - // GL_CLAMP_TO_EDGE except that it takes the absolute value of the texture - // coordinates before clamping. - default: UNEXPECTED( "Unknown texture address mode" ); return GL_CLAMP_TO_EDGE; - // clang-format on - } -} - -inline GLenum CompareFuncToGLCompareFunc(COMPARISON_FUNCTION Func) -{ - switch (Func) - { - // clang-format off - case COMPARISON_FUNC_UNKNOWN: UNEXPECTED( "Comparison function is not specified" ); return GL_ALWAYS; - case COMPARISON_FUNC_NEVER: return GL_NEVER; - case COMPARISON_FUNC_LESS: return GL_LESS; - case COMPARISON_FUNC_EQUAL: return GL_EQUAL; - case COMPARISON_FUNC_LESS_EQUAL: return GL_LEQUAL; - case COMPARISON_FUNC_GREATER: return GL_GREATER; - case COMPARISON_FUNC_NOT_EQUAL: return GL_NOTEQUAL; - case COMPARISON_FUNC_GREATER_EQUAL: return GL_GEQUAL; - case COMPARISON_FUNC_ALWAYS: return GL_ALWAYS; - default: UNEXPECTED( "Unknown comparison func" ); return GL_ALWAYS; - // clang-format on - } -} - -struct NativePixelAttribs -{ - GLenum PixelFormat = 0; - GLenum DataType = 0; - Bool IsCompressed = 0; - - NativePixelAttribs() noexcept {} - - explicit NativePixelAttribs(GLenum _PixelFormat, GLenum _DataType, Bool _IsCompressed = False) noexcept : - PixelFormat{_PixelFormat}, - DataType{_DataType}, - IsCompressed{_IsCompressed} - {} -}; - -inline Uint32 GetNumPixelFormatComponents(GLenum Format) -{ - switch (Format) - { - case GL_RGBA: - case GL_RGBA_INTEGER: - return 4; - - case GL_RGB: - case GL_RGB_INTEGER: - return 3; - - case GL_RG: - case GL_RG_INTEGER: - return 2; - - case GL_RED: - case GL_RED_INTEGER: - case GL_DEPTH_COMPONENT: - case GL_DEPTH_STENCIL: - return 1; - - default: UNEXPECTED("Unknonw pixel format"); return 0; - }; -} - -inline Uint32 GetPixelTypeSize(GLenum Type) -{ - switch (Type) - { - // clang-format off - case GL_FLOAT: return sizeof(GLfloat); - - case GL_UNSIGNED_INT_10_10_10_2: - case GL_UNSIGNED_INT_2_10_10_10_REV: - case GL_UNSIGNED_INT_10F_11F_11F_REV: - case GL_UNSIGNED_INT_24_8: - case GL_UNSIGNED_INT_5_9_9_9_REV: - case GL_UNSIGNED_INT: return sizeof(GLuint); - - case GL_INT: return sizeof(GLint); - case GL_HALF_FLOAT: return sizeof(GLhalf); - - case GL_UNSIGNED_SHORT_5_6_5: - case GL_UNSIGNED_SHORT_5_6_5_REV: - case GL_UNSIGNED_SHORT_5_5_5_1: - case GL_UNSIGNED_SHORT_1_5_5_5_REV: - case GL_UNSIGNED_SHORT: return sizeof(GLushort); - - case GL_SHORT: return sizeof(GLshort); - case GL_UNSIGNED_BYTE: return sizeof(GLubyte); - case GL_BYTE: return sizeof(GLbyte); - - case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:return sizeof(GLfloat) + sizeof(GLuint); - - default: UNEXPECTED( "Unknonw pixel type" ); return 0; - // clang-format on - } -} - -NativePixelAttribs GetNativePixelTransferAttribs(TEXTURE_FORMAT TexFormat); -GLenum AccessFlags2GLAccess(Uint32 UAVAccessFlags); -GLenum TypeToGLTexFormat(VALUE_TYPE ValType, Uint32 NumComponents, Bool bIsNormalized); -GLenum StencilOp2GlStencilOp(STENCIL_OP StencilOp); -GLenum BlendFactor2GLBlend(BLEND_FACTOR bf); -GLenum BlendOperation2GLBlendOp(BLEND_OPERATION BlendOp); - -} // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp b/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp new file mode 100644 index 00000000..4f149399 --- /dev/null +++ b/Graphics/GraphicsEngineOpenGL/include/GLTypeConversions.hpp @@ -0,0 +1,308 @@ +/* + * Copyright 2019-2020 Diligent Graphics LLC + * Copyright 2015-2019 Egor Yusov + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * In no event and under no legal theory, whether in tort (including negligence), + * contract, or otherwise, unless required by applicable law (such as deliberate + * and grossly negligent acts) or agreed to in writing, shall any Contributor be + * liable for any damages, including any direct, indirect, special, incidental, + * or consequential damages of any character arising as a result of this License or + * out of the use or inability to use the software (including but not limited to damages + * for loss of goodwill, work stoppage, computer failure or malfunction, or any and + * all other commercial damages or losses), even if such Contributor has been advised + * of the possibility of such damages. + */ + +#pragma once + +namespace Diligent +{ + +// clang-format off +static const GLenum PrimTopologyToGLTopologyMap[] = +{ + 0, //PRIMITIVE_TOPOLOGY_UNDEFINED = 0 + GL_TRIANGLES, //PRIMITIVE_TOPOLOGY_TRIANGLE_LIST + GL_TRIANGLE_STRIP, //PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP, + GL_POINTS, //PRIMITIVE_TOPOLOGY_POINT_LIST + GL_LINES //PRIMITIVE_TOPOLOGY_LINE_LIST +}; +// clang-format on + +inline GLenum PrimitiveTopologyToGLTopology(PRIMITIVE_TOPOLOGY PrimTopology) +{ + VERIFY_EXPR(PrimTopology < _countof(PrimTopologyToGLTopologyMap)); + auto GLTopology = PrimTopologyToGLTopologyMap[PrimTopology]; +#ifdef _DEBUG + switch (PrimTopology) + { + // clang-format off + case PRIMITIVE_TOPOLOGY_UNDEFINED: VERIFY_EXPR(GLTopology == 0); break; + case PRIMITIVE_TOPOLOGY_TRIANGLE_LIST: VERIFY_EXPR(GLTopology == GL_TRIANGLES); break; + case PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP: VERIFY_EXPR(GLTopology == GL_TRIANGLE_STRIP); break; + case PRIMITIVE_TOPOLOGY_POINT_LIST: VERIFY_EXPR(GLTopology == GL_POINTS); break; + case PRIMITIVE_TOPOLOGY_LINE_LIST: VERIFY_EXPR(GLTopology == GL_LINES); break; + default: UNEXPECTED("Unexpected primitive topology"); + // clang-format on + } +#endif + return GLTopology; +} + +// clang-format off +static const GLenum TypeToGLTypeMap[] = +{ + 0, //VT_UNDEFINED = 0 + GL_BYTE, //VT_INT8 + GL_SHORT, //VT_INT16 + GL_INT, //VT_INT32 + GL_UNSIGNED_BYTE, //VT_UINT8 + GL_UNSIGNED_SHORT, //VT_UINT16 + GL_UNSIGNED_INT, //VT_UINT32 + 0, //VT_FLOAT16 + GL_FLOAT //VT_FLOAT32 +}; +// clang-format on + +inline GLenum TypeToGLType(VALUE_TYPE Value) +{ + VERIFY_EXPR(Value < _countof(TypeToGLTypeMap)); + auto GLType = TypeToGLTypeMap[Value]; +#ifdef _DEBUG + switch (Value) + { + // clang-format off + case VT_INT8: VERIFY_EXPR(GLType == GL_BYTE); break; + case VT_INT16: VERIFY_EXPR(GLType == GL_SHORT); break; + case VT_INT32: VERIFY_EXPR(GLType == GL_INT); break; + case VT_UINT8: VERIFY_EXPR(GLType == GL_UNSIGNED_BYTE); break; + case VT_UINT16: VERIFY_EXPR(GLType == GL_UNSIGNED_SHORT); break; + case VT_UINT32: VERIFY_EXPR(GLType == GL_UNSIGNED_INT); break; + case VT_FLOAT32: VERIFY_EXPR(GLType == GL_FLOAT); break; + default: UNEXPECTED("Unexpected value type"); + // clang-format on + } +#endif + return GLType; +} + +inline GLenum UsageToGLUsage(const BufferDesc& Desc) +{ + // http://www.informit.com/articles/article.aspx?p=2033340&seqNum=2 + // https://www.khronos.org/registry/OpenGL-Refpages/gl2.1/xhtml/glBufferData.xml + switch (Desc.Usage) + { + // STATIC: The data store contents will be modified once and used many times. + // STREAM: The data store contents will be modified once and used at MOST a few times. + // DYNAMIC: The data store contents will be modified repeatedly and used many times. + + // clang-format off + case USAGE_STATIC: return GL_STATIC_DRAW; + case USAGE_DEFAULT: return GL_STATIC_DRAW; + case USAGE_DYNAMIC: return GL_DYNAMIC_DRAW; + case USAGE_STAGING: + if(Desc.CPUAccessFlags & CPU_ACCESS_READ) + return GL_STATIC_READ; + else + return GL_STATIC_COPY; + + default: UNEXPECTED( "Unknow usage" ); return 0; + // clang-format on + } +} + +inline void FilterTypeToGLFilterType(FILTER_TYPE Filter, GLenum& GLFilter, Bool& bIsAnisotropic, Bool& bIsComparison) +{ + switch (Filter) + { + case FILTER_TYPE_UNKNOWN: + UNEXPECTED("Unspecified filter type"); + bIsAnisotropic = false; + bIsComparison = false; + GLFilter = GL_NEAREST; + break; + + case FILTER_TYPE_POINT: + bIsAnisotropic = false; + bIsComparison = false; + GLFilter = GL_NEAREST; + break; + + case FILTER_TYPE_LINEAR: + bIsAnisotropic = false; + bIsComparison = false; + GLFilter = GL_LINEAR; + break; + + case FILTER_TYPE_ANISOTROPIC: + bIsAnisotropic = true; + bIsComparison = false; + GLFilter = GL_LINEAR; + break; + + case FILTER_TYPE_COMPARISON_POINT: + bIsAnisotropic = false; + bIsComparison = true; + GLFilter = GL_NEAREST; + break; + + case FILTER_TYPE_COMPARISON_LINEAR: + bIsAnisotropic = false; + bIsComparison = true; + GLFilter = GL_LINEAR; + break; + + case FILTER_TYPE_COMPARISON_ANISOTROPIC: + bIsAnisotropic = true; + bIsComparison = true; + GLFilter = GL_LINEAR; + break; + + default: + UNEXPECTED("Unknown filter type"); + bIsAnisotropic = false; + bIsComparison = false; + GLFilter = GL_NEAREST; + break; + } +} + +GLenum TexFormatToGLInternalTexFormat(TEXTURE_FORMAT TexFormat, Uint32 BindFlags = 0); +TEXTURE_FORMAT GLInternalTexFormatToTexFormat(GLenum GlFormat); +GLenum CorrectGLTexFormat(GLenum GLTexFormat, Uint32 BindFlags); + +inline GLenum TexAddressModeToGLAddressMode(TEXTURE_ADDRESS_MODE Mode) +{ + switch (Mode) + { + // clang-format off + case TEXTURE_ADDRESS_UNKNOWN: UNEXPECTED( "Texture address mode is not specified" ); return GL_CLAMP_TO_EDGE; + case TEXTURE_ADDRESS_WRAP: return GL_REPEAT; + case TEXTURE_ADDRESS_MIRROR: return GL_MIRRORED_REPEAT; + case TEXTURE_ADDRESS_CLAMP: return GL_CLAMP_TO_EDGE; + case TEXTURE_ADDRESS_BORDER: return GL_CLAMP_TO_BORDER; + case TEXTURE_ADDRESS_MIRROR_ONCE: return GL_MIRROR_CLAMP_TO_EDGE; // only available with OpenGL 4.4 + // This mode seems to be different from D3D11_TEXTURE_ADDRESS_MIRROR_ONCE + // The texture coord is clamped to the [-1, 1] range, but mirrors the + // negative direction with the positive. Basically, it acts as + // GL_CLAMP_TO_EDGE except that it takes the absolute value of the texture + // coordinates before clamping. + default: UNEXPECTED( "Unknown texture address mode" ); return GL_CLAMP_TO_EDGE; + // clang-format on + } +} + +inline GLenum CompareFuncToGLCompareFunc(COMPARISON_FUNCTION Func) +{ + switch (Func) + { + // clang-format off + case COMPARISON_FUNC_UNKNOWN: UNEXPECTED( "Comparison function is not specified" ); return GL_ALWAYS; + case COMPARISON_FUNC_NEVER: return GL_NEVER; + case COMPARISON_FUNC_LESS: return GL_LESS; + case COMPARISON_FUNC_EQUAL: return GL_EQUAL; + case COMPARISON_FUNC_LESS_EQUAL: return GL_LEQUAL; + case COMPARISON_FUNC_GREATER: return GL_GREATER; + case COMPARISON_FUNC_NOT_EQUAL: return GL_NOTEQUAL; + case COMPARISON_FUNC_GREATER_EQUAL: return GL_GEQUAL; + case COMPARISON_FUNC_ALWAYS: return GL_ALWAYS; + default: UNEXPECTED( "Unknown comparison func" ); return GL_ALWAYS; + // clang-format on + } +} + +struct NativePixelAttribs +{ + GLenum PixelFormat = 0; + GLenum DataType = 0; + Bool IsCompressed = 0; + + NativePixelAttribs() noexcept {} + + explicit NativePixelAttribs(GLenum _PixelFormat, GLenum _DataType, Bool _IsCompressed = False) noexcept : + PixelFormat{_PixelFormat}, + DataType{_DataType}, + IsCompressed{_IsCompressed} + {} +}; + +inline Uint32 GetNumPixelFormatComponents(GLenum Format) +{ + switch (Format) + { + case GL_RGBA: + case GL_RGBA_INTEGER: + return 4; + + case GL_RGB: + case GL_RGB_INTEGER: + return 3; + + case GL_RG: + case GL_RG_INTEGER: + return 2; + + case GL_RED: + case GL_RED_INTEGER: + case GL_DEPTH_COMPONENT: + case GL_DEPTH_STENCIL: + return 1; + + default: UNEXPECTED("Unknonw pixel format"); return 0; + }; +} + +inline Uint32 GetPixelTypeSize(GLenum Type) +{ + switch (Type) + { + // clang-format off + case GL_FLOAT: return sizeof(GLfloat); + + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + case GL_UNSIGNED_INT_10F_11F_11F_REV: + case GL_UNSIGNED_INT_24_8: + case GL_UNSIGNED_INT_5_9_9_9_REV: + case GL_UNSIGNED_INT: return sizeof(GLuint); + + case GL_INT: return sizeof(GLint); + case GL_HALF_FLOAT: return sizeof(GLhalf); + + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_SHORT: return sizeof(GLushort); + + case GL_SHORT: return sizeof(GLshort); + case GL_UNSIGNED_BYTE: return sizeof(GLubyte); + case GL_BYTE: return sizeof(GLbyte); + + case GL_FLOAT_32_UNSIGNED_INT_24_8_REV:return sizeof(GLfloat) + sizeof(GLuint); + + default: UNEXPECTED( "Unknonw pixel type" ); return 0; + // clang-format on + } +} + +NativePixelAttribs GetNativePixelTransferAttribs(TEXTURE_FORMAT TexFormat); +GLenum AccessFlags2GLAccess(Uint32 UAVAccessFlags); +GLenum TypeToGLTexFormat(VALUE_TYPE ValType, Uint32 NumComponents, Bool bIsNormalized); +GLenum StencilOp2GlStencilOp(STENCIL_OP StencilOp); +GLenum BlendFactor2GLBlend(BLEND_FACTOR bf); +GLenum BlendOperation2GLBlendOp(BLEND_OPERATION BlendOp); + +} // namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp index f4bff6a0..bce00b60 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferGLImpl.cpp @@ -29,7 +29,7 @@ #include "BufferGLImpl.hpp" #include "RenderDeviceGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "BufferViewGLImpl.hpp" #include "DeviceContextGLImpl.hpp" #include "EngineMemory.h" diff --git a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp index 024c2dae..8133df48 100644 --- a/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/BufferViewGLImpl.cpp @@ -31,7 +31,7 @@ #include "DeviceContextGLImpl.hpp" #include "BufferViewGLImpl.hpp" #include "BufferGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp index eca2ccfe..8b13486d 100644 --- a/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp @@ -33,7 +33,7 @@ #include "SwapChainGL.h" #include "DeviceContextGLImpl.hpp" #include "RenderDeviceGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "BufferGLImpl.hpp" #include "ShaderGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp index 2a35bd28..d81620a4 100644 --- a/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/EngineFactoryOpenGL.cpp @@ -33,7 +33,7 @@ #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" #include "EngineMemory.h" -#include "HLSL2GLSLConverterObject.h" +#include "HLSL2GLSLConverterObject.hpp" #include "EngineFactoryBase.hpp" #if PLATFORM_IOS diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp index da7a2847..9980d69f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextState.cpp @@ -31,7 +31,7 @@ #include "TextureBaseGL.hpp" #include "SamplerGLImpl.hpp" #include "AsyncWritableResource.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "BufferViewGLImpl.hpp" #include "RenderDeviceGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp b/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp index 71c23a13..2bfd7d9d 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLContextWindows.cpp @@ -29,7 +29,7 @@ #include "GLContextWindows.hpp" #include "DeviceCaps.h" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GraphicsAccessories.hpp" namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp b/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp index e534f64d..dde10533 100644 --- a/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/GLTypeConversions.cpp @@ -26,7 +26,7 @@ */ #include "pch.h" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GraphicsAccessories.hpp" namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp index 3f254d5c..c2e6a576 100644 --- a/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/RenderDeviceGLImpl.cpp @@ -41,7 +41,7 @@ #include "TextureCubeArray_OGL.hpp" #include "SamplerGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "PipelineStateGLImpl.hpp" #include "ShaderResourceBindingGLImpl.hpp" #include "FenceGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp b/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp index 2b34841c..ddf73df4 100644 --- a/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/SamplerGLImpl.cpp @@ -28,7 +28,7 @@ #include "pch.h" #include "SamplerGLImpl.hpp" #include "RenderDeviceGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" namespace Diligent { diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp index 4cbfa8e0..2dd93b6c 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture1DArray_OGL.cpp @@ -30,7 +30,7 @@ #include "Texture1DArray_OGL.hpp" #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "BufferGLImpl.hpp" namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp index 40cea68d..8f385238 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture1D_OGL.cpp @@ -30,7 +30,7 @@ #include "Texture1D_OGL.hpp" #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "BufferGLImpl.hpp" namespace Diligent diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp index 39e65b03..4c9c0e19 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2DArray_OGL.cpp @@ -30,7 +30,7 @@ #include "Texture2DArray_OGL.hpp" #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GraphicsAccessories.hpp" #include "BufferGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp index 4bdaf683..e854960f 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture2D_OGL.cpp @@ -30,7 +30,7 @@ #include "Texture2D_OGL.hpp" #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GraphicsAccessories.hpp" #include "BufferGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp index e915a3ed..7b4d19a0 100644 --- a/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/Texture3D_OGL.cpp @@ -30,7 +30,7 @@ #include "Texture3D_OGL.hpp" #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GraphicsAccessories.hpp" #include "BufferGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp index dc463a24..72733d70 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureBaseGL.cpp @@ -29,7 +29,7 @@ #include "TextureBaseGL.hpp" #include "RenderDeviceGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "TextureViewGLImpl.hpp" #include "GLContextState.hpp" #include "DeviceContextGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp index e58863ed..646e78f2 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCubeArray_OGL.cpp @@ -30,7 +30,7 @@ #include "TextureCubeArray_OGL.hpp" #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GraphicsAccessories.hpp" #include "BufferGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp index 27a296e1..8193aca5 100644 --- a/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/TextureCube_OGL.cpp @@ -30,7 +30,7 @@ #include "TextureCube_OGL.hpp" #include "RenderDeviceGLImpl.hpp" #include "DeviceContextGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GraphicsAccessories.hpp" #include "BufferGLImpl.hpp" diff --git a/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp b/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp index a3388293..cecadcba 100644 --- a/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp +++ b/Graphics/GraphicsEngineOpenGL/src/VAOCache.cpp @@ -31,7 +31,7 @@ #include "RenderDeviceGLImpl.hpp" #include "GLObjectWrapper.hpp" #include "BufferGLImpl.hpp" -#include "GLTypeConversions.h" +#include "GLTypeConversions.hpp" #include "GLContextState.hpp" #include "PipelineStateGLImpl.hpp" -- cgit v1.2.3