mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-08 22:59:31 +02:00
Fix stencil tests on Vulkan
This commit is contained in:
parent
0ded506a80
commit
0af1daaa5a
2 changed files with 38 additions and 1 deletions
|
@ -220,6 +220,7 @@ struct Cache {
|
||||||
gpu::PipelineReference pipeline{ GPU_REFERENCE_INIT_VALUE };
|
gpu::PipelineReference pipeline{ GPU_REFERENCE_INIT_VALUE };
|
||||||
gpu::FormatReference format{ GPU_REFERENCE_INIT_VALUE };
|
gpu::FormatReference format{ GPU_REFERENCE_INIT_VALUE };
|
||||||
gpu::FramebufferReference framebuffer{ GPU_REFERENCE_INIT_VALUE };
|
gpu::FramebufferReference framebuffer{ GPU_REFERENCE_INIT_VALUE };
|
||||||
|
gpu::Primitive primitiveTopology;
|
||||||
|
|
||||||
struct PipelineLayout {
|
struct PipelineLayout {
|
||||||
VkPipelineLayout pipelineLayout;
|
VkPipelineLayout pipelineLayout;
|
||||||
|
@ -453,6 +454,7 @@ struct Cache {
|
||||||
key += "_" + getRenderpassKeyString(renderpassKey);
|
key += "_" + getRenderpassKeyString(renderpassKey);
|
||||||
key += "_" + state.getKey();
|
key += "_" + state.getKey();
|
||||||
key += "_" + format->getKey();
|
key += "_" + format->getKey();
|
||||||
|
key += "_" + hex(primitiveTopology);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
} pipelineState;
|
} pipelineState;
|
||||||
|
@ -504,6 +506,7 @@ struct Cache {
|
||||||
// Input assembly
|
// Input assembly
|
||||||
{
|
{
|
||||||
auto& ia = builder.inputAssemblyState;
|
auto& ia = builder.inputAssemblyState;
|
||||||
|
ia.topology = PRIMITIVE_TO_VK[pipelineState.primitiveTopology];
|
||||||
// VKTODO: this looks unfinished
|
// VKTODO: this looks unfinished
|
||||||
// ia.primitiveRestartEnable = ???
|
// ia.primitiveRestartEnable = ???
|
||||||
// ia.topology = vk::PrimitiveTopology::eTriangleList; ???
|
// ia.topology = vk::PrimitiveTopology::eTriangleList; ???
|
||||||
|
@ -570,8 +573,11 @@ struct Cache {
|
||||||
ds.depthTestEnable = stateData.depthTest.isEnabled() ? VK_TRUE : VK_FALSE; //VKTODO
|
ds.depthTestEnable = stateData.depthTest.isEnabled() ? VK_TRUE : VK_FALSE; //VKTODO
|
||||||
ds.depthWriteEnable = stateData.depthTest.getWriteMask() != 0 ? VK_TRUE : VK_FALSE;
|
ds.depthWriteEnable = stateData.depthTest.getWriteMask() != 0 ? VK_TRUE : VK_FALSE;
|
||||||
ds.depthCompareOp = (VkCompareOp)stateData.depthTest.getFunction();
|
ds.depthCompareOp = (VkCompareOp)stateData.depthTest.getFunction();
|
||||||
|
ds.stencilTestEnable = stateData.stencilActivation.enabled;
|
||||||
ds.front = getStencilOp(stateData.stencilTestFront);
|
ds.front = getStencilOp(stateData.stencilTestFront);
|
||||||
|
ds.front.writeMask = stateData.stencilActivation.frontWriteMask;
|
||||||
ds.back = getStencilOp(stateData.stencilTestBack);
|
ds.back = getStencilOp(stateData.stencilTestBack);
|
||||||
|
ds.back.writeMask = stateData.stencilActivation.backWriteMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Vertex input
|
// Vertex input
|
||||||
|
@ -671,7 +677,8 @@ void VKBackend::executeFrame(const FramePointer& frame) {
|
||||||
// resolve layout
|
// resolve layout
|
||||||
// resolve pipeline
|
// resolve pipeline
|
||||||
// resolve descriptor set(s)
|
// resolve descriptor set(s)
|
||||||
_cache.getPipeline(_context);
|
// VKTODO
|
||||||
|
//_cache.getPipeline(_context);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Batch::COMMAND_setPipeline: {
|
case Batch::COMMAND_setPipeline: {
|
||||||
|
@ -1415,6 +1422,7 @@ void VKBackend::renderPassDraw(const Batch& batch) {
|
||||||
case Batch::COMMAND_multiDrawIndexedIndirect: {
|
case Batch::COMMAND_multiDrawIndexedIndirect: {
|
||||||
// updates for draw calls
|
// updates for draw calls
|
||||||
++_currentDraw;
|
++_currentDraw;
|
||||||
|
_cache.pipelineState.primitiveTopology = getPrimitiveTopologyFromCommand(*command, batch, *offset);
|
||||||
updateInput();
|
updateInput();
|
||||||
updateTransform(batch);
|
updateTransform(batch);
|
||||||
updatePipeline();
|
updatePipeline();
|
||||||
|
@ -2065,6 +2073,33 @@ void VKBackend::downloadFramebuffer(const FramebufferPointer& srcFramebuffer, co
|
||||||
// VKTODO
|
// VKTODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gpu::Primitive VKBackend::getPrimitiveTopologyFromCommand(Batch::Command command, const gpu::Batch& batch, size_t paramOffset) {
|
||||||
|
Primitive primitiveType{};
|
||||||
|
switch (command) {
|
||||||
|
case Batch::COMMAND_draw:
|
||||||
|
primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
||||||
|
break;
|
||||||
|
case Batch::COMMAND_drawIndexed:
|
||||||
|
primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
||||||
|
break;
|
||||||
|
case Batch::COMMAND_drawInstanced:
|
||||||
|
primitiveType = (Primitive)batch._params[paramOffset + 3]._uint;
|
||||||
|
break;
|
||||||
|
case Batch::COMMAND_drawIndexedInstanced:
|
||||||
|
primitiveType = (Primitive)batch._params[paramOffset + 3]._uint;
|
||||||
|
break;
|
||||||
|
case Batch::COMMAND_multiDrawIndirect:
|
||||||
|
primitiveType = (Primitive)batch._params[paramOffset + 1]._uint;
|
||||||
|
break;
|
||||||
|
case Batch::COMMAND_multiDrawIndexedIndirect:
|
||||||
|
primitiveType = (Primitive)batch._params[paramOffset + 1]._uint;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_ASSERT(false);
|
||||||
|
}
|
||||||
|
return primitiveType;
|
||||||
|
}
|
||||||
|
|
||||||
void VKBackend::do_draw(const Batch& batch, size_t paramOffset) {
|
void VKBackend::do_draw(const Batch& batch, size_t paramOffset) {
|
||||||
auto primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
auto primitiveType = (Primitive)batch._params[paramOffset + 2]._uint;
|
||||||
VkPrimitiveTopology mode = PRIMITIVE_TO_VK[primitiveType];
|
VkPrimitiveTopology mode = PRIMITIVE_TO_VK[primitiveType];
|
||||||
|
|
|
@ -327,6 +327,8 @@ public:
|
||||||
|
|
||||||
void trash(VKBuffer& buffer);
|
void trash(VKBuffer& buffer);
|
||||||
|
|
||||||
|
static gpu::Primitive getPrimitiveTopologyFromCommand(Batch::Command command, const Batch& batch, size_t paramOffset);
|
||||||
|
|
||||||
// Draw Stage
|
// Draw Stage
|
||||||
virtual void do_draw(const Batch& batch, size_t paramOffset) final;
|
virtual void do_draw(const Batch& batch, size_t paramOffset) final;
|
||||||
virtual void do_drawIndexed(const Batch& batch, size_t paramOffset) final;
|
virtual void do_drawIndexed(const Batch& batch, size_t paramOffset) final;
|
||||||
|
|
Loading…
Reference in a new issue