Vulkan: Correct missing offsets in Draw.

Was silently ignoring them.  Caused stretch in postshaders.
This commit is contained in:
Unknown W. Brackets 2020-05-10 20:34:42 -07:00
parent d4f4e87e66
commit e309712fed
5 changed files with 9 additions and 7 deletions

View File

@ -1091,7 +1091,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c
if (c.draw.vbuffer) {
vkCmdBindVertexBuffers(cmd, 0, 1, &c.draw.vbuffer, &c.draw.voffset);
}
vkCmdDraw(cmd, c.draw.count, 1, 0, 0);
vkCmdDraw(cmd, c.draw.count, 1, c.draw.offset, 0);
break;
case VKRRenderCommand::CLEAR:

View File

@ -109,6 +109,7 @@ struct VkRenderData {
VkBuffer vbuffer;
VkDeviceSize voffset;
uint32_t count;
uint32_t offset;
} draw;
struct {
VkPipelineLayout pipelineLayout;

View File

@ -177,10 +177,11 @@ public:
void Clear(uint32_t clearColor, float clearZ, int clearStencil, int clearMask);
void Draw(VkPipelineLayout layout, VkDescriptorSet descSet, int numUboOffsets, const uint32_t *uboOffsets, VkBuffer vbuffer, int voffset, int count) {
void Draw(VkPipelineLayout layout, VkDescriptorSet descSet, int numUboOffsets, const uint32_t *uboOffsets, VkBuffer vbuffer, int voffset, int count, int offset = 0) {
_dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER);
VkRenderData data{ VKRRenderCommand::DRAW };
data.draw.count = count;
data.draw.offset = offset;
data.draw.pipelineLayout = layout;
data.draw.ds = descSet;
data.draw.vbuffer = vbuffer;

View File

@ -140,7 +140,7 @@ static const std::vector<ShaderSource> fsTexCol = {
"#extension GL_ARB_shading_language_420pack : enable\n"
"layout(location = 0) in vec4 oColor0;\n"
"layout(location = 1) in vec2 oTexCoord0;\n"
"layout(location = 0) out vec4 fragColor0\n;"
"layout(location = 0) out vec4 fragColor0;\n"
"layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n"
"void main() { fragColor0 = texture(Sampler0, oTexCoord0) * oColor0; }\n"
}
@ -220,7 +220,7 @@ static const std::vector<ShaderSource> fsCol = {
"#extension GL_ARB_separate_shader_objects : enable\n"
"#extension GL_ARB_shading_language_420pack : enable\n"
"layout(location = 0) in vec4 oColor0;\n"
"layout(location = 0) out vec4 fragColor0\n;"
"layout(location = 0) out vec4 fragColor0;\n"
"void main() { fragColor0 = oColor0; }\n"
}
};

View File

@ -1242,7 +1242,7 @@ void VKContext::Draw(int vertexCount, int offset) {
renderManager_.BindPipeline(curPipeline_->vkpipeline);
ApplyDynamicState();
renderManager_.Draw(pipelineLayout_, descSet, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset, vertexCount);
renderManager_.Draw(pipelineLayout_, descSet, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset + curVBufferOffsets_[0], vertexCount, offset);
}
void VKContext::DrawIndexed(int vertexCount, int offset) {
@ -1258,7 +1258,7 @@ void VKContext::DrawIndexed(int vertexCount, int offset) {
renderManager_.BindPipeline(curPipeline_->vkpipeline);
ApplyDynamicState();
renderManager_.DrawIndexed(pipelineLayout_, descSet, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset, vulkanIbuf, (int)ibBindOffset + offset * sizeof(uint32_t), vertexCount, 1, VK_INDEX_TYPE_UINT32);
renderManager_.DrawIndexed(pipelineLayout_, descSet, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset + curVBufferOffsets_[0], vulkanIbuf, (int)ibBindOffset + offset * sizeof(uint32_t), vertexCount, 1, VK_INDEX_TYPE_UINT32);
}
void VKContext::DrawUP(const void *vdata, int vertexCount) {
@ -1270,7 +1270,7 @@ void VKContext::DrawUP(const void *vdata, int vertexCount) {
renderManager_.BindPipeline(curPipeline_->vkpipeline);
ApplyDynamicState();
renderManager_.Draw(pipelineLayout_, descSet, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset, vertexCount);
renderManager_.Draw(pipelineLayout_, descSet, 1, &ubo_offset, vulkanVbuf, (int)vbBindOffset + curVBufferOffsets_[0], vertexCount);
}
void VKContext::Clear(int clearMask, uint32_t colorval, float depthVal, int stencilVal) {