fix some depth issues
continuous-integration/drone/push Build is passing Details

pull/1/head
cosmonaut 2021-01-28 21:37:11 -08:00
parent 6457967470
commit b854a822d6
1 changed files with 24 additions and 12 deletions

View File

@ -198,15 +198,11 @@ static VkFormat RefreshToVK_SurfaceFormat[] =
VK_FORMAT_R32G32B32A32_SFLOAT, /* R32G32B32A32_SFLOAT */ VK_FORMAT_R32G32B32A32_SFLOAT, /* R32G32B32A32_SFLOAT */
VK_FORMAT_R16_SFLOAT, /* R16_SFLOAT */ VK_FORMAT_R16_SFLOAT, /* R16_SFLOAT */
VK_FORMAT_R16G16_SFLOAT, /* R16G16_SFLOAT */ VK_FORMAT_R16G16_SFLOAT, /* R16G16_SFLOAT */
VK_FORMAT_R16G16B16A16_SFLOAT /* R16G16B16A16_SFLOAT */ VK_FORMAT_R16G16B16A16_SFLOAT, /* R16G16B16A16_SFLOAT */
}; VK_FORMAT_D16_UNORM, /* D16 */
VK_FORMAT_D32_SFLOAT, /* D32 */
static VkFormat RefreshToVK_DepthFormat[] = VK_FORMAT_D16_UNORM_S8_UINT, /* D16S8 */
{ VK_FORMAT_D32_SFLOAT_S8_UINT /* D32S8 */
VK_FORMAT_D16_UNORM,
VK_FORMAT_D32_SFLOAT,
VK_FORMAT_D16_UNORM_S8_UINT,
VK_FORMAT_D32_SFLOAT_S8_UINT
}; };
static VkFormat RefreshToVK_VertexFormat[] = static VkFormat RefreshToVK_VertexFormat[] =
@ -4202,7 +4198,7 @@ static Refresh_RenderPass* VULKAN_CreateRenderPass(
else else
{ {
attachmentDescriptions[attachmentDescriptionCount].flags = 0; attachmentDescriptions[attachmentDescriptionCount].flags = 0;
attachmentDescriptions[attachmentDescriptionCount].format = RefreshToVK_DepthFormat[ attachmentDescriptions[attachmentDescriptionCount].format = RefreshToVK_SurfaceFormat[
renderPassCreateInfo->depthTargetDescription->depthStencilFormat renderPassCreateInfo->depthTargetDescription->depthStencilFormat
]; ];
attachmentDescriptions[attachmentDescriptionCount].samples = attachmentDescriptions[attachmentDescriptionCount].samples =
@ -5708,6 +5704,8 @@ static Refresh_Texture* VULKAN_CreateTexture(
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT VK_IMAGE_USAGE_TRANSFER_SRC_BIT
); );
VkImageAspectFlags imageAspectFlags;
VkFormat format = RefreshToVK_SurfaceFormat[textureCreateInfo->format];
if (textureCreateInfo->usageFlags & REFRESH_TEXTUREUSAGE_SAMPLER_BIT) if (textureCreateInfo->usageFlags & REFRESH_TEXTUREUSAGE_SAMPLER_BIT)
{ {
@ -5724,6 +5722,20 @@ static Refresh_Texture* VULKAN_CreateTexture(
imageUsageFlags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; imageUsageFlags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
} }
if (IsDepthFormat(format))
{
imageAspectFlags = VK_IMAGE_ASPECT_DEPTH_BIT;
if (IsStencilFormat(format))
{
imageAspectFlags |= VK_IMAGE_ASPECT_STENCIL_BIT;
}
}
else
{
imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
}
result = (VulkanTexture*) SDL_malloc(sizeof(VulkanTexture)); result = (VulkanTexture*) SDL_malloc(sizeof(VulkanTexture));
VULKAN_INTERNAL_CreateTexture( VULKAN_INTERNAL_CreateTexture(
@ -5734,8 +5746,8 @@ static Refresh_Texture* VULKAN_CreateTexture(
textureCreateInfo->isCube, textureCreateInfo->isCube,
VK_SAMPLE_COUNT_1_BIT, VK_SAMPLE_COUNT_1_BIT,
textureCreateInfo->levelCount, textureCreateInfo->levelCount,
RefreshToVK_SurfaceFormat[textureCreateInfo->format], format,
VK_IMAGE_ASPECT_COLOR_BIT, imageAspectFlags,
VK_IMAGE_TYPE_2D, VK_IMAGE_TYPE_2D,
imageUsageFlags, imageUsageFlags,
result result