Cleanup.
This commit is contained in:
parent
eec559cc55
commit
d86c16213e
129
src/bgfx_p.h
129
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)<<kSortKeyViewBitShift;
|
||||
//
|
||||
constexpr uint8_t kSortKeyViewNumBits = 10;
|
||||
constexpr uint8_t kSortKeyViewBitShift = 64-kSortKeyViewNumBits;
|
||||
constexpr uint64_t kSortKeyViewMask = uint64_t(BGFX_CONFIG_MAX_VIEWS-1)<<kSortKeyViewBitShift;
|
||||
|
||||
constexpr uint8_t kSortKeyDrawBitShift = kSortKeyViewBitShift - 1;
|
||||
constexpr uint64_t kSortKeyDrawBit = uint64_t(1)<<kSortKeyDrawBitShift;
|
||||
constexpr uint8_t kSortKeyDrawBitShift = kSortKeyViewBitShift - 1;
|
||||
constexpr uint64_t kSortKeyDrawBit = uint64_t(1)<<kSortKeyDrawBitShift;
|
||||
|
||||
//
|
||||
constexpr uint8_t kSortKeyDrawTypeNumBits = 2;
|
||||
constexpr uint8_t kSortKeyDrawTypeBitShift = kSortKeyDrawBitShift - kSortKeyDrawTypeNumBits;
|
||||
constexpr uint64_t kSortKeyDrawTypeMask = uint64_t(3)<<kSortKeyDrawTypeBitShift;
|
||||
//
|
||||
constexpr uint8_t kSortKeyDrawTypeNumBits = 2;
|
||||
constexpr uint8_t kSortKeyDrawTypeBitShift = kSortKeyDrawBitShift - kSortKeyDrawTypeNumBits;
|
||||
constexpr uint64_t kSortKeyDrawTypeMask = uint64_t(3)<<kSortKeyDrawTypeBitShift;
|
||||
|
||||
constexpr uint64_t kSortKeyDrawTypeProgram = uint64_t(0)<<kSortKeyDrawTypeBitShift;
|
||||
constexpr uint64_t kSortKeyDrawTypeDepth = uint64_t(1)<<kSortKeyDrawTypeBitShift;
|
||||
constexpr uint64_t kSortKeyDrawTypeSequence = uint64_t(2)<<kSortKeyDrawTypeBitShift;
|
||||
constexpr uint64_t kSortKeyDrawTypeProgram = uint64_t(0)<<kSortKeyDrawTypeBitShift;
|
||||
constexpr uint64_t kSortKeyDrawTypeDepth = uint64_t(1)<<kSortKeyDrawTypeBitShift;
|
||||
constexpr uint64_t kSortKeyDrawTypeSequence = uint64_t(2)<<kSortKeyDrawTypeBitShift;
|
||||
|
||||
//
|
||||
constexpr uint8_t kSortKeyTransNumBits = 2;
|
||||
//
|
||||
constexpr uint8_t kSortKeyTransNumBits = 2;
|
||||
|
||||
constexpr uint8_t kSortKeyDraw0BlendShift = kSortKeyDrawTypeBitShift - kSortKeyTransNumBits;
|
||||
constexpr uint64_t kSortKeyDraw0BlendMask = uint64_t(0x3)<<kSortKeyDraw0BlendShift;
|
||||
constexpr uint8_t kSortKeyDraw0BlendShift = kSortKeyDrawTypeBitShift - kSortKeyTransNumBits;
|
||||
constexpr uint64_t kSortKeyDraw0BlendMask = uint64_t(0x3)<<kSortKeyDraw0BlendShift;
|
||||
|
||||
constexpr uint8_t kSortKeyDraw0ProgramShift = kSortKeyDraw0BlendShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyDraw0ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw0ProgramShift;
|
||||
constexpr uint8_t kSortKeyDraw0ProgramShift = kSortKeyDraw0BlendShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyDraw0ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw0ProgramShift;
|
||||
|
||||
constexpr uint8_t kSortKeyDraw0DepthShift = kSortKeyDraw0ProgramShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH;
|
||||
constexpr uint64_t kSortKeyDraw0DepthMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<kSortKeyDraw0DepthShift;
|
||||
constexpr uint8_t kSortKeyDraw0DepthShift = kSortKeyDraw0ProgramShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH;
|
||||
constexpr uint64_t kSortKeyDraw0DepthMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<kSortKeyDraw0DepthShift;
|
||||
|
||||
//
|
||||
constexpr uint8_t kSortKeyDraw1DepthShift = kSortKeyDrawTypeBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH;
|
||||
constexpr uint64_t kSortKeyDraw1DepthMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<kSortKeyDraw1DepthShift;
|
||||
//
|
||||
constexpr uint8_t kSortKeyDraw1DepthShift = kSortKeyDrawTypeBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH;
|
||||
constexpr uint64_t kSortKeyDraw1DepthMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_DEPTH)-1)<<kSortKeyDraw1DepthShift;
|
||||
|
||||
constexpr uint8_t kSortKeyDraw1BlendShift = kSortKeyDraw1DepthShift - kSortKeyTransNumBits;
|
||||
constexpr uint64_t kSortKeyDraw1BlendMask = uint64_t(0x3)<<kSortKeyDraw1BlendShift;
|
||||
constexpr uint8_t kSortKeyDraw1BlendShift = kSortKeyDraw1DepthShift - kSortKeyTransNumBits;
|
||||
constexpr uint64_t kSortKeyDraw1BlendMask = uint64_t(0x3)<<kSortKeyDraw1BlendShift;
|
||||
|
||||
constexpr uint8_t kSortKeyDraw1ProgramShift = kSortKeyDraw1BlendShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyDraw1ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw1ProgramShift;
|
||||
constexpr uint8_t kSortKeyDraw1ProgramShift = kSortKeyDraw1BlendShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyDraw1ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw1ProgramShift;
|
||||
|
||||
//
|
||||
constexpr uint8_t kSortKeyDraw2SeqShift = kSortKeyDrawTypeBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ;
|
||||
constexpr uint64_t kSortKeyDraw2SeqMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<kSortKeyDraw2SeqShift;
|
||||
//
|
||||
constexpr uint8_t kSortKeyDraw2SeqShift = kSortKeyDrawTypeBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ;
|
||||
constexpr uint64_t kSortKeyDraw2SeqMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<kSortKeyDraw2SeqShift;
|
||||
|
||||
constexpr uint8_t kSortKeyDraw2BlendShift = kSortKeyDraw2SeqShift - kSortKeyTransNumBits;
|
||||
constexpr uint64_t kSortKeyDraw2BlendMask = uint64_t(0x3)<<kSortKeyDraw2BlendShift;
|
||||
constexpr uint8_t kSortKeyDraw2BlendShift = kSortKeyDraw2SeqShift - kSortKeyTransNumBits;
|
||||
constexpr uint64_t kSortKeyDraw2BlendMask = uint64_t(0x3)<<kSortKeyDraw2BlendShift;
|
||||
|
||||
constexpr uint8_t kSortKeyDraw2ProgramShift = kSortKeyDraw2BlendShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyDraw2ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw2ProgramShift;
|
||||
constexpr uint8_t kSortKeyDraw2ProgramShift = kSortKeyDraw2BlendShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyDraw2ProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyDraw2ProgramShift;
|
||||
|
||||
//
|
||||
constexpr uint8_t kSortKeyComputeSeqShift = kSortKeyDrawBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ;
|
||||
constexpr uint64_t kSortKeyComputeSeqMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<kSortKeyComputeSeqShift;
|
||||
//
|
||||
constexpr uint8_t kSortKeyComputeSeqShift = kSortKeyDrawBitShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ;
|
||||
constexpr uint64_t kSortKeyComputeSeqMask = ( (uint64_t(1)<<BGFX_CONFIG_SORT_KEY_NUM_BITS_SEQ)-1)<<kSortKeyComputeSeqShift;
|
||||
|
||||
constexpr uint8_t kSortKeyComputeProgramShift = kSortKeyComputeSeqShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyComputeProgramShift;
|
||||
constexpr uint8_t kSortKeyComputeProgramShift = kSortKeyComputeSeqShift - BGFX_CONFIG_SORT_KEY_NUM_BITS_PROGRAM;
|
||||
constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRAMS-1)<<kSortKeyComputeProgramShift;
|
||||
|
||||
BX_STATIC_ASSERT(BGFX_CONFIG_MAX_VIEWS <= (1<<kSortKeyViewNumBits) );
|
||||
BX_STATIC_ASSERT( (BGFX_CONFIG_MAX_PROGRAMS & (BGFX_CONFIG_MAX_PROGRAMS-1) ) == 0); // Must be power of 2.
|
||||
@ -1344,20 +1344,25 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
uint32_t m_num;
|
||||
};
|
||||
|
||||
#define CONSTANT_OPCODE_TYPE_SHIFT 27
|
||||
#define CONSTANT_OPCODE_TYPE_MASK UINT32_C(0xf8000000)
|
||||
#define CONSTANT_OPCODE_LOC_SHIFT 11
|
||||
#define CONSTANT_OPCODE_LOC_MASK UINT32_C(0x07fff800)
|
||||
#define CONSTANT_OPCODE_NUM_SHIFT 1
|
||||
#define CONSTANT_OPCODE_NUM_MASK UINT32_C(0x000007fe)
|
||||
#define CONSTANT_OPCODE_COPY_SHIFT 0
|
||||
#define CONSTANT_OPCODE_COPY_MASK UINT32_C(0x00000001)
|
||||
constexpr uint8_t kConstantOpcodeTypeShift = 27;
|
||||
constexpr uint32_t kConstantOpcodeTypeMask = UINT32_C(0xf8000000);
|
||||
constexpr uint8_t kConstantOpcodeLocShift = 11;
|
||||
constexpr uint32_t kConstantOpcodeLocMask = UINT32_C(0x07fff800);
|
||||
constexpr uint8_t kConstantOpcodeNumShift = 1;
|
||||
constexpr uint32_t kConstantOpcodeNumMask = UINT32_C(0x000007fe);
|
||||
constexpr uint8_t kConstantOpcodeCopyShift = 0;
|
||||
constexpr uint32_t kConstantOpcodeCopyMask = UINT32_C(0x00000001);
|
||||
|
||||
#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
|
||||
;
|
||||
|
||||
class UniformBuffer
|
||||
{
|
||||
@ -1394,19 +1399,19 @@ constexpr uint64_t kSortKeyComputeProgramMask = uint64_t(BGFX_CONFIG_MAX_PROGRA
|
||||
|
||||
static uint32_t encodeOpcode(UniformType::Enum _type, uint16_t _loc, uint16_t _num, uint16_t _copy)
|
||||
{
|
||||
const uint32_t type = _type << CONSTANT_OPCODE_TYPE_SHIFT;
|
||||
const uint32_t loc = _loc << CONSTANT_OPCODE_LOC_SHIFT;
|
||||
const uint32_t num = _num << CONSTANT_OPCODE_NUM_SHIFT;
|
||||
const uint32_t copy = _copy << CONSTANT_OPCODE_COPY_SHIFT;
|
||||
const uint32_t type = _type << kConstantOpcodeTypeShift;
|
||||
const uint32_t loc = _loc << kConstantOpcodeLocShift;
|
||||
const uint32_t num = _num << kConstantOpcodeNumShift;
|
||||
const uint32_t copy = _copy << kConstantOpcodeCopyShift;
|
||||
return type|loc|num|copy;
|
||||
}
|
||||
|
||||
static void decodeOpcode(uint32_t _opcode, UniformType::Enum& _type, uint16_t& _loc, uint16_t& _num, uint16_t& _copy)
|
||||
{
|
||||
const uint32_t type = (_opcode&CONSTANT_OPCODE_TYPE_MASK) >> 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);
|
||||
|
@ -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:
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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) )
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
);
|
||||
|
@ -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];
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -588,7 +588,7 @@ namespace bgfx { namespace metal
|
||||
uint16_t count = static_cast<uint16_t>(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];
|
||||
|
@ -641,12 +641,12 @@ namespace bgfx { namespace spirv
|
||||
uint16_t count = static_cast<uint16_t>(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);
|
||||
|
Loading…
Reference in New Issue
Block a user