From 1d52e0bd10effb4f7315b9d9b36681951c83f386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 16 Mar 2019 21:52:44 -0700 Subject: [PATCH] Fixed issue #1691. --- src/bgfx.cpp | 3 ++- src/bgfx_p.h | 2 +- src/renderer_d3d9.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 48e57a20f..67be8479f 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -4164,6 +4164,7 @@ namespace bgfx | BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB ) ); } + uint16_t srgbCaps = BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB; if (_cubeMap) @@ -4212,7 +4213,7 @@ namespace bgfx } if (0 != (_flags & BGFX_TEXTURE_SRGB) - && 0 == (g_caps.supported & srgbCaps & (0 + && 0 == (g_caps.formats[_format] & srgbCaps & (0 | BGFX_CAPS_FORMAT_TEXTURE_2D_SRGB | BGFX_CAPS_FORMAT_TEXTURE_3D_SRGB | BGFX_CAPS_FORMAT_TEXTURE_CUBE_SRGB diff --git a/src/bgfx_p.h b/src/bgfx_p.h index b206e7128..2c269cf81 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -521,7 +521,7 @@ namespace bgfx return uint32_t( (_stencil >> (32*_0or1) ) ); } - inline bool needBorderColor(uint32_t _flags) + inline bool needBorderColor(uint64_t _flags) { return BGFX_SAMPLER_U_BORDER == (_flags & BGFX_SAMPLER_U_BORDER) || BGFX_SAMPLER_V_BORDER == (_flags & BGFX_SAMPLER_V_BORDER) diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 4d38fcd1a..e5c598139 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -1734,9 +1734,9 @@ namespace bgfx { namespace d3d9 } } - void setSamplerState(uint8_t _stage, uint32_t _flags, const float _rgba[4]) + void setSamplerState(uint8_t _stage, uint64_t _flags, const float _rgba[4]) { - const uint32_t flags = _flags&( (~BGFX_SAMPLER_RESERVED_MASK) | BGFX_SAMPLER_BITS_MASK | BGFX_TEXTURE_SRGB); + const uint64_t flags = _flags&( (~BGFX_SAMPLER_RESERVED_MASK) | BGFX_SAMPLER_BITS_MASK | BGFX_TEXTURE_SRGB); BX_CHECK(_stage < BX_COUNTOF(m_samplerFlags), ""); if (m_samplerFlags[_stage] != flags) { @@ -2242,7 +2242,7 @@ namespace bgfx { namespace d3d9 UniformRegistry m_uniformReg; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; - uint32_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; + uint64_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; TextureD3D9* m_updateTexture; uint8_t* m_updateTextureBits; @@ -3124,9 +3124,8 @@ namespace bgfx { namespace d3d9 void TextureD3D9::commit(uint8_t _stage, uint32_t _flags, const float _palette[][4]) { - const uint32_t flags = 0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags) - ? _flags - : uint32_t(m_flags) + const uint64_t flags = (m_flags & BGFX_TEXTURE_SRGB) + | (0 == (BGFX_SAMPLER_INTERNAL_DEFAULT & _flags) ? _flags : uint32_t(m_flags) ) ; uint32_t index = (flags & BGFX_SAMPLER_BORDER_COLOR_MASK) >> BGFX_SAMPLER_BORDER_COLOR_SHIFT; s_renderD3D9->setSamplerState(_stage, flags, _palette[index]);