texture creation uses one function + Refresh_TextureCreateInfo
parent
79bc36d99d
commit
56f4c3c2c4
|
@ -519,6 +519,18 @@ typedef struct Refresh_ShaderModuleCreateInfo
|
|||
const uint32_t *byteCode;
|
||||
} Refresh_ShaderModuleCreateInfo;
|
||||
|
||||
typedef struct Refresh_TextureCreateInfo
|
||||
{
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t depth;
|
||||
uint32_t isCube;
|
||||
Refresh_SampleCount sampleCount;
|
||||
uint32_t levelCount;
|
||||
Refresh_ColorFormat format;
|
||||
Refresh_TextureUsageFlags usageFlags;
|
||||
} Refresh_TextureCreateInfo;
|
||||
|
||||
/* Pipeline state structures */
|
||||
|
||||
typedef struct Refresh_ShaderStageState
|
||||
|
@ -856,64 +868,12 @@ REFRESHAPI Refresh_ShaderModule* Refresh_CreateShaderModule(
|
|||
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
|
||||
);
|
||||
|
||||
/* Creates a 2D texture.
|
||||
*
|
||||
* format: The pixel format of the texture data.
|
||||
* width: The width of the texture image.
|
||||
* height: The height of the texture image.
|
||||
* levelCount: The number of mipmap levels to allocate.
|
||||
* usageFlags: Specifies how the texture will be used.
|
||||
*
|
||||
* Returns an allocated Refresh_Texture* object. Note that the contents of
|
||||
/* Returns an allocated Refresh_Texture* object. Note that the contents of
|
||||
* the texture are undefined until SetData is called.
|
||||
*/
|
||||
REFRESHAPI Refresh_Texture* Refresh_CreateTexture2D(
|
||||
REFRESHAPI Refresh_Texture* Refresh_CreateTexture(
|
||||
Refresh_Device *device,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
);
|
||||
|
||||
/* Creates a 3D texture.
|
||||
*
|
||||
* format: The pixel format of the texture data.
|
||||
* width: The width of the texture image.
|
||||
* height: The height of the texture image.
|
||||
* depth: The depth of the texture image.
|
||||
* levelCount: The number of mipmap levels to allocate.
|
||||
* usageFlags: Specifies how the texture will be used.
|
||||
*
|
||||
* Returns an allocated Refresh_Texture* object. Note that the contents of
|
||||
* the texture are undefined until SetData is called.
|
||||
*/
|
||||
REFRESHAPI Refresh_Texture* Refresh_CreateTexture3D(
|
||||
Refresh_Device *device,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t depth,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
);
|
||||
|
||||
/* Creates a texture cube.
|
||||
*
|
||||
* format: The pixel format of the texture data.
|
||||
* size: The length of the cube side.
|
||||
* levelCount: The number of mipmap levels to allocate.
|
||||
* usageFlags: Specifies how the texture will be used.
|
||||
*
|
||||
* Returns an allocated Refresh_Texture* object. Note that the contents of
|
||||
* the texture are undefined until SetData is called.
|
||||
*/
|
||||
REFRESHAPI Refresh_Texture* Refresh_CreateTextureCube(
|
||||
Refresh_Device *device,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t size,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
Refresh_TextureCreateInfo *textureCreateInfo
|
||||
);
|
||||
|
||||
/* Creates a color target.
|
||||
|
|
|
@ -338,60 +338,14 @@ Refresh_ShaderModule* Refresh_CreateShaderModule(
|
|||
);
|
||||
}
|
||||
|
||||
Refresh_Texture* Refresh_CreateTexture2D(
|
||||
Refresh_Texture* Refresh_CreateTexture(
|
||||
Refresh_Device *device,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
Refresh_TextureCreateInfo *textureCreateInfo
|
||||
) {
|
||||
NULL_RETURN_NULL(device);
|
||||
return device->CreateTexture2D(
|
||||
return device->CreateTexture(
|
||||
device->driverData,
|
||||
format,
|
||||
width,
|
||||
height,
|
||||
levelCount,
|
||||
usageFlags
|
||||
);
|
||||
}
|
||||
|
||||
Refresh_Texture* Refresh_CreateTexture3D(
|
||||
Refresh_Device *device,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t depth,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
) {
|
||||
NULL_RETURN_NULL(device);
|
||||
return device->CreateTexture3D(
|
||||
device->driverData,
|
||||
format,
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
levelCount,
|
||||
usageFlags
|
||||
);
|
||||
}
|
||||
|
||||
Refresh_Texture* Refresh_CreateTextureCube(
|
||||
Refresh_Device *device,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t size,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
) {
|
||||
NULL_RETURN_NULL(device);
|
||||
return device->CreateTextureCube(
|
||||
device->driverData,
|
||||
format,
|
||||
size,
|
||||
levelCount,
|
||||
usageFlags
|
||||
textureCreateInfo
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -249,31 +249,9 @@ struct Refresh_Device
|
|||
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
|
||||
);
|
||||
|
||||
Refresh_Texture* (*CreateTexture2D)(
|
||||
Refresh_Texture* (*CreateTexture)(
|
||||
Refresh_Renderer *driverData,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
);
|
||||
|
||||
Refresh_Texture* (*CreateTexture3D)(
|
||||
Refresh_Renderer *driverData,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t depth,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
);
|
||||
|
||||
Refresh_Texture* (*CreateTextureCube)(
|
||||
Refresh_Renderer *driverData,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t size,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
Refresh_TextureCreateInfo *textureCreateInfo
|
||||
);
|
||||
|
||||
Refresh_ColorTarget* (*CreateColorTarget)(
|
||||
|
@ -543,9 +521,7 @@ struct Refresh_Device
|
|||
ASSIGN_DRIVER_FUNC(CreateSampler, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateFramebuffer, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateShaderModule, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateTexture2D, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateTexture3D, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateTextureCube, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateTexture, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateColorTarget, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateDepthStencilTarget, name) \
|
||||
ASSIGN_DRIVER_FUNC(CreateBuffer, name) \
|
||||
|
|
|
@ -5570,13 +5570,9 @@ static uint8_t VULKAN_INTERNAL_CreateTexture(
|
|||
return 1;
|
||||
}
|
||||
|
||||
static Refresh_Texture* VULKAN_CreateTexture2D(
|
||||
static Refresh_Texture* VULKAN_CreateTexture(
|
||||
Refresh_Renderer *driverData,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
Refresh_TextureCreateInfo *textureCreateInfo
|
||||
) {
|
||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||
VulkanTexture *result;
|
||||
|
@ -5586,7 +5582,7 @@ static Refresh_Texture* VULKAN_CreateTexture2D(
|
|||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT
|
||||
);
|
||||
|
||||
if (usageFlags & REFRESH_TEXTUREUSAGE_COLOR_TARGET_BIT)
|
||||
if (textureCreateInfo->usageFlags & REFRESH_TEXTUREUSAGE_COLOR_TARGET_BIT)
|
||||
{
|
||||
imageUsageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
@ -5595,109 +5591,21 @@ static Refresh_Texture* VULKAN_CreateTexture2D(
|
|||
|
||||
VULKAN_INTERNAL_CreateTexture(
|
||||
renderer,
|
||||
width,
|
||||
height,
|
||||
1,
|
||||
0,
|
||||
textureCreateInfo->width,
|
||||
textureCreateInfo->height,
|
||||
textureCreateInfo->depth,
|
||||
textureCreateInfo->isCube,
|
||||
VK_SAMPLE_COUNT_1_BIT,
|
||||
levelCount,
|
||||
RefreshToVK_SurfaceFormat[format],
|
||||
textureCreateInfo->levelCount,
|
||||
RefreshToVK_SurfaceFormat[textureCreateInfo->format],
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_TILING_OPTIMAL,
|
||||
VK_IMAGE_TYPE_2D,
|
||||
imageUsageFlags,
|
||||
usageFlags,
|
||||
textureCreateInfo->usageFlags,
|
||||
result
|
||||
);
|
||||
result->colorFormat = format;
|
||||
|
||||
return (Refresh_Texture*) result;
|
||||
}
|
||||
|
||||
static Refresh_Texture* VULKAN_CreateTexture3D(
|
||||
Refresh_Renderer *driverData,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t depth,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
) {
|
||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||
VulkanTexture *result;
|
||||
VkImageUsageFlags imageUsageFlags = (
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT
|
||||
);
|
||||
|
||||
if (usageFlags & REFRESH_TEXTUREUSAGE_COLOR_TARGET_BIT)
|
||||
{
|
||||
imageUsageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
result = (VulkanTexture*) SDL_malloc(sizeof(VulkanTexture));
|
||||
|
||||
VULKAN_INTERNAL_CreateTexture(
|
||||
renderer,
|
||||
width,
|
||||
height,
|
||||
depth,
|
||||
0,
|
||||
VK_SAMPLE_COUNT_1_BIT,
|
||||
levelCount,
|
||||
RefreshToVK_SurfaceFormat[format],
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_TILING_OPTIMAL,
|
||||
VK_IMAGE_TYPE_3D,
|
||||
imageUsageFlags,
|
||||
usageFlags,
|
||||
result
|
||||
);
|
||||
result->colorFormat = format;
|
||||
|
||||
return (Refresh_Texture*) result;
|
||||
}
|
||||
|
||||
static Refresh_Texture* VULKAN_CreateTextureCube(
|
||||
Refresh_Renderer *driverData,
|
||||
Refresh_ColorFormat format,
|
||||
uint32_t size,
|
||||
uint32_t levelCount,
|
||||
Refresh_TextureUsageFlags usageFlags
|
||||
) {
|
||||
VulkanRenderer *renderer = (VulkanRenderer*) driverData;
|
||||
VulkanTexture *result;
|
||||
VkImageUsageFlags imageUsageFlags = (
|
||||
VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT
|
||||
);
|
||||
|
||||
if (usageFlags & REFRESH_TEXTUREUSAGE_COLOR_TARGET_BIT)
|
||||
{
|
||||
imageUsageFlags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
}
|
||||
|
||||
result = (VulkanTexture*) SDL_malloc(sizeof(VulkanTexture));
|
||||
|
||||
VULKAN_INTERNAL_CreateTexture(
|
||||
renderer,
|
||||
size,
|
||||
size,
|
||||
1,
|
||||
1,
|
||||
VK_SAMPLE_COUNT_1_BIT,
|
||||
levelCount,
|
||||
RefreshToVK_SurfaceFormat[format],
|
||||
VK_IMAGE_ASPECT_COLOR_BIT,
|
||||
VK_IMAGE_TILING_OPTIMAL,
|
||||
VK_IMAGE_TYPE_2D,
|
||||
imageUsageFlags,
|
||||
usageFlags,
|
||||
result
|
||||
);
|
||||
result->colorFormat = format;
|
||||
result->colorFormat = textureCreateInfo->format;
|
||||
|
||||
return (Refresh_Texture*) result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue