From e7294b896eb64c7674bb621fee6d8a60aea7fbea Mon Sep 17 00:00:00 2001 From: Unknown <0.tamas.marton@gmail.com> Date: Fri, 31 Jan 2020 18:42:37 +0000 Subject: [PATCH] depth texture reading and buffer copying works now --- driver/common.c | 12 ++++++++++++ driver/renderpass.c | 20 ++++++++++---------- test/blending/blending.cpp | 2 +- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/driver/common.c b/driver/common.c index 041495a..eb84cac 100644 --- a/driver/common.c +++ b/driver/common.c @@ -839,6 +839,9 @@ uint8_t getTextureDataType(VkFormat format) return 8; //etc1 case VK_FORMAT_G8B8G8R8_422_UNORM: return 17; //yuyv422r (raster format = not in T format, yuyv) + case VK_FORMAT_X8_D24_UNORM_PACK32: + case VK_FORMAT_D24_UNORM_S8_UINT: + return 0; //rgba8 case VK_FORMAT_UNDEFINED: //TODO return -1; default:// @@ -917,8 +920,17 @@ uint32_t getRenderTargetFormatVC4(VkFormat format) { case VK_FORMAT_R16G16B16A16_SFLOAT: //HDR mode set in tile binning config mode, so just return a valid format case VK_FORMAT_R8G8B8A8_UNORM: + //only here so we can do emulated buffer copies to depth textures + case VK_FORMAT_X8_D24_UNORM_PACK32: + case VK_FORMAT_D24_UNORM_S8_UINT: return VC4_RENDER_CONFIG_FORMAT_RGBA8888; case VK_FORMAT_B5G6R5_UNORM_PACK16: + //TODO + //case VK_FORMAT_R5G5B5A1_UNORM_PACK16: + //case VK_FORMAT_R4G4B4A4_UNORM_PACK16: + //case VK_FORMAT_R8G8_UNORM: + //case VK_FORMAT_R16_SFLOAT: + //case VK_FORMAT_R16_SINT: return VC4_RENDER_CONFIG_FORMAT_BGR565; default: fprintf(stderr, "rendertarget format: %i\n", format); diff --git a/driver/renderpass.c b/driver/renderpass.c index 01697a2..c2c48f6 100644 --- a/driver/renderpass.c +++ b/driver/renderpass.c @@ -41,20 +41,20 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB cb->currentSubpass = 0; - //TODO handle multiple attachments _image* i = 0; _image* dsI = 0; - for(uint32_t c = 0; c < cb->fbo->numAttachmentViews; ++c) + _renderpass* rp = pRenderPassBegin->renderPass; + + for(uint32_t c = 0; c < rp->subpasses[cb->currentSubpass].colorAttachmentCount; ++c) { - if(!isDepthStencilFormat(cb->fbo->attachmentViews[c].image->format)) - { - i = cb->fbo->attachmentViews[c].image; - } - else - { - dsI = cb->fbo->attachmentViews[c].image; - } + i = cb->fbo->attachmentViews[rp->subpasses[cb->currentSubpass].pColorAttachments[c].attachment].image; + break; //TODO handle multiple attachments + } + + if(rp->subpasses[cb->currentSubpass].pDepthStencilAttachment) + { + dsI = cb->fbo->attachmentViews[rp->subpasses[cb->currentSubpass].pDepthStencilAttachment->attachment].image; } clFit(commandBuffer, &commandBuffer->binCl, sizeof(CLMarker)); diff --git a/test/blending/blending.cpp b/test/blending/blending.cpp index b4f088c..d8c4fbf 100644 --- a/test/blending/blending.cpp +++ b/test/blending/blending.cpp @@ -767,7 +767,7 @@ void CreateRenderPass() subpassDesc.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS; subpassDesc.colorAttachmentCount = 1; subpassDesc.pColorAttachments = &attachRef; - subpassDesc.pDepthStencilAttachment = &depthAttachmentRef; + //subpassDesc.pDepthStencilAttachment = &depthAttachmentRef; VkAttachmentDescription attachDesc[2]; attachDesc[0] = {};