mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Cleanup.
This commit is contained in:
parent
444384469d
commit
bb89e6291c
7 changed files with 41 additions and 39 deletions
|
@ -1402,9 +1402,10 @@ namespace bgfx
|
||||||
|
|
||||||
void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags)
|
void setTexture(uint8_t _stage, UniformHandle _sampler, TextureHandle _handle, uint32_t _flags)
|
||||||
{
|
{
|
||||||
Binding& sampler = m_draw.m_bind[_stage];
|
Binding& bind = m_draw.m_bind[_stage];
|
||||||
sampler.m_idx = _handle.idx;
|
bind.m_idx = _handle.idx;
|
||||||
sampler.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS)
|
bind.m_type = Binding::Texture;
|
||||||
|
bind.m_un.m_draw.m_flags = (_flags&BGFX_SAMPLER_DEFAULT_FLAGS)
|
||||||
? BGFX_SAMPLER_DEFAULT_FLAGS
|
? BGFX_SAMPLER_DEFAULT_FLAGS
|
||||||
: _flags
|
: _flags
|
||||||
;
|
;
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace bgfx
|
||||||
}
|
}
|
||||||
|
|
||||||
template<uint16_t mtxRegs, typename RendererContext, typename Program, typename Draw>
|
template<uint16_t mtxRegs, typename RendererContext, typename Program, typename Draw>
|
||||||
void setPredefined(RendererContext* _renderer, uint8_t view, uint8_t eye, Program& _program, Frame* _render, const Draw& _draw)
|
void setPredefined(RendererContext* _renderer, uint16_t view, uint8_t eye, Program& _program, Frame* _render, const Draw& _draw)
|
||||||
{
|
{
|
||||||
for (uint32_t ii = 0, num = _program.m_numPredefined; ii < num; ++ii)
|
for (uint32_t ii = 0, num = _program.m_numPredefined; ii < num; ++ii)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4217,7 +4217,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
|
|
||||||
uint16_t programIdx = invalidHandle;
|
uint16_t programIdx = invalidHandle;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint16_t view = UINT16_MAX;
|
||||||
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
||||||
|
|
||||||
const uint64_t primType = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
|
const uint64_t primType = _render->m_debug&BGFX_DEBUG_WIREFRAME ? BGFX_STATE_PT_LINES : 0;
|
||||||
|
@ -4269,7 +4269,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
restartState = 2;
|
restartState = 2;
|
||||||
item = restartItem;
|
item = restartItem;
|
||||||
restartItem = numItems;
|
restartItem = numItems;
|
||||||
view = 0xff;
|
view = UINT16_MAX;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4708,16 +4708,16 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
uint32_t changes = 0;
|
uint32_t changes = 0;
|
||||||
for (uint8_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
for (uint8_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
||||||
{
|
{
|
||||||
const Binding& sampler = draw.m_bind[stage];
|
const Binding& bind = draw.m_bind[stage];
|
||||||
Binding& current = currentState.m_bind[stage];
|
Binding& current = currentState.m_bind[stage];
|
||||||
if (current.m_idx != sampler.m_idx
|
if (current.m_idx != bind.m_idx
|
||||||
|| current.m_un.m_draw.m_flags != sampler.m_un.m_draw.m_flags
|
|| current.m_un.m_draw.m_flags != bind.m_un.m_draw.m_flags
|
||||||
|| programChanged)
|
|| programChanged)
|
||||||
{
|
{
|
||||||
if (invalidHandle != sampler.m_idx)
|
if (invalidHandle != bind.m_idx)
|
||||||
{
|
{
|
||||||
TextureD3D11& texture = m_textures[sampler.m_idx];
|
TextureD3D11& texture = m_textures[bind.m_idx];
|
||||||
texture.commit(stage, sampler.m_un.m_draw.m_flags);
|
texture.commit(stage, bind.m_un.m_draw.m_flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -4728,7 +4728,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||||
++changes;
|
++changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
current = sampler;
|
current = bind;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 < changes)
|
if (0 < changes)
|
||||||
|
|
|
@ -4182,7 +4182,7 @@ data.NumQualityLevels = 0;
|
||||||
uint32_t currentBindHash = 0;
|
uint32_t currentBindHash = 0;
|
||||||
ID3D12PipelineState* currentPso = NULL;
|
ID3D12PipelineState* currentPso = NULL;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint16_t view = UINT16_MAX;
|
||||||
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
||||||
float alphaRef = 0.0f;
|
float alphaRef = 0.0f;
|
||||||
uint32_t blendFactor = 0;
|
uint32_t blendFactor = 0;
|
||||||
|
@ -4322,8 +4322,9 @@ data.NumQualityLevels = 0;
|
||||||
|
|
||||||
viewState.setPredefined<4>(this, view, 0, program, _render, compute);
|
viewState.setPredefined<4>(this, view, 0, program, _render, compute);
|
||||||
|
|
||||||
if (constantsChanged
|
constantsChanged |= program.m_numPredefined > 0;
|
||||||
|| program.m_numPredefined > 0)
|
|
||||||
|
if (constantsChanged)
|
||||||
{
|
{
|
||||||
commitShaderConstants(gpuAddress);
|
commitShaderConstants(gpuAddress);
|
||||||
}
|
}
|
||||||
|
@ -4512,14 +4513,14 @@ data.NumQualityLevels = 0;
|
||||||
srvHandle[0].ptr = 0;
|
srvHandle[0].ptr = 0;
|
||||||
for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
||||||
{
|
{
|
||||||
const Binding& sampler = draw.m_bind[stage];
|
const Binding& bind = draw.m_bind[stage];
|
||||||
if (invalidHandle != sampler.m_idx)
|
if (invalidHandle != bind.m_idx)
|
||||||
{
|
{
|
||||||
TextureD3D12& texture = m_textures[sampler.m_idx];
|
TextureD3D12& texture = m_textures[bind.m_idx];
|
||||||
texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
|
texture.setState(m_commandList, D3D12_RESOURCE_STATE_GENERIC_READ);
|
||||||
scratchBuffer.allocSrv(srvHandle[stage], texture);
|
scratchBuffer.allocSrv(srvHandle[stage], texture);
|
||||||
samplerFlags[stage] = (0 == (BGFX_SAMPLER_DEFAULT_FLAGS & sampler.m_un.m_draw.m_flags)
|
samplerFlags[stage] = (0 == (BGFX_SAMPLER_DEFAULT_FLAGS & bind.m_un.m_draw.m_flags)
|
||||||
? sampler.m_un.m_draw.m_flags
|
? bind.m_un.m_draw.m_flags
|
||||||
: texture.m_flags
|
: texture.m_flags
|
||||||
) & BGFX_TEXTURE_SAMPLER_BITS_MASK
|
) & BGFX_TEXTURE_SAMPLER_BITS_MASK
|
||||||
;
|
;
|
||||||
|
|
|
@ -3196,7 +3196,7 @@ namespace bgfx { namespace d3d9
|
||||||
DX_CHECK(device->SetRenderState(D3DRS_FILLMODE, _render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
|
DX_CHECK(device->SetRenderState(D3DRS_FILLMODE, _render->m_debug&BGFX_DEBUG_WIREFRAME ? D3DFILL_WIREFRAME : D3DFILL_SOLID) );
|
||||||
uint16_t programIdx = invalidHandle;
|
uint16_t programIdx = invalidHandle;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint16_t view = UINT16_MAX;
|
||||||
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
||||||
uint32_t blendFactor = 0;
|
uint32_t blendFactor = 0;
|
||||||
|
|
||||||
|
@ -3542,15 +3542,15 @@ namespace bgfx { namespace d3d9
|
||||||
{
|
{
|
||||||
for (uint8_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
for (uint8_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
||||||
{
|
{
|
||||||
const Binding& sampler = draw.m_bind[stage];
|
const Binding& bind = draw.m_bind[stage];
|
||||||
Binding& current = currentState.m_bind[stage];
|
Binding& current = currentState.m_bind[stage];
|
||||||
if (current.m_idx != sampler.m_idx
|
if (current.m_idx != bind.m_idx
|
||||||
|| current.m_un.m_draw.m_flags != sampler.m_un.m_draw.m_flags
|
|| current.m_un.m_draw.m_flags != bind.m_un.m_draw.m_flags
|
||||||
|| programChanged)
|
|| programChanged)
|
||||||
{
|
{
|
||||||
if (invalidHandle != sampler.m_idx)
|
if (invalidHandle != bind.m_idx)
|
||||||
{
|
{
|
||||||
m_textures[sampler.m_idx].commit(stage, sampler.m_un.m_draw.m_flags);
|
m_textures[bind.m_idx].commit(stage, bind.m_un.m_draw.m_flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3558,7 +3558,7 @@ namespace bgfx { namespace d3d9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = sampler;
|
current = bind;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4949,7 +4949,7 @@ namespace bgfx { namespace gl
|
||||||
|
|
||||||
uint16_t programIdx = invalidHandle;
|
uint16_t programIdx = invalidHandle;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint16_t view = UINT16_MAX;
|
||||||
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
||||||
int32_t height = hmdEnabled
|
int32_t height = hmdEnabled
|
||||||
? _render->m_hmd.height
|
? _render->m_hmd.height
|
||||||
|
@ -5013,7 +5013,7 @@ namespace bgfx { namespace gl
|
||||||
restartState = 2;
|
restartState = 2;
|
||||||
item = restartItem;
|
item = restartItem;
|
||||||
restartItem = numItems;
|
restartItem = numItems;
|
||||||
view = 0xff;
|
view = UINT16_MAX;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5558,20 +5558,20 @@ namespace bgfx { namespace gl
|
||||||
{
|
{
|
||||||
for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
for (uint32_t stage = 0; stage < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++stage)
|
||||||
{
|
{
|
||||||
const Binding& sampler = draw.m_bind[stage];
|
const Binding& bind = draw.m_bind[stage];
|
||||||
Binding& current = currentState.m_bind[stage];
|
Binding& current = currentState.m_bind[stage];
|
||||||
if (current.m_idx != sampler.m_idx
|
if (current.m_idx != bind.m_idx
|
||||||
|| current.m_un.m_draw.m_flags != sampler.m_un.m_draw.m_flags
|
|| current.m_un.m_draw.m_flags != bind.m_un.m_draw.m_flags
|
||||||
|| programChanged)
|
|| programChanged)
|
||||||
{
|
{
|
||||||
if (invalidHandle != sampler.m_idx)
|
if (invalidHandle != bind.m_idx)
|
||||||
{
|
{
|
||||||
TextureGL& texture = m_textures[sampler.m_idx];
|
TextureGL& texture = m_textures[bind.m_idx];
|
||||||
texture.commit(stage, sampler.m_un.m_draw.m_flags);
|
texture.commit(stage, bind.m_un.m_draw.m_flags);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current = sampler;
|
current = bind;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2069,7 +2069,7 @@ namespace bgfx { namespace mtl
|
||||||
|
|
||||||
uint16_t programIdx = invalidHandle;
|
uint16_t programIdx = invalidHandle;
|
||||||
SortKey key;
|
SortKey key;
|
||||||
uint8_t view = 0xff;
|
uint16_t view = UINT16_MAX;
|
||||||
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
|
||||||
|
|
||||||
//ASK: why should we use this? It changes topology, so possible renders a big mess, doesn't it?
|
//ASK: why should we use this? It changes topology, so possible renders a big mess, doesn't it?
|
||||||
|
@ -2120,7 +2120,7 @@ namespace bgfx { namespace mtl
|
||||||
restartState = 2;
|
restartState = 2;
|
||||||
item = restartItem;
|
item = restartItem;
|
||||||
restartItem = numItems;
|
restartItem = numItems;
|
||||||
view = 0xff;
|
view = UINT16_MAX;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue