BeginRenderPass

submit_rewrite
cosmonaut 2020-12-20 00:05:12 -08:00
parent ffae2d8bfb
commit 2f06a8a13f
4 changed files with 67 additions and 21 deletions

View File

@ -344,12 +344,6 @@ typedef struct REFRESH_DepthStencilValue
uint32_t stencil;
} REFRESH_DepthStencilValue;
typedef struct REFRESH_ClearValue
{
REFRESH_Color color;
REFRESH_DepthStencilValue depthStencil;
} REFRESH_ClearValue;
typedef struct REFRESH_Rect
{
int32_t x;
@ -1206,18 +1200,20 @@ REFRESHAPI void REFRESH_AddDisposeGraphicsPipeline(
* All load, store and resolve operations are restricted
* to the given rectangle.
* clearValues:
* A pointer to an array of REFRESH_ClearValue structures
* that contains clear values for each render target in the
* framebuffer.
* clearCount: The amount of clearValue structs in the above array.
* A pointer to an array of REFRESH_Color structures
* that contains clear values for each color target in the
* framebuffer. May be NULL.
* clearCount: The amount of color structs in the above array.
* depthStencilClearValue: The depth/stencil clear value. May be NULL.
*/
REFRESHAPI void REFRESH_BeginRenderPass(
REFRESH_Device *device,
REFRESH_RenderPass *renderPass,
REFRESH_Framebuffer *framebuffer,
REFRESH_Rect renderArea,
REFRESH_ClearValue *pClearValues,
uint32_t clearCount
REFRESH_Color *pColorClearValues,
uint32_t colorClearCount,
REFRESH_DepthStencilValue *depthStencilClearValue
);
/* Ends the current render pass. */

View File

@ -746,8 +746,9 @@ void REFRESH_BeginRenderPass(
REFRESH_RenderPass *renderPass,
REFRESH_Framebuffer *framebuffer,
REFRESH_Rect renderArea,
REFRESH_ClearValue *pClearValues,
uint32_t clearCount
REFRESH_Color *pColorClearValues,
uint32_t colorClearCount,
REFRESH_DepthStencilValue *depthStencilClearValue
) {
NULL_RETURN(device);
device->BeginRenderPass(
@ -755,8 +756,9 @@ void REFRESH_BeginRenderPass(
renderPass,
framebuffer,
renderArea,
pClearValues,
clearCount
pColorClearValues,
colorClearCount,
depthStencilClearValue
);
}

View File

@ -463,8 +463,9 @@ struct REFRESH_Device
REFRESH_RenderPass *renderPass,
REFRESH_Framebuffer *framebuffer,
REFRESH_Rect renderArea,
REFRESH_ClearValue *pClearValues,
uint32_t clearCount
REFRESH_Color *pColorClearValues,
uint32_t colorClearCount,
REFRESH_DepthStencilValue *depthStencilClearValue
);
void(*EndRenderPass)(

View File

@ -3859,10 +3859,57 @@ static void VULKAN_BeginRenderPass(
REFRESH_RenderPass *renderPass,
REFRESH_Framebuffer *framebuffer,
REFRESH_Rect renderArea,
REFRESH_ClearValue *pClearValues,
uint32_t clearCount
REFRESH_Color *pColorClearValues,
uint32_t colorClearCount,
REFRESH_DepthStencilValue *depthStencilClearValue
) {
SDL_assert(0);
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
VkClearValue *clearValues;
uint32_t i;
uint32_t colorCount = colorClearCount;
if (depthStencilClearValue != NULL)
{
colorCount += 1;
}
clearValues = SDL_stack_alloc(VkClearValue, colorCount);
for (i = 0; i < colorClearCount; i += 1)
{
clearValues[i].color.uint32[0] = pColorClearValues[i].r;
clearValues[i].color.uint32[1] = pColorClearValues[i].g;
clearValues[i].color.uint32[2] = pColorClearValues[i].b;
clearValues[i].color.uint32[3] = pColorClearValues[i].a;
}
if (depthStencilClearValue != NULL)
{
clearValues[colorClearCount].depthStencil.depth =
depthStencilClearValue->depth;
clearValues[colorClearCount].depthStencil.stencil =
depthStencilClearValue->stencil;
}
VkRenderPassBeginInfo renderPassBeginInfo;
renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassBeginInfo.pNext = NULL;
renderPassBeginInfo.renderPass = (VkRenderPass) renderPass;
renderPassBeginInfo.framebuffer = (VkFramebuffer) framebuffer;
renderPassBeginInfo.renderArea.extent.width = renderArea.w;
renderPassBeginInfo.renderArea.extent.height = renderArea.h;
renderPassBeginInfo.renderArea.offset.x = renderArea.x;
renderPassBeginInfo.renderArea.offset.y = renderArea.y;
renderPassBeginInfo.pClearValues = clearValues;
renderPassBeginInfo.clearValueCount = colorCount;
RECORD_CMD(renderer->vkCmdBeginRenderPass(
renderer->currentCommandBuffer,
&renderPassBeginInfo,
VK_SUBPASS_CONTENTS_INLINE
));
SDL_stack_free(clearValues);
}
static void VULKAN_EndRenderPass(