update PushUniforms and Draw functions
parent
55ce210be6
commit
695ad15b75
|
@ -1539,6 +1539,10 @@ typedef struct VulkanCommandBuffer
|
||||||
VulkanComputePipeline *currentComputePipeline;
|
VulkanComputePipeline *currentComputePipeline;
|
||||||
VulkanGraphicsPipeline *currentGraphicsPipeline;
|
VulkanGraphicsPipeline *currentGraphicsPipeline;
|
||||||
|
|
||||||
|
uint32_t vertexUniformOffset;
|
||||||
|
uint32_t fragmentUniformOffset;
|
||||||
|
uint32_t computeUniformOffset;
|
||||||
|
|
||||||
VulkanTexture *renderPassColorTargetTextures[MAX_COLOR_TARGET_BINDINGS];
|
VulkanTexture *renderPassColorTargetTextures[MAX_COLOR_TARGET_BINDINGS];
|
||||||
uint32_t renderPassColorTargetCount;
|
uint32_t renderPassColorTargetCount;
|
||||||
VulkanTexture *renderPassDepthTexture; /* can be NULL */
|
VulkanTexture *renderPassDepthTexture; /* can be NULL */
|
||||||
|
@ -5203,9 +5207,7 @@ static void VULKAN_DrawInstancedPrimitives(
|
||||||
uint32_t baseVertex,
|
uint32_t baseVertex,
|
||||||
uint32_t startIndex,
|
uint32_t startIndex,
|
||||||
uint32_t primitiveCount,
|
uint32_t primitiveCount,
|
||||||
uint32_t instanceCount,
|
uint32_t instanceCount
|
||||||
uint32_t vertexParamOffset,
|
|
||||||
uint32_t fragmentParamOffset
|
|
||||||
) {
|
) {
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
|
@ -5218,8 +5220,8 @@ static void VULKAN_DrawInstancedPrimitives(
|
||||||
descriptorSets[2] = renderer->vertexUniformBufferObject->descriptorSet;
|
descriptorSets[2] = renderer->vertexUniformBufferObject->descriptorSet;
|
||||||
descriptorSets[3] = renderer->fragmentUniformBufferObject->descriptorSet;
|
descriptorSets[3] = renderer->fragmentUniformBufferObject->descriptorSet;
|
||||||
|
|
||||||
dynamicOffsets[0] = vertexParamOffset;
|
dynamicOffsets[0] = vulkanCommandBuffer->vertexUniformOffset;
|
||||||
dynamicOffsets[1] = fragmentParamOffset;
|
dynamicOffsets[1] = vulkanCommandBuffer->fragmentUniformOffset;
|
||||||
|
|
||||||
renderer->vkCmdBindDescriptorSets(
|
renderer->vkCmdBindDescriptorSets(
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
|
@ -5250,9 +5252,7 @@ static void VULKAN_DrawIndexedPrimitives(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
uint32_t baseVertex,
|
uint32_t baseVertex,
|
||||||
uint32_t startIndex,
|
uint32_t startIndex,
|
||||||
uint32_t primitiveCount,
|
uint32_t primitiveCount
|
||||||
uint32_t vertexParamOffset,
|
|
||||||
uint32_t fragmentParamOffset
|
|
||||||
) {
|
) {
|
||||||
VULKAN_DrawInstancedPrimitives(
|
VULKAN_DrawInstancedPrimitives(
|
||||||
driverData,
|
driverData,
|
||||||
|
@ -5260,9 +5260,7 @@ static void VULKAN_DrawIndexedPrimitives(
|
||||||
baseVertex,
|
baseVertex,
|
||||||
startIndex,
|
startIndex,
|
||||||
primitiveCount,
|
primitiveCount,
|
||||||
1,
|
1
|
||||||
vertexParamOffset,
|
|
||||||
fragmentParamOffset
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5270,9 +5268,7 @@ static void VULKAN_DrawPrimitives(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
uint32_t vertexStart,
|
uint32_t vertexStart,
|
||||||
uint32_t primitiveCount,
|
uint32_t primitiveCount
|
||||||
uint32_t vertexParamOffset,
|
|
||||||
uint32_t fragmentParamOffset
|
|
||||||
) {
|
) {
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
|
@ -5285,8 +5281,8 @@ static void VULKAN_DrawPrimitives(
|
||||||
descriptorSets[2] = renderer->vertexUniformBufferObject->descriptorSet;
|
descriptorSets[2] = renderer->vertexUniformBufferObject->descriptorSet;
|
||||||
descriptorSets[3] = renderer->fragmentUniformBufferObject->descriptorSet;
|
descriptorSets[3] = renderer->fragmentUniformBufferObject->descriptorSet;
|
||||||
|
|
||||||
dynamicOffsets[0] = vertexParamOffset;
|
dynamicOffsets[0] = vulkanCommandBuffer->vertexUniformOffset;
|
||||||
dynamicOffsets[1] = fragmentParamOffset;
|
dynamicOffsets[1] = vulkanCommandBuffer->fragmentUniformOffset;
|
||||||
|
|
||||||
renderer->vkCmdBindDescriptorSets(
|
renderer->vkCmdBindDescriptorSets(
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
|
@ -5317,9 +5313,7 @@ static void VULKAN_DrawPrimitivesIndirect(
|
||||||
Refresh_GpuBuffer *buffer,
|
Refresh_GpuBuffer *buffer,
|
||||||
uint32_t offsetInBytes,
|
uint32_t offsetInBytes,
|
||||||
uint32_t drawCount,
|
uint32_t drawCount,
|
||||||
uint32_t stride,
|
uint32_t stride
|
||||||
uint32_t vertexParamOffset,
|
|
||||||
uint32_t fragmentParamOffset
|
|
||||||
) {
|
) {
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
|
@ -5332,8 +5326,8 @@ static void VULKAN_DrawPrimitivesIndirect(
|
||||||
descriptorSets[2] = renderer->vertexUniformBufferObject->descriptorSet;
|
descriptorSets[2] = renderer->vertexUniformBufferObject->descriptorSet;
|
||||||
descriptorSets[3] = renderer->fragmentUniformBufferObject->descriptorSet;
|
descriptorSets[3] = renderer->fragmentUniformBufferObject->descriptorSet;
|
||||||
|
|
||||||
dynamicOffsets[0] = vertexParamOffset;
|
dynamicOffsets[0] = vulkanCommandBuffer->vertexUniformOffset;
|
||||||
dynamicOffsets[1] = fragmentParamOffset;
|
dynamicOffsets[1] = vulkanCommandBuffer->fragmentUniformOffset;
|
||||||
|
|
||||||
renderer->vkCmdBindDescriptorSets(
|
renderer->vkCmdBindDescriptorSets(
|
||||||
vulkanCommandBuffer->commandBuffer,
|
vulkanCommandBuffer->commandBuffer,
|
||||||
|
@ -6828,7 +6822,7 @@ static void VULKAN_INTERNAL_SetUniformBufferData(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t VULKAN_PushVertexShaderUniforms(
|
static void VULKAN_PushVertexShaderUniforms(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
void *data,
|
void *data,
|
||||||
|
@ -6837,22 +6831,15 @@ static uint32_t VULKAN_PushVertexShaderUniforms(
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer* vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer* vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanGraphicsPipeline* graphicsPipeline = vulkanCommandBuffer->currentGraphicsPipeline;
|
VulkanGraphicsPipeline* graphicsPipeline = vulkanCommandBuffer->currentGraphicsPipeline;
|
||||||
uint32_t offset;
|
|
||||||
|
|
||||||
if (graphicsPipeline->vertexUniformBlockSize == 0)
|
|
||||||
{
|
|
||||||
Refresh_LogError("Bound pipeline's vertex stage does not declare uniforms!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_LockMutex(renderer->vertexUniformBufferObject->lock);
|
SDL_LockMutex(renderer->vertexUniformBufferObject->lock);
|
||||||
|
|
||||||
if (renderer->vertexUniformBufferObject->currentOffset + dataLengthInBytes + UBO_SECTION_SIZE >= UBO_BUFFER_SIZE)
|
if (renderer->vertexUniformBufferObject->currentOffset + graphicsPipeline->vertexUniformBlockSize + UBO_SECTION_SIZE >= UBO_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
renderer->vertexUniformBufferObject->currentOffset = 0;
|
renderer->vertexUniformBufferObject->currentOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = renderer->vertexUniformBufferObject->currentOffset;
|
vulkanCommandBuffer->vertexUniformOffset = renderer->vertexUniformBufferObject->currentOffset;
|
||||||
|
|
||||||
VULKAN_INTERNAL_SetUniformBufferData(
|
VULKAN_INTERNAL_SetUniformBufferData(
|
||||||
renderer->vertexUniformBufferObject,
|
renderer->vertexUniformBufferObject,
|
||||||
|
@ -6863,11 +6850,9 @@ static uint32_t VULKAN_PushVertexShaderUniforms(
|
||||||
renderer->vertexUniformBufferObject->currentOffset += graphicsPipeline->vertexUniformBlockSize;
|
renderer->vertexUniformBufferObject->currentOffset += graphicsPipeline->vertexUniformBlockSize;
|
||||||
|
|
||||||
SDL_UnlockMutex(renderer->vertexUniformBufferObject->lock);
|
SDL_UnlockMutex(renderer->vertexUniformBufferObject->lock);
|
||||||
|
|
||||||
return offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t VULKAN_PushFragmentShaderUniforms(
|
static void VULKAN_PushFragmentShaderUniforms(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
void *data,
|
void *data,
|
||||||
|
@ -6876,22 +6861,15 @@ static uint32_t VULKAN_PushFragmentShaderUniforms(
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer* vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer* vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanGraphicsPipeline* graphicsPipeline = vulkanCommandBuffer->currentGraphicsPipeline;
|
VulkanGraphicsPipeline* graphicsPipeline = vulkanCommandBuffer->currentGraphicsPipeline;
|
||||||
uint32_t offset;
|
|
||||||
|
|
||||||
if (graphicsPipeline->fragmentUniformBlockSize == 0)
|
|
||||||
{
|
|
||||||
Refresh_LogError("Bound pipeline's fragment stage does not declare uniforms!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_LockMutex(renderer->fragmentUniformBufferObject->lock);
|
SDL_LockMutex(renderer->fragmentUniformBufferObject->lock);
|
||||||
|
|
||||||
if (renderer->fragmentUniformBufferObject->currentOffset + dataLengthInBytes + UBO_SECTION_SIZE >= UBO_BUFFER_SIZE)
|
if (renderer->fragmentUniformBufferObject->currentOffset + graphicsPipeline->fragmentUniformBlockSize + UBO_SECTION_SIZE >= UBO_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
renderer->fragmentUniformBufferObject->currentOffset = 0;
|
renderer->fragmentUniformBufferObject->currentOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = renderer->fragmentUniformBufferObject->currentOffset;
|
vulkanCommandBuffer->fragmentUniformOffset = renderer->fragmentUniformBufferObject->currentOffset;
|
||||||
|
|
||||||
VULKAN_INTERNAL_SetUniformBufferData(
|
VULKAN_INTERNAL_SetUniformBufferData(
|
||||||
renderer->fragmentUniformBufferObject,
|
renderer->fragmentUniformBufferObject,
|
||||||
|
@ -6902,11 +6880,9 @@ static uint32_t VULKAN_PushFragmentShaderUniforms(
|
||||||
renderer->fragmentUniformBufferObject->currentOffset += graphicsPipeline->fragmentUniformBlockSize;
|
renderer->fragmentUniformBufferObject->currentOffset += graphicsPipeline->fragmentUniformBlockSize;
|
||||||
|
|
||||||
SDL_UnlockMutex(renderer->fragmentUniformBufferObject->lock);
|
SDL_UnlockMutex(renderer->fragmentUniformBufferObject->lock);
|
||||||
|
|
||||||
return offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t VULKAN_PushComputeShaderUniforms(
|
static void VULKAN_PushComputeShaderUniforms(
|
||||||
Refresh_Renderer *driverData,
|
Refresh_Renderer *driverData,
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
void *data,
|
void *data,
|
||||||
|
@ -6915,22 +6891,15 @@ static uint32_t VULKAN_PushComputeShaderUniforms(
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer* vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer* vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
VulkanComputePipeline* computePipeline = vulkanCommandBuffer->currentComputePipeline;
|
VulkanComputePipeline* computePipeline = vulkanCommandBuffer->currentComputePipeline;
|
||||||
uint32_t offset;
|
|
||||||
|
|
||||||
if (computePipeline->uniformBlockSize == 0)
|
|
||||||
{
|
|
||||||
Refresh_LogError("Bound pipeline's compute stage does not declare uniforms!");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDL_LockMutex(renderer->computeUniformBufferObject->lock);
|
SDL_LockMutex(renderer->computeUniformBufferObject->lock);
|
||||||
|
|
||||||
if (renderer->computeUniformBufferObject->currentOffset + dataLengthInBytes + UBO_SECTION_SIZE >= UBO_BUFFER_SIZE)
|
if (renderer->computeUniformBufferObject->currentOffset + computePipeline->uniformBlockSize + UBO_SECTION_SIZE >= UBO_BUFFER_SIZE)
|
||||||
{
|
{
|
||||||
renderer->computeUniformBufferObject->currentOffset = 0;
|
renderer->computeUniformBufferObject->currentOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = renderer->computeUniformBufferObject->currentOffset;
|
vulkanCommandBuffer->computeUniformOffset = renderer->computeUniformBufferObject->currentOffset;
|
||||||
|
|
||||||
VULKAN_INTERNAL_SetUniformBufferData(
|
VULKAN_INTERNAL_SetUniformBufferData(
|
||||||
renderer->computeUniformBufferObject,
|
renderer->computeUniformBufferObject,
|
||||||
|
@ -6941,8 +6910,6 @@ static uint32_t VULKAN_PushComputeShaderUniforms(
|
||||||
renderer->computeUniformBufferObject->currentOffset += computePipeline->uniformBlockSize;
|
renderer->computeUniformBufferObject->currentOffset += computePipeline->uniformBlockSize;
|
||||||
|
|
||||||
SDL_UnlockMutex(renderer->computeUniformBufferObject->lock);
|
SDL_UnlockMutex(renderer->computeUniformBufferObject->lock);
|
||||||
|
|
||||||
return offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If fetching an image descriptor, descriptorImageInfos must not be NULL.
|
/* If fetching an image descriptor, descriptorImageInfos must not be NULL.
|
||||||
|
@ -8239,8 +8206,7 @@ static void VULKAN_DispatchCompute(
|
||||||
Refresh_CommandBuffer *commandBuffer,
|
Refresh_CommandBuffer *commandBuffer,
|
||||||
uint32_t groupCountX,
|
uint32_t groupCountX,
|
||||||
uint32_t groupCountY,
|
uint32_t groupCountY,
|
||||||
uint32_t groupCountZ,
|
uint32_t groupCountZ
|
||||||
uint32_t computeParamOffset
|
|
||||||
) {
|
) {
|
||||||
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
VulkanRenderer* renderer = (VulkanRenderer*) driverData;
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer;
|
||||||
|
@ -8259,7 +8225,7 @@ static void VULKAN_DispatchCompute(
|
||||||
3,
|
3,
|
||||||
descriptorSets,
|
descriptorSets,
|
||||||
1,
|
1,
|
||||||
&computeParamOffset
|
&vulkanCommandBuffer->computeUniformOffset
|
||||||
);
|
);
|
||||||
|
|
||||||
renderer->vkCmdDispatch(
|
renderer->vkCmdDispatch(
|
||||||
|
@ -9280,6 +9246,10 @@ static Refresh_CommandBuffer* VULKAN_AcquireCommandBuffer(
|
||||||
commandBuffer->currentComputePipeline = NULL;
|
commandBuffer->currentComputePipeline = NULL;
|
||||||
commandBuffer->currentGraphicsPipeline = NULL;
|
commandBuffer->currentGraphicsPipeline = NULL;
|
||||||
|
|
||||||
|
commandBuffer->vertexUniformOffset = 0;
|
||||||
|
commandBuffer->fragmentUniformOffset = 0;
|
||||||
|
commandBuffer->computeUniformOffset = 0;
|
||||||
|
|
||||||
commandBuffer->renderPassColorTargetCount = 0;
|
commandBuffer->renderPassColorTargetCount = 0;
|
||||||
commandBuffer->autoReleaseFence = 1;
|
commandBuffer->autoReleaseFence = 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue