diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 85c87260..151bd788 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -127,8 +127,6 @@ namespace stl #define BGFX_DEFAULT_WIDTH 1280 #define BGFX_DEFAULT_HEIGHT 720 -#define BGFX_STATE_TEX_COUNT 16 - #define BGFX_MAX_COMPUTE_BINDINGS 8 #define BGFX_SAMPLER_DEFAULT_FLAGS UINT32_C(0x10000000) @@ -980,7 +978,7 @@ namespace bgfx m_indexBuffer.idx = invalidHandle; m_instanceDataBuffer.idx = invalidHandle; - for (uint32_t ii = 0; ii < BGFX_STATE_TEX_COUNT; ++ii) + for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii) { m_sampler[ii].m_idx = invalidHandle; m_sampler[ii].m_flags = 0; @@ -1007,7 +1005,7 @@ namespace bgfx VertexDeclHandle m_vertexDecl; IndexBufferHandle m_indexBuffer; VertexBufferHandle m_instanceDataBuffer; - Sampler m_sampler[BGFX_STATE_TEX_COUNT]; + Sampler m_sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; }; struct ComputeBinding diff --git a/src/config.h b/src/config.h index 3bc0bd3d..ddb021b6 100644 --- a/src/config.h +++ b/src/config.h @@ -180,6 +180,10 @@ # define BGFX_CONFIG_MAX_TEXTURES (4<<10) #endif // BGFX_CONFIG_MAX_TEXTURES +#ifndef BGFX_CONFIG_MAX_TEXTURE_SAMPLERS +# define BGFX_CONFIG_MAX_TEXTURE_SAMPLERS 16 +#endif // BGFX_CONFIG_MAX_TEXTURE_SAMPLERS + #ifndef BGFX_CONFIG_MAX_FRAME_BUFFERS # define BGFX_CONFIG_MAX_FRAME_BUFFERS 64 #endif // BGFX_CONFIG_MAX_FRAME_BUFFERS diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 13f84747..a996505f 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -338,8 +338,8 @@ namespace bgfx memset(m_sampler, 0, sizeof(m_sampler) ); } - ID3D11ShaderResourceView* m_srv[BGFX_STATE_TEX_COUNT]; - ID3D11SamplerState* m_sampler[BGFX_STATE_TEX_COUNT]; + ID3D11ShaderResourceView* m_srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; + ID3D11SamplerState* m_sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; }; static const GUID WKPDID_D3DDebugObjectName = { 0x429b8c22, 0x9188, 0x4b0c, { 0x87, 0x42, 0xac, 0xb0, 0xbf, 0x85, 0xc2, 0x00 } }; @@ -1479,8 +1479,8 @@ namespace bgfx void commitTextureStage() { - m_deviceCtx->PSSetShaderResources(0, BGFX_STATE_TEX_COUNT, m_textureStage.m_srv); - m_deviceCtx->PSSetSamplers(0, BGFX_STATE_TEX_COUNT, m_textureStage.m_sampler); + m_deviceCtx->PSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_srv); + m_deviceCtx->PSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, m_textureStage.m_sampler); } void invalidateTextureStage() @@ -2573,13 +2573,13 @@ namespace bgfx { wasCompute = true; - ID3D11ShaderResourceView* srv[BGFX_STATE_TEX_COUNT] = {}; - deviceCtx->VSSetShaderResources(0, BGFX_STATE_TEX_COUNT, srv); - deviceCtx->PSSetShaderResources(0, BGFX_STATE_TEX_COUNT, srv); + ID3D11ShaderResourceView* srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {}; + deviceCtx->VSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, srv); + deviceCtx->PSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, srv); - ID3D11SamplerState* sampler[BGFX_STATE_TEX_COUNT] = {}; - deviceCtx->VSSetSamplers(0, BGFX_STATE_TEX_COUNT, sampler); - deviceCtx->PSSetSamplers(0, BGFX_STATE_TEX_COUNT, sampler); + ID3D11SamplerState* sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {}; + deviceCtx->VSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, sampler); + deviceCtx->PSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, sampler); } const RenderCompute& compute = renderItem.compute; @@ -2624,7 +2624,7 @@ namespace bgfx ID3D11UnorderedAccessView* uav[BGFX_MAX_COMPUTE_BINDINGS] = {}; ID3D11ShaderResourceView* srv[BGFX_MAX_COMPUTE_BINDINGS] = {}; - ID3D11SamplerState* sampler[BGFX_STATE_TEX_COUNT] = {}; + ID3D11SamplerState* sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {}; for (uint32_t ii = 0; ii < BGFX_MAX_COMPUTE_BINDINGS; ++ii) { @@ -2676,14 +2676,14 @@ namespace bgfx deviceCtx->CSSetShader(NULL, NULL, 0); - ID3D11UnorderedAccessView* uav[BGFX_STATE_TEX_COUNT] = {}; - deviceCtx->CSSetUnorderedAccessViews(0, BGFX_STATE_TEX_COUNT, uav, NULL); + ID3D11UnorderedAccessView* uav[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {}; + deviceCtx->CSSetUnorderedAccessViews(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, uav, NULL); - ID3D11ShaderResourceView* srv[BGFX_STATE_TEX_COUNT] = {}; - deviceCtx->CSSetShaderResources(0, BGFX_STATE_TEX_COUNT, srv); + ID3D11ShaderResourceView* srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {}; + deviceCtx->CSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, srv); - ID3D11SamplerState* samplers[BGFX_STATE_TEX_COUNT] = {}; - m_deviceCtx->CSSetSamplers(0, BGFX_STATE_TEX_COUNT, samplers); + ID3D11SamplerState* samplers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {}; + m_deviceCtx->CSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, samplers); } const RenderDraw& draw = renderItem.draw; @@ -2982,7 +2982,7 @@ namespace bgfx { uint32_t changes = 0; - for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage) { const Sampler& sampler = draw.m_sampler[stage]; Sampler& current = currentState.m_sampler[stage]; diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index 8fdeb0f9..3103efa7 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -1062,7 +1062,7 @@ namespace bgfx { invalidateSamplerState(); - for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage) { DX_CHECK(m_device->SetTexture(stage, NULL) ); } @@ -1134,7 +1134,7 @@ namespace bgfx void invalidateSamplerState() { - for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage) { m_samplerFlags[stage] = UINT32_MAX; } @@ -1416,7 +1416,7 @@ namespace bgfx UniformRegistry m_uniformReg; void* m_uniforms[BGFX_CONFIG_MAX_UNIFORMS]; - uint32_t m_samplerFlags[BGFX_STATE_TEX_COUNT]; + uint32_t m_samplerFlags[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS]; TextureD3D9* m_updateTexture; uint8_t* m_updateTextureBits; @@ -2975,7 +2975,7 @@ namespace bgfx } { - for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage) { const Sampler& sampler = draw.m_sampler[stage]; Sampler& current = currentState.m_sampler[stage]; diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 48351520..cb8cd6eb 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -4424,7 +4424,7 @@ namespace bgfx } { - for (uint32_t stage = 0; stage < BGFX_STATE_TEX_COUNT; ++stage) + for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage) { const Sampler& sampler = draw.m_sampler[stage]; Sampler& current = currentState.m_sampler[stage];