simplify VULKAN_INTERNAL_CreateTexture
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

pull/14/head
cosmonaut 2022-02-24 13:48:52 -08:00
parent a39b49ee9b
commit 76217adc40
1 changed files with 20 additions and 28 deletions

View File

@ -5705,8 +5705,7 @@ static Refresh_ShaderModule* VULKAN_CreateShaderModule(
return (Refresh_ShaderModule*) shaderModule; return (Refresh_ShaderModule*) shaderModule;
} }
/* texture should be an alloc'd but uninitialized VulkanTexture */ static VulkanTexture* VULKAN_INTERNAL_CreateTexture(
static uint8_t VULKAN_INTERNAL_CreateTexture(
VulkanRenderer *renderer, VulkanRenderer *renderer,
uint32_t width, uint32_t width,
uint32_t height, uint32_t height,
@ -5717,8 +5716,7 @@ static uint8_t VULKAN_INTERNAL_CreateTexture(
VkFormat format, VkFormat format,
VkImageAspectFlags aspectMask, VkImageAspectFlags aspectMask,
VkImageType imageType, VkImageType imageType,
VkImageUsageFlags imageUsageFlags, VkImageUsageFlags imageUsageFlags
VulkanTexture *texture
) { ) {
VkResult vulkanResult; VkResult vulkanResult;
VkImageCreateInfo imageCreateInfo; VkImageCreateInfo imageCreateInfo;
@ -5732,6 +5730,8 @@ static uint8_t VULKAN_INTERNAL_CreateTexture(
((imageUsageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0); ((imageUsageFlags & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0);
VkComponentMapping swizzle = IDENTITY_SWIZZLE; VkComponentMapping swizzle = IDENTITY_SWIZZLE;
VulkanTexture *texture = SDL_malloc(sizeof(VulkanTexture));
texture->isCube = 0; texture->isCube = 0;
texture->is3D = 0; texture->is3D = 0;
@ -5891,7 +5891,7 @@ static uint8_t VULKAN_INTERNAL_CreateTexture(
texture->queueFamilyIndex = renderer->queueFamilyIndices.graphicsFamily; texture->queueFamilyIndex = renderer->queueFamilyIndices.graphicsFamily;
texture->usageFlags = imageUsageFlags; texture->usageFlags = imageUsageFlags;
return 1; return texture;
} }
static Refresh_Texture* VULKAN_CreateTexture( static Refresh_Texture* VULKAN_CreateTexture(
@ -5899,7 +5899,6 @@ static Refresh_Texture* VULKAN_CreateTexture(
Refresh_TextureCreateInfo *textureCreateInfo Refresh_TextureCreateInfo *textureCreateInfo
) { ) {
VulkanRenderer *renderer = (VulkanRenderer*) driverData; VulkanRenderer *renderer = (VulkanRenderer*) driverData;
VulkanTexture *result;
VkImageUsageFlags imageUsageFlags = ( VkImageUsageFlags imageUsageFlags = (
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT VK_IMAGE_USAGE_TRANSFER_SRC_BIT
@ -5936,9 +5935,7 @@ static Refresh_Texture* VULKAN_CreateTexture(
imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT; imageAspectFlags = VK_IMAGE_ASPECT_COLOR_BIT;
} }
result = (VulkanTexture*) SDL_malloc(sizeof(VulkanTexture)); return (Refresh_Texture*) VULKAN_INTERNAL_CreateTexture(
VULKAN_INTERNAL_CreateTexture(
renderer, renderer,
textureCreateInfo->width, textureCreateInfo->width,
textureCreateInfo->height, textureCreateInfo->height,
@ -5949,11 +5946,8 @@ static Refresh_Texture* VULKAN_CreateTexture(
format, format,
imageAspectFlags, imageAspectFlags,
VK_IMAGE_TYPE_2D, VK_IMAGE_TYPE_2D,
imageUsageFlags, imageUsageFlags
result
); );
return (Refresh_Texture*) result;
} }
static Refresh_RenderTarget* VULKAN_CreateRenderTarget( static Refresh_RenderTarget* VULKAN_CreateRenderTarget(
@ -5992,22 +5986,20 @@ static Refresh_RenderTarget* VULKAN_CreateRenderTarget(
if (multisampleCount > REFRESH_SAMPLECOUNT_1) if (multisampleCount > REFRESH_SAMPLECOUNT_1)
{ {
renderTarget->multisampleTexture = renderTarget->multisampleTexture =
(VulkanTexture*) SDL_malloc(sizeof(VulkanTexture)); VULKAN_INTERNAL_CreateTexture(
renderer,
renderTarget->texture->dimensions.width,
renderTarget->texture->dimensions.height,
1,
0,
RefreshToVK_SampleCount[multisampleCount],
1,
renderTarget->texture->format,
aspectFlags,
VK_IMAGE_TYPE_2D,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT
);
VULKAN_INTERNAL_CreateTexture(
renderer,
renderTarget->texture->dimensions.width,
renderTarget->texture->dimensions.height,
1,
0,
RefreshToVK_SampleCount[multisampleCount],
1,
renderTarget->texture->format,
aspectFlags,
VK_IMAGE_TYPE_2D,
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT,
renderTarget->multisampleTexture
);
renderTarget->multisampleCount = multisampleCount; renderTarget->multisampleCount = multisampleCount;
} }