1
0
mirror of https://github.com/Yours3lf/rpi-vk-driver.git synced 2024-11-29 11:24:14 +01:00

fixed mipmapping

This commit is contained in:
yours3lf 2020-05-16 14:49:09 +01:00
parent 75cf12a07e
commit cdd209d43a
5 changed files with 21 additions and 24 deletions

View File

@ -38,7 +38,7 @@ typedef struct CLMarker
uint32_t clearColor[2]; uint32_t clearColor[2];
uint32_t clearDepth, clearStencil; uint32_t clearDepth, clearStencil;
uint32_t width, height; //render w/h uint32_t width, height; //render w/h
uint32_t renderToMip; uint32_t mipLevel;
//pointers that point to where all the other CL data is //pointers that point to where all the other CL data is
//plus sizes //plus sizes

View File

@ -360,11 +360,9 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
{ {
uint32_t tiling = writeImage->tiling; uint32_t tiling = writeImage->tiling;
uint32_t isLT = isLTformat(getFormatBpp(writeImage->format), marker->width, marker->height); if(marker->mipLevel > 0)
if(writeImage->tiling == VC4_TILING_FORMAT_T && isLT)
{ {
tiling = VC4_TILING_FORMAT_LT; tiling = writeImage->levelTiling[marker->mipLevel];
} }
submitCl.color_write.hindex = writeImageIdx; submitCl.color_write.hindex = writeImageIdx;
@ -392,11 +390,9 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
{ {
uint32_t tiling = readImage->tiling; uint32_t tiling = readImage->tiling;
uint32_t isLT = isLTformat(getFormatBpp(readImage->format), marker->width, marker->height); if(marker->mipLevel > 0)
if(readImage->tiling == VC4_TILING_FORMAT_T && isLT)
{ {
tiling = VC4_TILING_FORMAT_LT; tiling = readImage->levelTiling[marker->mipLevel];
} }
submitCl.color_read.hindex = readImageIdx; submitCl.color_read.hindex = readImageIdx;
@ -410,11 +406,9 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
{ {
uint32_t tiling = writeDepthStencilImage->tiling; uint32_t tiling = writeDepthStencilImage->tiling;
uint32_t isLT = isLTformat(getFormatBpp(writeDepthStencilImage->format), marker->width, marker->height); if(marker->mipLevel > 0)
if(writeDepthStencilImage->tiling == VC4_TILING_FORMAT_T && isLT)
{ {
tiling = VC4_TILING_FORMAT_LT; tiling = writeDepthStencilImage->levelTiling[marker->mipLevel];
} }
submitCl.zs_write.hindex = writeDepthStencilImageIdx; submitCl.zs_write.hindex = writeDepthStencilImageIdx;
@ -436,11 +430,9 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
{ {
uint32_t tiling = readDepthStencilImage->tiling; uint32_t tiling = readDepthStencilImage->tiling;
uint32_t isLT = isLTformat(getFormatBpp(readDepthStencilImage->format), marker->width, marker->height); if(marker->mipLevel > 0)
if(readDepthStencilImage->tiling == VC4_TILING_FORMAT_T && isLT)
{ {
tiling = VC4_TILING_FORMAT_LT; tiling = readDepthStencilImage->levelTiling[marker->mipLevel];
} }
submitCl.zs_read.hindex = readDepthStencilImageIdx; submitCl.zs_read.hindex = readDepthStencilImageIdx;
@ -498,7 +490,7 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
heightInTiles = divRoundUp(height, tileSizeH); heightInTiles = divRoundUp(height, tileSizeH);
//pad width if rendering to miplevel //pad width if rendering to miplevel
if(marker->renderToMip) if(marker->mipLevel > 0)
{ {
width = getPow2Pad(width); width = getPow2Pad(width);
width = width < 4 ? 4 : width; width = width < 4 ? 4 : width;
@ -542,21 +534,21 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkQueueSubmit(
submitCl.shader_rec_count = marker->shaderRecCount; submitCl.shader_rec_count = marker->shaderRecCount;
submitCl.uniforms_size = marker->uniformsSize; submitCl.uniforms_size = marker->uniformsSize;
/** /**/
printf("BCL:\n"); printf("BCL:\n");
clDump(((uint8_t*)marker) + sizeof(CLMarker), marker->size); clDump(((uint8_t*)marker) + sizeof(CLMarker), marker->size);
printf("BO handles: "); printf("BO handles: ");
for(int d = 0; d < marker->handlesSize / 4; ++d) for(int d = 0; d < marker->handlesSize / 4; ++d)
{ {
printf("%u ", *((uint32_t*)(marker->handlesBuf)+d)); printf("%u ", *(((uint32_t*)getCPAptrFromOffset(cmdbuf->handlesCl.CPA, marker->handlesBufOffset))+d));
} }
printf("\nUniforms: "); printf("\nUniforms: ");
for(int d = 0; d < marker->uniformsSize / 4; ++d) for(int d = 0; d < marker->uniformsSize / 4; ++d)
{ {
printf("%i ", *((uint32_t*)(marker->uniformsBuf)+d)); printf("%i ", *(((uint32_t*)getCPAptrFromOffset(cmdbuf->uniformsCl.CPA, marker->uniformsBufOffset))+d));
} }
printf("\nShader recs: "); printf("\nShader recs: ");
uint8_t* ptr = marker->shaderRecBuf + (3 + 3) * 4; uint8_t* ptr = getCPAptrFromOffset(cmdbuf->shaderRecCl.CPA, marker->shaderRecBufOffset + (3 + 3) * 4);
for(int d = 0; d < marker->shaderRecCount; ++d) for(int d = 0; d < marker->shaderRecCount; ++d)
{ {
uint8_t flags = *ptr; uint8_t flags = *ptr;

View File

@ -197,6 +197,7 @@ typedef struct VkImage_T
uint32_t width, height, depth; uint32_t width, height, depth;
uint32_t miplevels, samples; uint32_t miplevels, samples;
uint32_t levelOffsets[11]; //max 11 mip levels uint32_t levelOffsets[11]; //max 11 mip levels
uint32_t levelTiling[11];
uint32_t layers; //number of views for multiview/stereo uint32_t layers; //number of views for multiview/stereo
uint32_t size; //overall size including padding and alignment uint32_t size; //overall size including padding and alignment
uint32_t stride; //the number of bytes from one row of pixels in memory to the next row of pixels in memory (aka pitch) uint32_t stride; //the number of bytes from one row of pixels in memory to the next row of pixels in memory (aka pitch)

View File

@ -248,11 +248,11 @@ void rpi_vkCmdBeginRenderPass(VkCommandBuffer commandBuffer, const VkRenderPassB
} }
//pad render size if we are rendering to a mip level //pad render size if we are rendering to a mip level
currMarker->renderToMip = biggestMip > 0; currMarker->mipLevel = biggestMip;
uint32_t width = currMarker->width; uint32_t width = currMarker->width;
if(currMarker->renderToMip) if(currMarker->mipLevel > 0)
{ {
width = getPow2Pad(width); width = getPow2Pad(width);
width = width < 4 ? 4 : width; width = width < 4 ? 4 : width;

View File

@ -202,6 +202,7 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateImage(
i->depth = pCreateInfo->extent.depth; i->depth = pCreateInfo->extent.depth;
i->miplevels = pCreateInfo->mipLevels; i->miplevels = pCreateInfo->mipLevels;
memset(i->levelOffsets, 0, sizeof(uint32_t) * 11); memset(i->levelOffsets, 0, sizeof(uint32_t) * 11);
memset(i->levelTiling, 0, sizeof(uint32_t) * 11);
i->samples = pCreateInfo->samples; i->samples = pCreateInfo->samples;
i->layers = pCreateInfo->arrayLayers; i->layers = pCreateInfo->arrayLayers;
i->size = 0; i->size = 0;
@ -311,6 +312,8 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkGetImageMemoryRequirements(
for(int c = i->miplevels - 1; c >= 0; c--) for(int c = i->miplevels - 1; c >= 0; c--)
{ {
i->levelTiling[c] = i->tiling;
uint32_t mipW, mipH; uint32_t mipW, mipH;
if(!c) if(!c)
{ {
@ -340,6 +343,7 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkGetImageMemoryRequirements(
uint32_t isMipLT = isLTformat(bpp, mipW, mipH); uint32_t isMipLT = isLTformat(bpp, mipW, mipH);
if(isMipLT) if(isMipLT)
{ {
i->levelTiling[c] = VC4_TILING_FORMAT_LT;
mipW = roundUp(mipW, utileW); mipW = roundUp(mipW, utileW);
mipH = roundUp(mipH, utileH); mipH = roundUp(mipH, utileH);
} }