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

mipload bias disables auto lod

This commit is contained in:
Unknown 2020-04-10 15:04:09 +01:00
parent 3de1deb156
commit 61d1d5fd27
6 changed files with 18 additions and 21 deletions

View File

@ -871,14 +871,14 @@ uint8_t getTextureDataType(VkFormat format)
}
}
uint8_t getMinFilterType(VkFilter minFilter, VkSamplerMipmapMode mipFilter, float maxLod)
uint8_t getMinFilterType(VkFilter minFilter, VkSamplerMipmapMode mipFilter)//, float maxLod)
{
if(minFilter == VK_FILTER_NEAREST)
{
if(maxLod < 0.0001f)
{
return 1; //no mip filtering
}
// if(maxLod < 0.0001f)
// {
// return 1; //no mip filtering
// }
if(mipFilter == VK_SAMPLER_MIPMAP_MODE_NEAREST)
{
@ -891,10 +891,10 @@ uint8_t getMinFilterType(VkFilter minFilter, VkSamplerMipmapMode mipFilter, floa
}
else if(minFilter == VK_FILTER_LINEAR)
{
if(maxLod < 0.0001f)
{
return 0; //no mip filtering
}
// if(maxLod < 0.0001f)
// {
// return 0; //no mip filtering
// }
if(mipFilter == VK_SAMPLER_MIPMAP_MODE_NEAREST)
{

View File

@ -548,7 +548,7 @@ uint32_t encodeVPMSetup(uint8_t stride,
uint8_t address,
uint8_t vectorComponentsToRead);
uint8_t getTextureDataType(VkFormat format);
uint8_t getMinFilterType(VkFilter minFilter, VkSamplerMipmapMode mipFilter, float maxLod);
uint8_t getMinFilterType(VkFilter minFilter, VkSamplerMipmapMode mipFilter);//, float maxLod);
uint8_t getWrapMode(VkSamplerAddressMode mode);
uint32_t getRenderTargetFormatVC4(VkFormat format);
void clFit(VkCommandBuffer cb, ControlList* cl, uint32_t commandSize);

View File

@ -135,8 +135,6 @@ void createSampler(VkDevice device, VkSampler* nearestTextureSampler, VkSampler*
sampler.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
sampler.mipLodBias = 0.0f;
sampler.compareOp = VK_COMPARE_OP_NEVER;
sampler.minLod = 1.0f; //disable auto LOD
sampler.maxLod = 0.0f;
sampler.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
rpi_vkCreateSampler(device, &sampler, 0, nearestTextureSampler);
_sampler* s = nearestTextureSampler;
@ -1026,10 +1024,8 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdBlitImage(
samplerCI.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samplerCI.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samplerCI.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
samplerCI.mipLodBias = srcMipLevel;
samplerCI.mipLodBias = 1.0f;
samplerCI.compareOp = VK_COMPARE_OP_NEVER;
samplerCI.minLod = 1.0f; //disable auto LOD
samplerCI.maxLod = 999.0f;
samplerCI.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK;
rpi_vkCreateSampler(device, &samplerCI, 0, &mipSampler);
_sampler* s = mipSampler;
@ -1042,7 +1038,7 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdBlitImage(
view.subresourceRange.baseMipLevel = srcMipLevel;
view.subresourceRange.baseArrayLayer = 0;
view.subresourceRange.layerCount = 1;
view.subresourceRange.levelCount = srcMipLevel + 1;
view.subresourceRange.levelCount = srcImg->miplevels;
view.image = srcImage;
rpi_vkCreateImageView(device, &view, 0, &srcTextureView);
@ -1120,8 +1116,9 @@ VKAPI_ATTR void VKAPI_CALL rpi_vkCmdBlitImage(
rpi_vkCmdPushConstants(commandBuffer, blitPipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0, sizeof(vertConstants), &vertConstants);
float mipBias = srcMipLevel;
uint32_t fragConstants[1];
fragConstants[0] = *(uint32_t*)&samplerCI.mipLodBias;
fragConstants[0] = *(uint32_t*)&mipBias;
rpi_vkCmdPushConstants(commandBuffer, blitPipelineLayout, VK_SHADER_STAGE_FRAGMENT_BIT, 0, sizeof(fragConstants), &fragConstants);

View File

@ -339,7 +339,7 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer)
di->imageView->image->levelOffsets[0] >> 12, //Image level 0 offset in multiples of 4KB
di->imageView->image->height & 2047,
di->imageView->image->width & 2047,
getMinFilterType(di->sampler->minFilter, di->sampler->mipmapMode, di->sampler->maxLod),
getMinFilterType(di->sampler->minFilter, di->sampler->mipmapMode),// di->sampler->maxLod),
di->sampler->magFilter == VK_FILTER_NEAREST,
getWrapMode(di->sampler->addressModeU),
getWrapMode(di->sampler->addressModeV),
@ -367,7 +367,7 @@ static uint32_t drawCommon(VkCommandBuffer commandBuffer)
//TODO handle this properly
//TMU0_B requires an extra uniform written
//we need to signal that somehow from API side
if(di->sampler->mipLodBias > 0.0f || di->sampler->disableAutoLod)
if(di->sampler->disableAutoLod)
{
size += 4;
}

View File

@ -32,7 +32,7 @@ VKAPI_ATTR VkResult VKAPI_CALL rpi_vkCreateSampler(
s->maxLod = pCreateInfo->maxLod;
s->borderColor = pCreateInfo->borderColor;
s->unnormalizedCoordinates = pCreateInfo->unnormalizedCoordinates;
s->disableAutoLod = s->minLod > 0.0f;
s->disableAutoLod = s->mipLodBias > 0.0f;
*pSampler = s;

View File

@ -1555,7 +1555,7 @@ void CreateTexture()
sampler.addressModeU = VK_SAMPLER_ADDRESS_MODE_REPEAT;
sampler.addressModeV = VK_SAMPLER_ADDRESS_MODE_REPEAT;
sampler.addressModeW = VK_SAMPLER_ADDRESS_MODE_REPEAT;
//sampler.mipLodBias = 1.0f;
sampler.mipLodBias = 0.0f;
sampler.compareOp = VK_COMPARE_OP_NEVER;
sampler.minLod = 0.0f;
sampler.maxLod = 999.0f;