mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-04 17:06:25 +00:00
GPU: Allow rendering into depth texture layers and levels
This commit is contained in:
@@ -1688,6 +1688,14 @@ SDL_GPURenderPass *SDL_BeginGPURenderPass(
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (depth_stencil_target_info != NULL) {
|
||||
TextureCommonHeader *depthTextureCommonHeader = (TextureCommonHeader *) depth_stencil_target_info->texture;
|
||||
if (depthTextureCommonHeader->info.layer_count_or_depth > 255) {
|
||||
SDL_SetError("Cannot bind a depth texture with more than 255 layers!");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (COMMAND_BUFFER_DEVICE->debug_mode) {
|
||||
CHECK_COMMAND_BUFFER_RETURN_NULL
|
||||
CHECK_ANY_PASS_IN_PROGRESS("Cannot begin render pass during another pass!", NULL)
|
||||
@@ -3408,4 +3416,3 @@ SDL_GPUTextureFormat SDL_GetGPUTextureFormatFromPixelFormat(SDL_PixelFormat form
|
||||
return SDL_GPU_TEXTUREFORMAT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4289,8 +4289,8 @@ static void D3D12_BeginRenderPass(
|
||||
if (depthStencilTargetInfo != NULL) {
|
||||
D3D12TextureContainer *container = (D3D12TextureContainer *)depthStencilTargetInfo->texture;
|
||||
|
||||
Uint32 h = container->header.info.height;
|
||||
Uint32 w = container->header.info.width;
|
||||
Uint32 h = container->header.info.height >> depthStencilTargetInfo->mip_level;
|
||||
Uint32 w = container->header.info.width >> depthStencilTargetInfo->mip_level;
|
||||
|
||||
// The framebuffer cannot be larger than the smallest target.
|
||||
|
||||
@@ -4359,8 +4359,8 @@ static void D3D12_BeginRenderPass(
|
||||
D3D12TextureSubresource *subresource = D3D12_INTERNAL_PrepareTextureSubresourceForWrite(
|
||||
d3d12CommandBuffer,
|
||||
container,
|
||||
0,
|
||||
0,
|
||||
depthStencilTargetInfo->layer,
|
||||
depthStencilTargetInfo->mip_level,
|
||||
depthStencilTargetInfo->cycle,
|
||||
D3D12_RESOURCE_STATE_DEPTH_WRITE);
|
||||
|
||||
|
@@ -2319,6 +2319,8 @@ static void METAL_BeginRenderPass(
|
||||
depthStencilTargetInfo->cycle);
|
||||
|
||||
passDescriptor.depthAttachment.texture = texture->handle;
|
||||
passDescriptor.depthAttachment.level = depthStencilTargetInfo->mip_level;
|
||||
passDescriptor.depthAttachment.slice = depthStencilTargetInfo->layer;
|
||||
passDescriptor.depthAttachment.loadAction = SDLToMetal_LoadOp[depthStencilTargetInfo->load_op];
|
||||
passDescriptor.depthAttachment.storeAction = SDLToMetal_StoreOp[depthStencilTargetInfo->store_op];
|
||||
passDescriptor.depthAttachment.clearDepth = depthStencilTargetInfo->clear_depth;
|
||||
@@ -2352,8 +2354,8 @@ static void METAL_BeginRenderPass(
|
||||
|
||||
if (depthStencilTargetInfo != NULL) {
|
||||
MetalTextureContainer *container = (MetalTextureContainer *)depthStencilTargetInfo->texture;
|
||||
Uint32 w = container->header.info.width;
|
||||
Uint32 h = container->header.info.height;
|
||||
Uint32 w = container->header.info.width >> depthStencilTargetInfo->mip_level;
|
||||
Uint32 h = container->header.info.height >> depthStencilTargetInfo->mip_level;
|
||||
|
||||
if (w < vpWidth) {
|
||||
vpWidth = w;
|
||||
|
@@ -7276,8 +7276,8 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer(
|
||||
} else {
|
||||
VulkanTextureSubresource *subresource = VULKAN_INTERNAL_FetchTextureSubresource(
|
||||
(VulkanTextureContainer *)depthStencilTargetInfo->texture,
|
||||
0,
|
||||
0);
|
||||
depthStencilTargetInfo->layer,
|
||||
depthStencilTargetInfo->mip_level);
|
||||
key.depthStencilAttachmentView = subresource->depthStencilView;
|
||||
}
|
||||
|
||||
@@ -7332,8 +7332,8 @@ static VulkanFramebuffer *VULKAN_INTERNAL_FetchFramebuffer(
|
||||
if (depthStencilTargetInfo != NULL) {
|
||||
VulkanTextureSubresource *subresource = VULKAN_INTERNAL_FetchTextureSubresource(
|
||||
(VulkanTextureContainer *)depthStencilTargetInfo->texture,
|
||||
0,
|
||||
0);
|
||||
depthStencilTargetInfo->layer,
|
||||
depthStencilTargetInfo->mip_level);
|
||||
imageViewAttachments[attachmentCount] = subresource->depthStencilView;
|
||||
|
||||
attachmentCount += 1;
|
||||
@@ -7813,8 +7813,8 @@ static void VULKAN_BeginRenderPass(
|
||||
if (depthStencilTargetInfo != NULL) {
|
||||
VulkanTextureContainer *textureContainer = (VulkanTextureContainer *)depthStencilTargetInfo->texture;
|
||||
|
||||
w = textureContainer->header.info.width;
|
||||
h = textureContainer->header.info.height;
|
||||
w = textureContainer->header.info.width >> depthStencilTargetInfo->mip_level;
|
||||
h = textureContainer->header.info.height >> depthStencilTargetInfo->mip_level;
|
||||
|
||||
// The framebuffer cannot be larger than the smallest attachment.
|
||||
|
||||
@@ -7869,8 +7869,8 @@ static void VULKAN_BeginRenderPass(
|
||||
renderer,
|
||||
vulkanCommandBuffer,
|
||||
textureContainer,
|
||||
0,
|
||||
0,
|
||||
depthStencilTargetInfo->layer,
|
||||
depthStencilTargetInfo->mip_level,
|
||||
depthStencilTargetInfo->cycle,
|
||||
VULKAN_TEXTURE_USAGE_MODE_DEPTH_STENCIL_ATTACHMENT);
|
||||
|
||||
|
Reference in New Issue
Block a user