mirror of
https://github.com/Yours3lf/rpi-vk-driver.git
synced 2025-01-30 22:52:14 +01:00
MSAA is now working, but need to make it robust
This commit is contained in:
parent
20dae3b400
commit
7fabec0b32
@ -39,7 +39,7 @@ void clInit(ControlList* cl, void* buffer)
|
||||
cl->currMarker = 0;
|
||||
}
|
||||
|
||||
void clInsertNewCLMarker(ControlList* cl, ControlList* handlesCL, ControlList* shaderRecCL, uint32_t shaderRecCount, ControlList* uniformsCL, void* imagePtr, void* depthStencilImagePtr)
|
||||
void clInsertNewCLMarker(ControlList* cl, ControlList* handlesCL, ControlList* shaderRecCL, uint32_t shaderRecCount, ControlList* uniformsCL, void* imagePtr, void* MSAAimagePtr, void* depthStencilImagePtr)
|
||||
{
|
||||
//to be inserted when you'd insert tile binning mode config
|
||||
assert(cl);
|
||||
@ -52,6 +52,7 @@ void clInsertNewCLMarker(ControlList* cl, ControlList* handlesCL, ControlList* s
|
||||
marker.nextMarker = 0;
|
||||
marker.size = 0;
|
||||
marker.image = imagePtr;
|
||||
marker.MSAAimage = MSAAimagePtr;
|
||||
marker.depthStencilImage = depthStencilImagePtr;
|
||||
marker.handlesSize = 0;
|
||||
marker.shaderRecSize = 0;
|
||||
|
@ -18,6 +18,7 @@ typedef struct CLMarker
|
||||
struct CLMarker* nextMarker;
|
||||
uint32_t size; //in bytes
|
||||
void* image; //_image* to render to
|
||||
void* MSAAimage; //_image* to render to
|
||||
void* depthStencilImage; //_image* to render depth/stencil to
|
||||
uint32_t flags; //used to store clear flag etc.
|
||||
|
||||
@ -58,7 +59,7 @@ uint32_t divRoundUp(uint32_t n, uint32_t d);
|
||||
uint32_t moveBits(uint32_t d, uint32_t bits, uint32_t offset);
|
||||
uint32_t clHasEnoughSpace(ControlList* cl, uint32_t size);
|
||||
void clInit(ControlList* cl, void* buffer);
|
||||
void clInsertNewCLMarker(ControlList* cl, ControlList* handlesCL, ControlList* shaderRecCL, uint32_t shaderRecCount, ControlList* uniformsCL, void* imagePtr, void* depthStencilImagePtr);
|
||||
void clInsertNewCLMarker(ControlList* cl, ControlList* handlesCL, ControlList* shaderRecCL, uint32_t shaderRecCount, ControlList* uniformsCL, void* imagePtr, void* MSAAimagePtr, void* depthStencilImagePtr);
|
||||
void clCloseCurrentMarker(ControlList* cl, ControlList* handlesCL, ControlList* shaderRecCL, uint32_t shaderRecCount, ControlList* uniformsCL);
|
||||
void clInsertData(ControlList* cl, uint32_t size, uint8_t* data);
|
||||
void clInsertUniformConstant(ControlList* cl, uint32_t data);
|
||||
|
@ -313,10 +313,12 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
|
||||
};
|
||||
|
||||
_image* i = marker->image;
|
||||
_image* MSAAimage = marker->MSAAimage;
|
||||
_image* dsI = marker->depthStencilImage;
|
||||
|
||||
//This should not result in an insertion!
|
||||
uint32_t imageIdx = clGetHandleIndex(&cmdbuf->handlesCl, marker->handlesBuf, marker->handlesSize, i->boundMem->bo);
|
||||
//uint32_t MSAAimageIdx = MSAAimage ? clGetHandleIndex(&cmdbuf->handlesCl, marker->handlesBuf, marker->handlesSize, MSAAimage->boundMem->bo) : 0;
|
||||
uint32_t depthStencilImageIdx = dsI ? clGetHandleIndex(&cmdbuf->handlesCl, marker->handlesBuf, marker->handlesSize, dsI->boundMem->bo) : 0;
|
||||
|
||||
//TODO msaa, read fields
|
||||
@ -351,7 +353,8 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
|
||||
submitCl.clear_s = 0;
|
||||
}
|
||||
|
||||
if(i->samples > 1)
|
||||
//TODO handle this properly
|
||||
if(MSAAimage)
|
||||
{
|
||||
// This bit controls how many pixels the general
|
||||
// (i.e. subsampled) loads/stores are iterating over
|
||||
@ -368,7 +371,7 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
|
||||
uint32_t tileSizeW = 64;
|
||||
uint32_t tileSizeH = 64;
|
||||
|
||||
if(i->samples > 1)
|
||||
if(MSAAimage)
|
||||
{
|
||||
tileSizeW >>= 1;
|
||||
tileSizeH >>= 1;
|
||||
|
@ -42,14 +42,33 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB
|
||||
cb->currentSubpass = 0;
|
||||
|
||||
_image* i = 0;
|
||||
_image* MSAAimage = 0;
|
||||
_image* dsI = 0;
|
||||
|
||||
_renderpass* rp = pRenderPassBegin->renderPass;
|
||||
|
||||
for(uint32_t c = 0; c < rp->subpasses[cb->currentSubpass].colorAttachmentCount; ++c)
|
||||
//TODO handle MSAA properly
|
||||
if(!rp->subpasses[cb->currentSubpass].pResolveAttachments)
|
||||
{
|
||||
i = cb->fbo->attachmentViews[rp->subpasses[cb->currentSubpass].pColorAttachments[c].attachment].image;
|
||||
break; //TODO handle multiple attachments
|
||||
for(uint32_t c = 0; c < rp->subpasses[cb->currentSubpass].colorAttachmentCount; ++c)
|
||||
{
|
||||
i = cb->fbo->attachmentViews[rp->subpasses[cb->currentSubpass].pColorAttachments[c].attachment].image;
|
||||
break; //TODO handle multiple attachments
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(uint32_t c = 0; c < rp->subpasses[cb->currentSubpass].colorAttachmentCount; ++c)
|
||||
{
|
||||
i = cb->fbo->attachmentViews[rp->subpasses[cb->currentSubpass].pResolveAttachments[c].attachment].image;
|
||||
break; //TODO handle multiple attachments
|
||||
}
|
||||
|
||||
for(uint32_t c = 0; c < rp->subpasses[cb->currentSubpass].colorAttachmentCount; ++c)
|
||||
{
|
||||
MSAAimage = cb->fbo->attachmentViews[rp->subpasses[cb->currentSubpass].pColorAttachments[c].attachment].image;
|
||||
break; //TODO handle multiple attachments
|
||||
}
|
||||
}
|
||||
|
||||
if(rp->subpasses[cb->currentSubpass].pDepthStencilAttachment)
|
||||
@ -58,7 +77,7 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB
|
||||
}
|
||||
|
||||
clFit(commandBuffer, &commandBuffer->binCl, sizeof(CLMarker));
|
||||
clInsertNewCLMarker(&commandBuffer->binCl, &cb->handlesCl, &cb->shaderRecCl, cb->shaderRecCount, &cb->uniformsCl, i, dsI);
|
||||
clInsertNewCLMarker(&commandBuffer->binCl, &cb->handlesCl, &cb->shaderRecCl, cb->shaderRecCount, &cb->uniformsCl, i, MSAAimage, dsI);
|
||||
|
||||
//insert reloc for render target
|
||||
clFit(commandBuffer, &commandBuffer->handlesCl, 4);
|
||||
@ -74,7 +93,7 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB
|
||||
//TODO handle multiple attachments
|
||||
for(uint32_t c = 0; c < cb->renderpass->numAttachments; ++c)
|
||||
{
|
||||
if(cb->renderpass->attachments[c].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
if(cb->renderpass->attachments[c].loadOp == VK_ATTACHMENT_LOAD_OP_CLEAR)
|
||||
{
|
||||
//TODO separate clear for color / depth / stencil?
|
||||
cb->binCl.currMarker->flags |= VC4_SUBMIT_CL_USE_CLEAR_COLOR;
|
||||
@ -88,7 +107,7 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB
|
||||
0, //tile allocation initial block size
|
||||
0, //auto initialize tile state data array
|
||||
getFormatBpp(i->format) == 64, //64 bit color mode
|
||||
i->samples > 1, //msaa
|
||||
MSAAimage ? 1 : 0, //TODO msaa
|
||||
i->width, i->height,
|
||||
0, //tile state data array address
|
||||
0, //tile allocation memory size
|
||||
@ -309,7 +328,7 @@ VkResult rpi_vkCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo*
|
||||
return VK_ERROR_OUT_OF_HOST_MEMORY;
|
||||
}
|
||||
|
||||
for(int c = 0; c < fb->numAttachmentViews; ++c)
|
||||
for(uint32_t c = 0; c < fb->numAttachmentViews; ++c)
|
||||
{
|
||||
memcpy(&fb->attachmentViews[c], pCreateInfo->pAttachments[c], sizeof(_imageView));
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdClearColorImage(
|
||||
|
||||
{ //Simplest case: just submit a job to clear the image
|
||||
clFit(commandBuffer, &commandBuffer->binCl, sizeof(CLMarker));
|
||||
clInsertNewCLMarker(&commandBuffer->binCl, &commandBuffer->handlesCl, &commandBuffer->shaderRecCl, commandBuffer->shaderRecCount, &commandBuffer->uniformsCl, i, 0);
|
||||
clInsertNewCLMarker(&commandBuffer->binCl, &commandBuffer->handlesCl, &commandBuffer->shaderRecCl, commandBuffer->shaderRecCount, &commandBuffer->uniformsCl, i, 0, 0);
|
||||
|
||||
//insert reloc for render target
|
||||
clFit(commandBuffer, &commandBuffer->handlesCl, 4);
|
||||
|
@ -765,7 +765,7 @@ void CreateRenderPass()
|
||||
// This is the frame buffer attachment to where the multisampled image
|
||||
// will be resolved to and which will be presented to the swapchain
|
||||
attachDesc[1].format = swapchainFormat.format;
|
||||
attachDesc[1].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachDesc[1].loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
|
||||
attachDesc[1].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
attachDesc[1].stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
attachDesc[1].stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
|
||||
|
Loading…
x
Reference in New Issue
Block a user