diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 23689b437..0b8c574b7 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -931,61 +931,61 @@ namespace bgfx uint32_t m_minCapacity; }; -// -constexpr uint8_t kSortKeyViewNumBits = 10; -constexpr uint8_t kSortKeyViewBitShift = 64-kSortKeyViewNumBits; -constexpr uint64_t kSortKeyViewMask = uint64_t(BGFX_CONFIG_MAX_VIEWS-1)<> CONSTANT_OPCODE_TYPE_SHIFT; - const uint32_t loc = (_opcode&CONSTANT_OPCODE_LOC_MASK ) >> CONSTANT_OPCODE_LOC_SHIFT; - const uint32_t num = (_opcode&CONSTANT_OPCODE_NUM_MASK ) >> CONSTANT_OPCODE_NUM_SHIFT; - const uint32_t copy = (_opcode&CONSTANT_OPCODE_COPY_MASK); // >> CONSTANT_OPCODE_COPY_SHIFT; + const uint32_t type = (_opcode&kConstantOpcodeTypeMask) >> kConstantOpcodeTypeShift; + const uint32_t loc = (_opcode&kConstantOpcodeLocMask ) >> kConstantOpcodeLocShift; + const uint32_t num = (_opcode&kConstantOpcodeNumMask ) >> kConstantOpcodeNumShift; + const uint32_t copy = (_opcode&kConstantOpcodeCopyMask); // >> kConstantOpcodeCopyShift; _type = (UniformType::Enum)(type); _copy = (uint16_t)copy; @@ -3897,7 +3902,7 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA uint8_t type = 0; bx::read(&reader, type, &err); - type &= ~BGFX_UNIFORM_MASK; + type &= ~kUniformMask; uint8_t num; bx::read(&reader, num, &err); diff --git a/src/renderer.h b/src/renderer.h index 8780930a6..2771eabcc 100644 --- a/src/renderer.h +++ b/src/renderer.h @@ -100,8 +100,8 @@ namespace bgfx for (uint32_t ii = 0, num = _program.m_numPredefined; ii < num; ++ii) { const PredefinedUniform& predefined = _program.m_predefined[ii]; - uint8_t flags = predefined.m_type&BGFX_UNIFORM_FRAGMENTBIT; - switch (predefined.m_type&(~BGFX_UNIFORM_FRAGMENTBIT) ) + uint8_t flags = predefined.m_type&kUniformFragmentBit; + switch (predefined.m_type&(~kUniformFragmentBit) ) { case PredefinedUniform::ViewRect: { diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index e6b990733..a46f32227 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -2454,7 +2454,7 @@ namespace bgfx { namespace d3d11 void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs) { - if (_flags&BGFX_UNIFORM_FRAGMENTBIT) + if (_flags&kUniformFragmentBit) { bx::memCopy(&m_fsScratch[_regIndex], _val, _numRegs*16); m_fsChanges += _numRegs; @@ -3263,7 +3263,7 @@ namespace bgfx { namespace d3d11 #define CASE_IMPLEMENT_UNIFORM(_uniform, _dxsuffix, _type) \ case UniformType::_uniform: \ - case UniformType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \ + case UniformType::_uniform|kUniformFragmentBit: \ { \ setShaderUniform(uint8_t(type), loc, data, num); \ } \ @@ -3272,7 +3272,7 @@ namespace bgfx { namespace d3d11 switch ( (uint32_t)type) { case UniformType::Mat3: - case UniformType::Mat3|BGFX_UNIFORM_FRAGMENTBIT: \ + case UniformType::Mat3|kUniformFragmentBit: \ { float* value = (float*)data; for (uint32_t ii = 0, count = num/3; ii < count; ++ii, loc += 3*16, value += 9) @@ -3913,7 +3913,7 @@ namespace bgfx { namespace d3d11 , count ); - const uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0; + const uint8_t fragmentBit = fragment ? kUniformFragmentBit : 0; if (0 < count) { @@ -3955,7 +3955,7 @@ namespace bgfx { namespace d3d11 m_predefined[m_numPredefined].m_type = uint8_t(predefined|fragmentBit); m_numPredefined++; } - else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) ) + else if (0 == (kUniformSamplerBit & type) ) { const UniformRegInfo* info = s_renderD3D11->m_uniformReg.find(name); BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name); @@ -3979,7 +3979,7 @@ namespace bgfx { namespace d3d11 BX_TRACE("\t%s: %s (%s), num %2d, r.index %3d, r.count %2d" , kind , name - , getUniformTypeName(UniformType::Enum(type&~BGFX_UNIFORM_MASK) ) + , getUniformTypeName(UniformType::Enum(type&~kUniformMask) ) , num , regIndex , regCount diff --git a/src/renderer_d3d12.cpp b/src/renderer_d3d12.cpp index 046fa3506..cfe59ce76 100644 --- a/src/renderer_d3d12.cpp +++ b/src/renderer_d3d12.cpp @@ -2324,7 +2324,7 @@ namespace bgfx { namespace d3d12 void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs) { - if (_flags&BGFX_UNIFORM_FRAGMENTBIT) + if (_flags&kUniformFragmentBit) { bx::memCopy(&m_fsScratch[_regIndex], _val, _numRegs*16); } @@ -3150,7 +3150,7 @@ namespace bgfx { namespace d3d12 #define CASE_IMPLEMENT_UNIFORM(_uniform, _dxsuffix, _type) \ case UniformType::_uniform: \ - case UniformType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \ + case UniformType::_uniform|kUniformFragmentBit: \ { \ setShaderUniform(uint8_t(type), loc, data, num); \ } \ @@ -3159,7 +3159,7 @@ namespace bgfx { namespace d3d12 switch ( (uint32_t)type) { case UniformType::Mat3: - case UniformType::Mat3|BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Mat3|kUniformFragmentBit: { float* value = (float*)data; for (uint32_t ii = 0, count = num/3; ii < count; ++ii, loc += 3*16, value += 9) @@ -4500,7 +4500,7 @@ namespace bgfx { namespace d3d12 , count ); - uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0; + uint8_t fragmentBit = fragment ? kUniformFragmentBit : 0; if (0 < count) { @@ -4542,7 +4542,7 @@ namespace bgfx { namespace d3d12 m_predefined[m_numPredefined].m_type = uint8_t(predefined|fragmentBit); m_numPredefined++; } - else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) ) + else if (0 == (kUniformSamplerBit & type) ) { const UniformRegInfo* info = s_renderD3D12->m_uniformReg.find(name); BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name); @@ -4566,7 +4566,7 @@ namespace bgfx { namespace d3d12 BX_TRACE("\t%s: %s (%s), num %2d, r.index %3d, r.count %2d" , kind , name - , getUniformTypeName(UniformType::Enum(type&~BGFX_UNIFORM_MASK) ) + , getUniformTypeName(UniformType::Enum(type&~kUniformMask) ) , num , regIndex , regCount diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index d74870a2c..68754a6ef 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -1517,7 +1517,7 @@ namespace bgfx { namespace d3d9 void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs) { - if (_flags&BGFX_UNIFORM_FRAGMENTBIT) + if (_flags&kUniformFragmentBit) { DX_CHECK(m_device->SetPixelShaderConstantF(_regIndex, (const float*)_val, _numRegs) ); } @@ -1902,7 +1902,7 @@ namespace bgfx { namespace d3d9 } \ break; \ \ - case UniformType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \ + case UniformType::_uniform|kUniformFragmentBit: \ { \ _type* value = (_type*)data; \ DX_CHECK(device->SetPixelShaderConstant##_dxsuffix(loc, value, num) ); \ @@ -1934,7 +1934,7 @@ namespace bgfx { namespace d3d9 } break; - case UniformType::Mat3|BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Mat3|kUniformFragmentBit: { float* value = (float*)data; for (uint32_t ii = 0, count = num/3; ii < count; ++ii, loc += 3, value += 9) @@ -2424,7 +2424,7 @@ namespace bgfx { namespace d3d9 BX_TRACE("Shader consts %d", count); - uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0; + uint8_t fragmentBit = fragment ? kUniformFragmentBit : 0; if (0 < count) { @@ -2466,7 +2466,7 @@ namespace bgfx { namespace d3d9 m_predefined[m_numPredefined].m_type = uint8_t(predefined|fragmentBit); m_numPredefined++; } - else if (0 == (BGFX_UNIFORM_SAMPLERBIT & type) ) + else if (0 == (kUniformSamplerBit & type) ) { const UniformRegInfo* info = s_renderD3D9->m_uniformReg.find(name); BX_WARN(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name); @@ -2490,7 +2490,7 @@ namespace bgfx { namespace d3d9 BX_TRACE("\t%s: %s (%s), num %2d, r.index %3d, r.count %2d" , kind , name - , getUniformTypeName(UniformType::Enum(type&~BGFX_UNIFORM_MASK) ) + , getUniformTypeName(UniformType::Enum(type&~kUniformMask) ) , num , regIndex , regCount diff --git a/src/renderer_mtl.mm b/src/renderer_mtl.mm index 3d1a1c6f5..af07d722f 100644 --- a/src/renderer_mtl.mm +++ b/src/renderer_mtl.mm @@ -1388,7 +1388,7 @@ namespace bgfx { namespace mtl void setShaderUniform(uint8_t _flags, uint32_t _loc, const void* _val, uint32_t _numRegs) { - uint32_t offset = 0 != (_flags&BGFX_UNIFORM_FRAGMENTBIT) + uint32_t offset = 0 != (_flags&kUniformFragmentBit) ? m_uniformBufferFragmentOffset : m_uniformBufferVertexOffset ; @@ -1439,7 +1439,7 @@ namespace bgfx { namespace mtl #define CASE_IMPLEMENT_UNIFORM(_uniform, _dxsuffix, _type) \ case UniformType::_uniform: \ - case UniformType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \ + case UniformType::_uniform|kUniformFragmentBit: \ { \ setShaderUniform(uint8_t(type), loc, data, num); \ } \ @@ -1448,7 +1448,7 @@ namespace bgfx { namespace mtl switch ( (uint32_t)type) { case UniformType::Mat3: - case UniformType::Mat3|BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Mat3|kUniformFragmentBit: { float* value = (float*)data; for (uint32_t ii = 0, count = num/3; ii < count; ++ii, loc += 3*16, value += 9) @@ -1796,7 +1796,7 @@ namespace bgfx { namespace mtl ? ps->m_vshConstantBuffer : ps->m_fshConstantBuffer ; - const int8_t fragmentBit = (1 == shaderType ? BGFX_UNIFORM_FRAGMENTBIT : 0); + const int8_t fragmentBit = (1 == shaderType ? kUniformFragmentBit : 0); for (MTLArgument* arg in (shaderType == 0 ? _vertexArgs : _fragmentArgs) ) { diff --git a/src/renderer_vk.cpp b/src/renderer_vk.cpp index d9548bc75..7121f10fc 100644 --- a/src/renderer_vk.cpp +++ b/src/renderer_vk.cpp @@ -3011,7 +3011,7 @@ VK_IMPORT_DEVICE void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs) { - if (_flags & BGFX_UNIFORM_FRAGMENTBIT) + if (_flags & kUniformFragmentBit) { bx::memCopy(&m_fsScratch[_regIndex], _val, _numRegs*16); } @@ -4021,7 +4021,7 @@ VK_IMPORT_DEVICE #define CASE_IMPLEMENT_UNIFORM(_uniform, _dxsuffix, _type) \ case UniformType::_uniform: \ - case UniformType::_uniform|BGFX_UNIFORM_FRAGMENTBIT: \ + case UniformType::_uniform|kUniformFragmentBit: \ { \ setShaderUniform(uint8_t(type), loc, data, num); \ } \ @@ -4030,7 +4030,7 @@ VK_IMPORT_DEVICE switch ( (uint32_t)type) { case UniformType::Mat3: - case UniformType::Mat3|BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Mat3|kUniformFragmentBit: { float* value = (float*)data; for (uint32_t ii = 0, count = num/3; ii < count; ++ii, loc += 3*16, value += 9) @@ -4054,7 +4054,7 @@ VK_IMPORT_DEVICE break; case UniformType::Sampler: - case UniformType::Sampler|BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Sampler|kUniformFragmentBit: // do nothing, but VkDescriptorSetImageInfo would be set before drawing break; // CASE_IMPLEMENT_UNIFORM(Sampler, I, int); @@ -4783,7 +4783,7 @@ VK_DESTROY , count ); - uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0; + uint8_t fragmentBit = fragment ? kUniformFragmentBit : 0; for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii) { @@ -4832,7 +4832,7 @@ VK_DESTROY m_predefined[m_numPredefined].m_type = uint8_t(predefined|fragmentBit); m_numPredefined++; } - else if (UniformType::End == (~BGFX_UNIFORM_MASK & type)) + else if (UniformType::End == (~kUniformMask & type)) { // regCount is used for descriptor type const bool isBuffer = regCount == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; @@ -4844,7 +4844,7 @@ VK_DESTROY kind = "storage"; } - else if (UniformType::Sampler == (~BGFX_UNIFORM_MASK & type) ) + else if (UniformType::Sampler == (~kUniformMask & type) ) { const uint16_t stage = regIndex - 16 - (fragment ? 48 : 0); // regIndex is used for image/sampler binding index @@ -4879,7 +4879,7 @@ VK_DESTROY BX_TRACE("\t%s: %s (%s), num %2d, r.index %3d, r.count %2d" , kind , name - , getUniformTypeName(UniformType::Enum(type&~BGFX_UNIFORM_MASK) ) + , getUniformTypeName(UniformType::Enum(type&~kUniformMask) ) , num , regIndex , regCount diff --git a/src/renderer_webgpu.cpp b/src/renderer_webgpu.cpp index de4a4e2aa..e6b0b6a10 100644 --- a/src/renderer_webgpu.cpp +++ b/src/renderer_webgpu.cpp @@ -1406,7 +1406,7 @@ namespace bgfx { namespace webgpu void setShaderUniform(uint8_t _flags, uint32_t _regIndex, const void* _val, uint32_t _numRegs) { - if(_flags&BGFX_UNIFORM_FRAGMENTBIT) + if(_flags&kUniformFragmentBit) { bx::memCopy(&m_fsScratch[_regIndex], _val, _numRegs * 16); } @@ -1474,7 +1474,7 @@ namespace bgfx { namespace webgpu switch ( (uint32_t)type) { case UniformType::Mat3: - case UniformType::Mat3|BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Mat3|kUniformFragmentBit: { float* value = (float*)data; for (uint32_t ii = 0, count = num/3; ii < count; ++ii, loc += 3*16, value += 9) @@ -1498,11 +1498,11 @@ namespace bgfx { namespace webgpu break; case UniformType::Sampler: - case UniformType::Sampler | BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Sampler | kUniformFragmentBit: case UniformType::Vec4: - case UniformType::Vec4 | BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Vec4 | kUniformFragmentBit: case UniformType::Mat4: - case UniformType::Mat4 | BGFX_UNIFORM_FRAGMENTBIT: + case UniformType::Mat4 | kUniformFragmentBit: { setShaderUniform(uint8_t(type), loc, data, num); } @@ -2482,7 +2482,7 @@ namespace bgfx { namespace webgpu ); const bool fragment = isShaderType(magic, 'F'); - uint8_t fragmentBit = fragment ? BGFX_UNIFORM_FRAGMENTBIT : 0; + uint8_t fragmentBit = fragment ? kUniformFragmentBit : 0; BX_ASSERT(!isShaderVerLess(magic, 7), "WebGPU backend supports only shader binary version >= 7"); @@ -2526,11 +2526,11 @@ namespace bgfx { namespace webgpu m_predefined[m_numPredefined].m_type = uint8_t(predefined|fragmentBit); m_numPredefined++; } - else if (UniformType::End == (~BGFX_UNIFORM_MASK & type)) + else if (UniformType::End == (~kUniformMask & type)) { // regCount is used for descriptor type const bool buffer = regCount == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; - const bool readonly = (type & BGFX_UNIFORM_READONLYBIT) != 0; + const bool readonly = (type & kUniformReadOnlyBit) != 0; const uint8_t stage = regIndex - (buffer ? 16 : 32) - (fragment ? 48 : 0); @@ -2559,7 +2559,7 @@ namespace bgfx { namespace webgpu kind = "storage"; } - else if (UniformType::Sampler == (~BGFX_UNIFORM_MASK & type)) + else if (UniformType::Sampler == (~kUniformMask & type)) { const UniformRegInfo* info = s_renderWgpu->m_uniformReg.find(name); BX_ASSERT(NULL != info, "User defined uniform '%s' is not found, it won't be set.", name); @@ -2577,7 +2577,7 @@ namespace bgfx { namespace webgpu m_textures[m_numSamplers].viewDimension = wgpu::TextureViewDimension(texDimension); m_textures[m_numSamplers].textureComponentType = wgpu::TextureComponentType(texComponent); - const bool comparisonSampler = (type & BGFX_UNIFORM_COMPAREBIT) != 0; + const bool comparisonSampler = (type & kUniformCompareBit) != 0; m_samplers[m_numSamplers] = wgpu::BindGroupLayoutBinding(); m_samplers[m_numSamplers].binding = regIndex + 16; @@ -2607,7 +2607,7 @@ namespace bgfx { namespace webgpu BX_TRACE("\t%s: %s (%s), r.index %3d, r.count %2d" , kind , name - , getUniformTypeName(UniformType::Enum(type&~BGFX_UNIFORM_MASK) ) + , getUniformTypeName(UniformType::Enum(type&~kUniformMask) ) , regIndex , regCount ); diff --git a/tools/shaderc/shaderc.cpp b/tools/shaderc/shaderc.cpp index 777e6251d..7051a6d77 100644 --- a/tools/shaderc/shaderc.cpp +++ b/tools/shaderc/shaderc.cpp @@ -279,7 +279,7 @@ namespace bgfx const char* getUniformTypeName(UniformType::Enum _enum) { - uint32_t idx = _enum & ~(BGFX_UNIFORM_FRAGMENTBIT|BGFX_UNIFORM_SAMPLERBIT); + uint32_t idx = _enum & ~(kUniformFragmentBit|kUniformSamplerBit); if (idx < UniformType::Count) { return s_uniformTypeName[idx]; diff --git a/tools/shaderc/shaderc.h b/tools/shaderc/shaderc.h index 763213a9f..5e2f5e515 100644 --- a/tools/shaderc/shaderc.h +++ b/tools/shaderc/shaderc.h @@ -107,11 +107,16 @@ namespace bgfx bx::StringView nextWord(bx::StringView& _parse); -#define BGFX_UNIFORM_FRAGMENTBIT UINT8_C(0x10) -#define BGFX_UNIFORM_SAMPLERBIT UINT8_C(0x20) -#define BGFX_UNIFORM_READONLYBIT UINT8_C(0x40) -#define BGFX_UNIFORM_COMPAREBIT UINT8_C(0x80) -#define BGFX_UNIFORM_MASK (BGFX_UNIFORM_FRAGMENTBIT|BGFX_UNIFORM_SAMPLERBIT|BGFX_UNIFORM_READONLYBIT|BGFX_UNIFORM_COMPAREBIT) + constexpr uint8_t kUniformFragmentBit = 0x10; + constexpr uint8_t kUniformSamplerBit = 0x20; + constexpr uint8_t kUniformReadOnlyBit = 0x40; + constexpr uint8_t kUniformCompareBit = 0x80; + constexpr uint8_t kUniformMask = 0 + | kUniformFragmentBit + | kUniformSamplerBit + | kUniformReadOnlyBit + | kUniformCompareBit + ; const char* getUniformTypeName(UniformType::Enum _enum); UniformType::Enum nameToUniformTypeEnum(const char* _name); diff --git a/tools/shaderc/shaderc_hlsl.cpp b/tools/shaderc/shaderc_hlsl.cpp index bd6ad7f64..604b7ebd4 100644 --- a/tools/shaderc/shaderc_hlsl.cpp +++ b/tools/shaderc/shaderc_hlsl.cpp @@ -366,7 +366,7 @@ namespace bgfx { namespace hlsl Uniform un; un.name = '$' == name[0] ? name + 1 : name; un.type = isSampler(desc.Type) - ? UniformType::Enum(BGFX_UNIFORM_SAMPLERBIT | type) + ? UniformType::Enum(kUniformSamplerBit | type) : type ; un.num = (uint8_t)ctType.Elements; @@ -527,7 +527,7 @@ namespace bgfx { namespace hlsl { Uniform un; un.name.assign(bindDesc.Name, (end.getPtr() - bindDesc.Name) ); - un.type = UniformType::Enum(BGFX_UNIFORM_SAMPLERBIT | UniformType::Sampler); + un.type = UniformType::Enum(kUniformSamplerBit | UniformType::Sampler); un.num = 1; un.regIndex = uint16_t(bindDesc.BindPoint); un.regCount = uint16_t(bindDesc.BindCount); @@ -724,7 +724,7 @@ namespace bgfx { namespace hlsl uint16_t count = (uint16_t)uniforms.size(); bx::write(_writer, count); - uint32_t fragmentBit = profile[0] == 'p' ? BGFX_UNIFORM_FRAGMENTBIT : 0; + uint32_t fragmentBit = profile[0] == 'p' ? kUniformFragmentBit : 0; for (UniformArray::const_iterator it = uniforms.begin(); it != uniforms.end(); ++it) { const Uniform& un = *it; diff --git a/tools/shaderc/shaderc_metal.cpp b/tools/shaderc/shaderc_metal.cpp index cc4e05c30..57e0f87c1 100644 --- a/tools/shaderc/shaderc_metal.cpp +++ b/tools/shaderc/shaderc_metal.cpp @@ -588,7 +588,7 @@ namespace bgfx { namespace metal uint16_t count = static_cast(uniforms.size()); bx::write(_writer, count); - uint32_t fragmentBit = isFragmentShader ? BGFX_UNIFORM_FRAGMENTBIT : 0; + uint32_t fragmentBit = isFragmentShader ? kUniformFragmentBit : 0; for (uint16_t ii = 0; ii < count; ++ii) { const Uniform& un = uniforms[ii]; diff --git a/tools/shaderc/shaderc_spirv.cpp b/tools/shaderc/shaderc_spirv.cpp index cc9a6d57c..5cdd4dcd2 100644 --- a/tools/shaderc/shaderc_spirv.cpp +++ b/tools/shaderc/shaderc_spirv.cpp @@ -641,12 +641,12 @@ namespace bgfx { namespace spirv uint16_t count = static_cast(uniforms.size()); bx::write(_writer, count); - uint32_t fragmentBit = isFragmentShader ? BGFX_UNIFORM_FRAGMENTBIT : 0; + uint32_t fragmentBit = isFragmentShader ? kUniformFragmentBit : 0; for (uint16_t ii = 0; ii < count; ++ii) { const Uniform& un = uniforms[ii]; - if ((un.type & ~BGFX_UNIFORM_MASK) > UniformType::End) + if ((un.type & ~kUniformMask) > UniformType::End) size = bx::max(size, (uint16_t)(un.regIndex + un.regCount*16)); uint8_t nameSize = (uint8_t)un.name.size(); @@ -1001,10 +1001,10 @@ namespace bgfx { namespace spirv Uniform un; un.name = uniform_name; - if (isCompareSampler) - un.type = UniformType::Enum(BGFX_UNIFORM_SAMPLERBIT | BGFX_UNIFORM_COMPAREBIT | UniformType::Sampler); - else - un.type = UniformType::Enum(BGFX_UNIFORM_SAMPLERBIT | UniformType::Sampler); + un.type = UniformType::Enum(UniformType::Sampler + | kUniformSamplerBit + | (isCompareSampler ? kUniformCompareBit : 0) + ); un.texComponent = uint8_t(SpirvCrossBaseTypeToFormatType(componentType)); un.texDimension = uint8_t(SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed)); @@ -1032,13 +1032,13 @@ namespace bgfx { namespace spirv spirv_cross::Bitset flags = refl.get_buffer_block_flags(resource.id); UniformType::Enum type = flags.get(spv::DecorationNonWritable) - ? UniformType::Enum(BGFX_UNIFORM_READONLYBIT | UniformType::End) + ? UniformType::Enum(kUniformReadOnlyBit | UniformType::End) : UniformType::End; Uniform un; un.name = uniform_name; un.type = type; - + un.texComponent = uint8_t(SpirvCrossBaseTypeToFormatType(componentType)); un.texDimension = uint8_t(SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed)); @@ -1060,7 +1060,7 @@ namespace bgfx { namespace spirv { spirv_cross::Bitset flags = refl.get_buffer_block_flags(resource.id); UniformType::Enum type = flags.get(spv::DecorationNonWritable) - ? UniformType::Enum(BGFX_UNIFORM_READONLYBIT | UniformType::End) + ? UniformType::Enum(kUniformReadOnlyBit | UniformType::End) : UniformType::End; uint32_t binding_index = refl.get_decoration(resource.id, spv::Decoration::DecorationBinding);