Allow null fragment shader for depth only programs.
This commit is contained in:
parent
c5f7ad598b
commit
67ad9fbbef
@ -6420,8 +6420,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
deviceCtx->VSSetConstantBuffers(0, 1, &vsh->m_buffer);
|
||||
|
||||
const ShaderD3D11* fsh = program.m_fsh;
|
||||
if (NULL != m_currentColor
|
||||
|| fsh->m_hasDepthOp)
|
||||
if (NULL != fsh
|
||||
&& (NULL != m_currentColor || fsh->m_hasDepthOp) )
|
||||
{
|
||||
deviceCtx->PSSetShader(fsh->m_pixelShader, NULL, 0);
|
||||
deviceCtx->PSSetConstantBuffers(0, 1, &fsh->m_buffer);
|
||||
@ -6448,10 +6448,13 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
commit(*vcb);
|
||||
}
|
||||
|
||||
UniformBuffer* fcb = program.m_fsh->m_constantBuffer;
|
||||
if (NULL != fcb)
|
||||
if (NULL != program.m_fsh)
|
||||
{
|
||||
commit(*fcb);
|
||||
UniformBuffer* fcb = program.m_fsh->m_constantBuffer;
|
||||
if (NULL != fcb)
|
||||
{
|
||||
commit(*fcb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2826,7 +2826,11 @@ data.NumQualityLevels = 0;
|
||||
murmur.add(_stencil);
|
||||
murmur.add(program.m_vsh->m_hash);
|
||||
murmur.add(program.m_vsh->m_attrMask, sizeof(program.m_vsh->m_attrMask) );
|
||||
murmur.add(program.m_fsh->m_hash);
|
||||
if (NULL != program.m_fsh)
|
||||
{
|
||||
murmur.add(program.m_fsh->m_hash);
|
||||
}
|
||||
|
||||
for (uint32_t ii = 0; ii < _numStreams; ++ii)
|
||||
{
|
||||
murmur.add(_vertexDecls[ii]->m_hash);
|
||||
@ -2851,66 +2855,76 @@ data.NumQualityLevels = 0;
|
||||
desc.VS.pShaderBytecode = program.m_vsh->m_code->data;
|
||||
desc.VS.BytecodeLength = program.m_vsh->m_code->size;
|
||||
|
||||
const Memory* temp = alloc(program.m_fsh->m_code->size);
|
||||
bx::memSet(temp->data, 0, temp->size);
|
||||
bx::MemoryReader rd(program.m_fsh->m_code->data, program.m_fsh->m_code->size);
|
||||
bx::StaticMemoryBlockWriter wr(temp->data, temp->size);
|
||||
const Memory* temp = NULL;
|
||||
|
||||
DxbcContext dxbc;
|
||||
bx::Error err;
|
||||
read(&rd, dxbc, &err);
|
||||
|
||||
bool patchShader = !dxbc.shader.aon9;
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG)
|
||||
&& patchShader)
|
||||
if (NULL != program.m_fsh)
|
||||
{
|
||||
union { uint32_t offset; void* ptr; } cast = { 0 };
|
||||
filter(dxbc.shader, dxbc.shader, patchCb0, cast.ptr);
|
||||
temp = alloc(program.m_fsh->m_code->size);
|
||||
bx::memSet(temp->data, 0, temp->size);
|
||||
bx::MemoryReader rd(program.m_fsh->m_code->data, program.m_fsh->m_code->size);
|
||||
bx::StaticMemoryBlockWriter wr(temp->data, temp->size);
|
||||
|
||||
write(&wr, dxbc, &err);
|
||||
DxbcContext dxbc;
|
||||
bx::Error err;
|
||||
read(&rd, dxbc, &err);
|
||||
|
||||
dxbcHash(temp->data + 20, temp->size - 20, temp->data + 4);
|
||||
|
||||
patchShader = 0 == bx::memCmp(program.m_fsh->m_code->data, temp->data, 16);
|
||||
BX_CHECK(patchShader, "DXBC fragment shader patching error (ShaderHandle: %d).", program.m_fsh - m_shaders);
|
||||
|
||||
if (!patchShader)
|
||||
bool patchShader = !dxbc.shader.aon9;
|
||||
if (BX_ENABLED(BGFX_CONFIG_DEBUG)
|
||||
&& patchShader)
|
||||
{
|
||||
for (uint32_t ii = 20; ii < temp->size; ii += 16)
|
||||
{
|
||||
if (0 != bx::memCmp(&program.m_fsh->m_code->data[ii], &temp->data[ii], 16) )
|
||||
{
|
||||
// bx::debugPrintfData(&program.m_fsh->m_code->data[ii], temp->size-ii, "");
|
||||
// bx::debugPrintfData(&temp->data[ii], temp->size-ii, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
union { uint32_t offset; void* ptr; } cast = { 0 };
|
||||
filter(dxbc.shader, dxbc.shader, patchCb0, cast.ptr);
|
||||
|
||||
write(&wr, dxbc, &err);
|
||||
|
||||
dxbcHash(temp->data + 20, temp->size - 20, temp->data + 4);
|
||||
|
||||
patchShader = 0 == bx::memCmp(program.m_fsh->m_code->data, temp->data, 16);
|
||||
BX_CHECK(patchShader, "DXBC fragment shader patching error (ShaderHandle: %d).", program.m_fsh - m_shaders);
|
||||
|
||||
if (!patchShader)
|
||||
{
|
||||
for (uint32_t ii = 20; ii < temp->size; ii += 16)
|
||||
{
|
||||
if (0 != bx::memCmp(&program.m_fsh->m_code->data[ii], &temp->data[ii], 16) )
|
||||
{
|
||||
// bx::debugPrintfData(&program.m_fsh->m_code->data[ii], temp->size-ii, "");
|
||||
// bx::debugPrintfData(&temp->data[ii], temp->size-ii, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
desc.PS.pShaderBytecode = program.m_fsh->m_code->data;
|
||||
desc.PS.BytecodeLength = program.m_fsh->m_code->size;
|
||||
}
|
||||
}
|
||||
|
||||
if (patchShader)
|
||||
{
|
||||
bx::memCopy(temp->data, program.m_fsh->m_code->data, program.m_fsh->m_code->size);
|
||||
|
||||
bx::seek(&wr, 0, bx::Whence::Begin);
|
||||
union { uint32_t offset; void* ptr; } cast =
|
||||
{
|
||||
uint32_t(program.m_vsh->m_size)/16
|
||||
};
|
||||
filter(dxbc.shader, dxbc.shader, patchCb0, cast.ptr);
|
||||
write(&wr, dxbc, &err);
|
||||
dxbcHash(temp->data + 20, temp->size - 20, temp->data + 4);
|
||||
|
||||
desc.PS.pShaderBytecode = temp->data;
|
||||
desc.PS.BytecodeLength = temp->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
desc.PS.pShaderBytecode = program.m_fsh->m_code->data;
|
||||
desc.PS.BytecodeLength = program.m_fsh->m_code->size;
|
||||
}
|
||||
}
|
||||
|
||||
if (patchShader)
|
||||
{
|
||||
bx::memCopy(temp->data, program.m_fsh->m_code->data, program.m_fsh->m_code->size);
|
||||
|
||||
bx::seek(&wr, 0, bx::Whence::Begin);
|
||||
union { uint32_t offset; void* ptr; } cast =
|
||||
{
|
||||
uint32_t(program.m_vsh->m_size)/16
|
||||
};
|
||||
filter(dxbc.shader, dxbc.shader, patchCb0, cast.ptr);
|
||||
write(&wr, dxbc, &err);
|
||||
dxbcHash(temp->data + 20, temp->size - 20, temp->data + 4);
|
||||
|
||||
desc.PS.pShaderBytecode = temp->data;
|
||||
desc.PS.BytecodeLength = temp->size;
|
||||
}
|
||||
else
|
||||
{
|
||||
desc.PS.pShaderBytecode = program.m_fsh->m_code->data;
|
||||
desc.PS.BytecodeLength = program.m_fsh->m_code->size;
|
||||
desc.PS.pShaderBytecode = NULL;
|
||||
desc.PS.BytecodeLength = 0;
|
||||
}
|
||||
|
||||
desc.DS.pShaderBytecode = NULL;
|
||||
@ -3018,7 +3032,10 @@ data.NumQualityLevels = 0;
|
||||
|
||||
m_pipelineStateCache.add(hash, pso);
|
||||
|
||||
release(temp);
|
||||
if (NULL != temp)
|
||||
{
|
||||
release(temp);
|
||||
}
|
||||
|
||||
ID3DBlob* blob;
|
||||
HRESULT hr = pso->GetCachedBlob(&blob);
|
||||
@ -6285,10 +6302,13 @@ data.NumQualityLevels = 0;
|
||||
commit(*vcb);
|
||||
}
|
||||
|
||||
UniformBuffer* fcb = program.m_fsh->m_constantBuffer;
|
||||
if (NULL != fcb)
|
||||
if (NULL != program.m_fsh)
|
||||
{
|
||||
commit(*fcb);
|
||||
UniformBuffer* fcb = program.m_fsh->m_constantBuffer;
|
||||
if (NULL != fcb)
|
||||
{
|
||||
commit(*fcb);
|
||||
}
|
||||
}
|
||||
|
||||
hasPredefined = 0 < program.m_numPredefined;
|
||||
|
@ -1027,7 +1027,7 @@ namespace bgfx { namespace d3d9
|
||||
|
||||
void createProgram(ProgramHandle _handle, ShaderHandle _vsh, ShaderHandle _fsh) override
|
||||
{
|
||||
m_program[_handle.idx].create(m_shaders[_vsh.idx], m_shaders[_fsh.idx]);
|
||||
m_program[_handle.idx].create(&m_shaders[_vsh.idx], isValid(_fsh) ? &m_shaders[_fsh.idx] : NULL);
|
||||
}
|
||||
|
||||
void destroyProgram(ProgramHandle _handle) override
|
||||
@ -4105,7 +4105,10 @@ namespace bgfx { namespace d3d9
|
||||
{
|
||||
ProgramD3D9& program = m_program[programIdx];
|
||||
device->SetVertexShader(program.m_vsh->m_vertexShader);
|
||||
device->SetPixelShader(program.m_fsh->m_pixelShader);
|
||||
device->SetPixelShader(NULL == program.m_fsh
|
||||
? NULL
|
||||
: program.m_fsh->m_pixelShader
|
||||
);
|
||||
}
|
||||
|
||||
programChanged =
|
||||
@ -4124,10 +4127,13 @@ namespace bgfx { namespace d3d9
|
||||
commit(*vcb);
|
||||
}
|
||||
|
||||
UniformBuffer* fcb = program.m_fsh->m_constantBuffer;
|
||||
if (NULL != fcb)
|
||||
if (NULL != program.m_fsh)
|
||||
{
|
||||
commit(*fcb);
|
||||
UniformBuffer* fcb = program.m_fsh->m_constantBuffer;
|
||||
if (NULL != fcb)
|
||||
{
|
||||
commit(*fcb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -4406,11 +4412,11 @@ namespace bgfx { namespace d3d9
|
||||
);
|
||||
|
||||
const D3DADAPTER_IDENTIFIER9& identifier = m_identifier;
|
||||
tvm.printf(0, pos++, 0x8b, " Device: %s (%s)", identifier.Description, identifier.Driver);
|
||||
tvm.printf(0, pos++, 0x8f, " Device: %s (%s)", identifier.Description, identifier.Driver);
|
||||
|
||||
char processMemoryUsed[16];
|
||||
bx::prettify(processMemoryUsed, BX_COUNTOF(processMemoryUsed), bx::getProcessMemoryUsed() );
|
||||
tvm.printf(0, pos++, 0x8b, " Memory: %s (process) ", processMemoryUsed);
|
||||
tvm.printf(0, pos++, 0x8f, " Memory: %s (process) ", processMemoryUsed);
|
||||
|
||||
pos = 10;
|
||||
tvm.printf(10, pos++, 0x8b, " Frame: %7.3f, % 7.3f \x1f, % 7.3f \x1e [ms] / % 6.2f FPS "
|
||||
|
@ -259,17 +259,19 @@ namespace bgfx { namespace d3d9
|
||||
|
||||
struct ProgramD3D9
|
||||
{
|
||||
void create(const ShaderD3D9& _vsh, const ShaderD3D9& _fsh)
|
||||
void create(const ShaderD3D9* _vsh, const ShaderD3D9* _fsh)
|
||||
{
|
||||
BX_CHECK(NULL != _vsh.m_vertexShader, "Vertex shader doesn't exist.");
|
||||
m_vsh = &_vsh;
|
||||
m_vsh = _vsh;
|
||||
m_fsh = _fsh;
|
||||
|
||||
BX_CHECK(NULL != _fsh.m_pixelShader, "Fragment shader doesn't exist.");
|
||||
m_fsh = &_fsh;
|
||||
bx::memCopy(&m_predefined[0], _vsh->m_predefined, _vsh->m_numPredefined*sizeof(PredefinedUniform) );
|
||||
m_numPredefined = _vsh->m_numPredefined;
|
||||
|
||||
bx::memCopy(&m_predefined[0], _vsh.m_predefined, _vsh.m_numPredefined*sizeof(PredefinedUniform) );
|
||||
bx::memCopy(&m_predefined[_vsh.m_numPredefined], _fsh.m_predefined, _fsh.m_numPredefined*sizeof(PredefinedUniform) );
|
||||
m_numPredefined = _vsh.m_numPredefined + _fsh.m_numPredefined;
|
||||
if (NULL != _fsh)
|
||||
{
|
||||
bx::memCopy(&m_predefined[_vsh->m_numPredefined], _fsh->m_predefined, _fsh->m_numPredefined*sizeof(PredefinedUniform) );
|
||||
m_numPredefined += _fsh->m_numPredefined;
|
||||
}
|
||||
}
|
||||
|
||||
void destroy()
|
||||
|
Loading…
Reference in New Issue
Block a user