mirror of
https://github.com/shadps4-emu/ext-SDL.git
synced 2024-11-23 10:09:48 +00:00
Add load op and clear color to SDL_BlitGPUTexture (#10767)
This commit is contained in:
parent
4728325044
commit
668e2f82d2
@ -1603,6 +1603,25 @@ typedef struct SDL_GPUDepthStencilTargetInfo
|
|||||||
Uint8 padding3;
|
Uint8 padding3;
|
||||||
} SDL_GPUDepthStencilTargetInfo;
|
} SDL_GPUDepthStencilTargetInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A structure containing parameters for a blit command.
|
||||||
|
*
|
||||||
|
* \since This struct is available since SDL 3.0.0
|
||||||
|
*
|
||||||
|
* \sa SDL_BlitGPUTexture
|
||||||
|
*/
|
||||||
|
typedef struct SDL_GPUBlitInfo {
|
||||||
|
SDL_GPUBlitRegion source; /**< The source region for the blit. */
|
||||||
|
SDL_GPUBlitRegion destination; /**< The destination region for the blit. */
|
||||||
|
SDL_GPULoadOp load_op; /**< What is done with the contents of the destination before the blit. */
|
||||||
|
SDL_FColor clear_color; /**< The color to clear the destination region to before the blit. Ignored if load_op is not SDL_GPU_LOADOP_CLEAR. */
|
||||||
|
SDL_FlipMode flip_mode; /**< The flip mode for the source region. */
|
||||||
|
SDL_GPUFilter filter; /**< The filter mode used when blitting. */
|
||||||
|
SDL_bool cycle; /**< SDL_TRUE cycles the destination texture if it is already bound. */
|
||||||
|
Uint8 padding;
|
||||||
|
Uint8 padding2;
|
||||||
|
Uint8 padding3;
|
||||||
|
} SDL_GPUBlitInfo;
|
||||||
/* Binding structs */
|
/* Binding structs */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3053,22 +3072,13 @@ extern SDL_DECLSPEC void SDLCALL SDL_GenerateMipmapsForGPUTexture(
|
|||||||
* This function must not be called inside of any pass.
|
* This function must not be called inside of any pass.
|
||||||
*
|
*
|
||||||
* \param command_buffer a command buffer.
|
* \param command_buffer a command buffer.
|
||||||
* \param source the texture region to copy from.
|
* \param info the blit info struct containing the blit parameters.
|
||||||
* \param destination the texture region to copy to.
|
|
||||||
* \param flip_mode the flip mode for the source texture region.
|
|
||||||
* \param filter the filter mode that will be used when blitting.
|
|
||||||
* \param cycle if SDL_TRUE, cycles the destination texture if the destination
|
|
||||||
* texture is bound, otherwise overwrites the data.
|
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*/
|
*/
|
||||||
extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(
|
extern SDL_DECLSPEC void SDLCALL SDL_BlitGPUTexture(
|
||||||
SDL_GPUCommandBuffer *command_buffer,
|
SDL_GPUCommandBuffer *command_buffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info);
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flip_mode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
SDL_bool cycle);
|
|
||||||
|
|
||||||
/* Submission/Presentation */
|
/* Submission/Presentation */
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ SDL_DYNAPI_PROC(void,SDL_BindGPUVertexBuffers,(SDL_GPURenderPass *a, Uint32 b, c
|
|||||||
SDL_DYNAPI_PROC(void,SDL_BindGPUVertexSamplers,(SDL_GPURenderPass *a, Uint32 b, const SDL_GPUTextureSamplerBinding *c, Uint32 d),(a,b,c,d),)
|
SDL_DYNAPI_PROC(void,SDL_BindGPUVertexSamplers,(SDL_GPURenderPass *a, Uint32 b, const SDL_GPUTextureSamplerBinding *c, Uint32 d),(a,b,c,d),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_BindGPUVertexStorageBuffers,(SDL_GPURenderPass *a, Uint32 b, SDL_GPUBuffer *const *c, Uint32 d),(a,b,c,d),)
|
SDL_DYNAPI_PROC(void,SDL_BindGPUVertexStorageBuffers,(SDL_GPURenderPass *a, Uint32 b, SDL_GPUBuffer *const *c, Uint32 d),(a,b,c,d),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_BindGPUVertexStorageTextures,(SDL_GPURenderPass *a, Uint32 b, SDL_GPUTexture *const *c, Uint32 d),(a,b,c,d),)
|
SDL_DYNAPI_PROC(void,SDL_BindGPUVertexStorageTextures,(SDL_GPURenderPass *a, Uint32 b, SDL_GPUTexture *const *c, Uint32 d),(a,b,c,d),)
|
||||||
SDL_DYNAPI_PROC(void,SDL_BlitGPUTexture,(SDL_GPUCommandBuffer *a, const SDL_GPUBlitRegion *b, const SDL_GPUBlitRegion *c, SDL_FlipMode d, SDL_GPUFilter e, SDL_bool f),(a,b,c,d,e,f),)
|
SDL_DYNAPI_PROC(void,SDL_BlitGPUTexture,(SDL_GPUCommandBuffer *a, const SDL_GPUBlitInfo *b),(a,b),)
|
||||||
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurface,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
|
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurface,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d),(a,b,c,d),return)
|
||||||
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurface9Grid,(SDL_Surface *a, const SDL_Rect *b, int c, int d, int e, int f, float g, SDL_ScaleMode h, SDL_Surface *i, const SDL_Rect *j),(a,b,c,d,e,f,g,h,i,j),return)
|
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurface9Grid,(SDL_Surface *a, const SDL_Rect *b, int c, int d, int e, int f, float g, SDL_ScaleMode h, SDL_Surface *i, const SDL_Rect *j),(a,b,c,d,e,f,g,h,i,j),return)
|
||||||
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
|
SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceScaled,(SDL_Surface *a, const SDL_Rect *b, SDL_Surface *c, const SDL_Rect *d, SDL_ScaleMode e),(a,b,c,d,e),return)
|
||||||
|
@ -221,11 +221,7 @@ SDL_GPUGraphicsPipeline *SDL_GPU_FetchBlitPipeline(
|
|||||||
|
|
||||||
void SDL_GPU_BlitCommon(
|
void SDL_GPU_BlitCommon(
|
||||||
SDL_GPUCommandBuffer *command_buffer,
|
SDL_GPUCommandBuffer *command_buffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info,
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flip_mode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
bool cycle,
|
|
||||||
SDL_GPUSampler *blit_linear_sampler,
|
SDL_GPUSampler *blit_linear_sampler,
|
||||||
SDL_GPUSampler *blit_nearest_sampler,
|
SDL_GPUSampler *blit_nearest_sampler,
|
||||||
SDL_GPUShader *blit_vertex_shader,
|
SDL_GPUShader *blit_vertex_shader,
|
||||||
@ -239,8 +235,8 @@ void SDL_GPU_BlitCommon(
|
|||||||
{
|
{
|
||||||
CommandBufferCommonHeader *cmdbufHeader = (CommandBufferCommonHeader *)command_buffer;
|
CommandBufferCommonHeader *cmdbufHeader = (CommandBufferCommonHeader *)command_buffer;
|
||||||
SDL_GPURenderPass *render_pass;
|
SDL_GPURenderPass *render_pass;
|
||||||
TextureCommonHeader *src_header = (TextureCommonHeader *)source->texture;
|
TextureCommonHeader *src_header = (TextureCommonHeader *)info->source.texture;
|
||||||
TextureCommonHeader *dst_header = (TextureCommonHeader *)destination->texture;
|
TextureCommonHeader *dst_header = (TextureCommonHeader *)info->destination.texture;
|
||||||
SDL_GPUGraphicsPipeline *blit_pipeline;
|
SDL_GPUGraphicsPipeline *blit_pipeline;
|
||||||
SDL_GPUColorTargetInfo color_target_info;
|
SDL_GPUColorTargetInfo color_target_info;
|
||||||
SDL_GPUViewport viewport;
|
SDL_GPUViewport viewport;
|
||||||
@ -266,24 +262,14 @@ void SDL_GPU_BlitCommon(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the entire destination is blitted, we don't have to load
|
color_target_info.load_op = info->load_op;
|
||||||
if (
|
color_target_info.clear_color = info->clear_color;
|
||||||
dst_header->info.layer_count_or_depth == 1 &&
|
|
||||||
dst_header->info.num_levels == 1 &&
|
|
||||||
dst_header->info.type != SDL_GPU_TEXTURETYPE_3D &&
|
|
||||||
destination->w == dst_header->info.width &&
|
|
||||||
destination->h == dst_header->info.height) {
|
|
||||||
color_target_info.load_op = SDL_GPU_LOADOP_DONT_CARE;
|
|
||||||
} else {
|
|
||||||
color_target_info.load_op = SDL_GPU_LOADOP_LOAD;
|
|
||||||
}
|
|
||||||
|
|
||||||
color_target_info.store_op = SDL_GPU_STOREOP_STORE;
|
color_target_info.store_op = SDL_GPU_STOREOP_STORE;
|
||||||
|
|
||||||
color_target_info.texture = destination->texture;
|
color_target_info.texture = info->destination.texture;
|
||||||
color_target_info.mip_level = destination->mip_level;
|
color_target_info.mip_level = info->destination.mip_level;
|
||||||
color_target_info.layer_or_depth_plane = destination->layer_or_depth_plane;
|
color_target_info.layer_or_depth_plane = info->destination.layer_or_depth_plane;
|
||||||
color_target_info.cycle = cycle;
|
color_target_info.cycle = info->cycle;
|
||||||
|
|
||||||
render_pass = SDL_BeginGPURenderPass(
|
render_pass = SDL_BeginGPURenderPass(
|
||||||
command_buffer,
|
command_buffer,
|
||||||
@ -291,10 +277,10 @@ void SDL_GPU_BlitCommon(
|
|||||||
1,
|
1,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
viewport.x = (float)destination->x;
|
viewport.x = (float)info->destination.x;
|
||||||
viewport.y = (float)destination->y;
|
viewport.y = (float)info->destination.y;
|
||||||
viewport.w = (float)destination->w;
|
viewport.w = (float)info->destination.w;
|
||||||
viewport.h = (float)destination->h;
|
viewport.h = (float)info->destination.h;
|
||||||
viewport.min_depth = 0;
|
viewport.min_depth = 0;
|
||||||
viewport.max_depth = 1;
|
viewport.max_depth = 1;
|
||||||
|
|
||||||
@ -306,9 +292,9 @@ void SDL_GPU_BlitCommon(
|
|||||||
render_pass,
|
render_pass,
|
||||||
blit_pipeline);
|
blit_pipeline);
|
||||||
|
|
||||||
texture_sampler_binding.texture = source->texture;
|
texture_sampler_binding.texture = info->source.texture;
|
||||||
texture_sampler_binding.sampler =
|
texture_sampler_binding.sampler =
|
||||||
filter == SDL_GPU_FILTER_NEAREST ? blit_nearest_sampler : blit_linear_sampler;
|
info->filter == SDL_GPU_FILTER_NEAREST ? blit_nearest_sampler : blit_linear_sampler;
|
||||||
|
|
||||||
SDL_BindGPUFragmentSamplers(
|
SDL_BindGPUFragmentSamplers(
|
||||||
render_pass,
|
render_pass,
|
||||||
@ -316,21 +302,21 @@ void SDL_GPU_BlitCommon(
|
|||||||
&texture_sampler_binding,
|
&texture_sampler_binding,
|
||||||
1);
|
1);
|
||||||
|
|
||||||
blit_fragment_uniforms.left = (float)source->x / (src_header->info.width >> source->mip_level);
|
blit_fragment_uniforms.left = (float)info->source.x / (src_header->info.width >> info->source.mip_level);
|
||||||
blit_fragment_uniforms.top = (float)source->y / (src_header->info.height >> source->mip_level);
|
blit_fragment_uniforms.top = (float)info->source.y / (src_header->info.height >> info->source.mip_level);
|
||||||
blit_fragment_uniforms.width = (float)source->w / (src_header->info.width >> source->mip_level);
|
blit_fragment_uniforms.width = (float)info->source.w / (src_header->info.width >> info->source.mip_level);
|
||||||
blit_fragment_uniforms.height = (float)source->h / (src_header->info.height >> source->mip_level);
|
blit_fragment_uniforms.height = (float)info->source.h / (src_header->info.height >> info->source.mip_level);
|
||||||
blit_fragment_uniforms.mip_level = source->mip_level;
|
blit_fragment_uniforms.mip_level = info->source.mip_level;
|
||||||
|
|
||||||
layer_divisor = (src_header->info.type == SDL_GPU_TEXTURETYPE_3D) ? src_header->info.layer_count_or_depth : 1;
|
layer_divisor = (src_header->info.type == SDL_GPU_TEXTURETYPE_3D) ? src_header->info.layer_count_or_depth : 1;
|
||||||
blit_fragment_uniforms.layer_or_depth = (float)source->layer_or_depth_plane / layer_divisor;
|
blit_fragment_uniforms.layer_or_depth = (float)info->source.layer_or_depth_plane / layer_divisor;
|
||||||
|
|
||||||
if (flip_mode & SDL_FLIP_HORIZONTAL) {
|
if (info->flip_mode & SDL_FLIP_HORIZONTAL) {
|
||||||
blit_fragment_uniforms.left += blit_fragment_uniforms.width;
|
blit_fragment_uniforms.left += blit_fragment_uniforms.width;
|
||||||
blit_fragment_uniforms.width *= -1;
|
blit_fragment_uniforms.width *= -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flip_mode & SDL_FLIP_VERTICAL) {
|
if (info->flip_mode & SDL_FLIP_VERTICAL) {
|
||||||
blit_fragment_uniforms.top += blit_fragment_uniforms.height;
|
blit_fragment_uniforms.top += blit_fragment_uniforms.height;
|
||||||
blit_fragment_uniforms.height *= -1;
|
blit_fragment_uniforms.height *= -1;
|
||||||
}
|
}
|
||||||
@ -2120,22 +2106,14 @@ void SDL_GenerateMipmapsForGPUTexture(
|
|||||||
|
|
||||||
void SDL_BlitGPUTexture(
|
void SDL_BlitGPUTexture(
|
||||||
SDL_GPUCommandBuffer *command_buffer,
|
SDL_GPUCommandBuffer *command_buffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info)
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flip_mode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
SDL_bool cycle)
|
|
||||||
{
|
{
|
||||||
if (command_buffer == NULL) {
|
if (command_buffer == NULL) {
|
||||||
SDL_InvalidParamError("command_buffer");
|
SDL_InvalidParamError("command_buffer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (source == NULL) {
|
if (info == NULL) {
|
||||||
SDL_InvalidParamError("source");
|
SDL_InvalidParamError("info");
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (destination == NULL) {
|
|
||||||
SDL_InvalidParamError("destination");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2145,11 +2123,15 @@ void SDL_BlitGPUTexture(
|
|||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
bool failed = false;
|
bool failed = false;
|
||||||
TextureCommonHeader *srcHeader = (TextureCommonHeader *)source->texture;
|
TextureCommonHeader *srcHeader = (TextureCommonHeader *)info->source.texture;
|
||||||
TextureCommonHeader *dstHeader = (TextureCommonHeader *)destination->texture;
|
TextureCommonHeader *dstHeader = (TextureCommonHeader *)info->destination.texture;
|
||||||
|
|
||||||
if (srcHeader == NULL || dstHeader == NULL) {
|
if (srcHeader == NULL) {
|
||||||
SDL_assert_release(!"Blit source and destination textures must be non-NULL");
|
SDL_assert_release(!"Blit source texture must be non-NULL");
|
||||||
|
return; // attempting to proceed will crash
|
||||||
|
}
|
||||||
|
if (dstHeader == NULL) {
|
||||||
|
SDL_assert_release(!"Blit destination texture must be non-NULL");
|
||||||
return; // attempting to proceed will crash
|
return; // attempting to proceed will crash
|
||||||
}
|
}
|
||||||
if ((srcHeader->info.usage & SDL_GPU_TEXTUREUSAGE_SAMPLER) == 0) {
|
if ((srcHeader->info.usage & SDL_GPU_TEXTUREUSAGE_SAMPLER) == 0) {
|
||||||
@ -2164,7 +2146,7 @@ void SDL_BlitGPUTexture(
|
|||||||
SDL_assert_release(!"Blit source texture cannot have a depth format");
|
SDL_assert_release(!"Blit source texture cannot have a depth format");
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
if (source->w == 0 || source->h == 0 || destination->w == 0 || destination->h == 0) {
|
if (info->source.w == 0 || info->source.h == 0 || info->destination.w == 0 || info->destination.h == 0) {
|
||||||
SDL_assert_release(!"Blit source/destination regions must have non-zero width, height, and depth");
|
SDL_assert_release(!"Blit source/destination regions must have non-zero width, height, and depth");
|
||||||
failed = true;
|
failed = true;
|
||||||
}
|
}
|
||||||
@ -2176,11 +2158,7 @@ void SDL_BlitGPUTexture(
|
|||||||
|
|
||||||
COMMAND_BUFFER_DEVICE->Blit(
|
COMMAND_BUFFER_DEVICE->Blit(
|
||||||
command_buffer,
|
command_buffer,
|
||||||
source,
|
info);
|
||||||
destination,
|
|
||||||
flip_mode,
|
|
||||||
filter,
|
|
||||||
cycle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Submission/Presentation
|
// Submission/Presentation
|
||||||
|
@ -263,11 +263,7 @@ SDL_GPUGraphicsPipeline *SDL_GPU_FetchBlitPipeline(
|
|||||||
|
|
||||||
void SDL_GPU_BlitCommon(
|
void SDL_GPU_BlitCommon(
|
||||||
SDL_GPUCommandBuffer *commandBuffer,
|
SDL_GPUCommandBuffer *commandBuffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info,
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flipMode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
bool cycle,
|
|
||||||
SDL_GPUSampler *blitLinearSampler,
|
SDL_GPUSampler *blitLinearSampler,
|
||||||
SDL_GPUSampler *blitNearestSampler,
|
SDL_GPUSampler *blitNearestSampler,
|
||||||
SDL_GPUShader *blitVertexShader,
|
SDL_GPUShader *blitVertexShader,
|
||||||
@ -605,11 +601,7 @@ struct SDL_GPUDevice
|
|||||||
|
|
||||||
void (*Blit)(
|
void (*Blit)(
|
||||||
SDL_GPUCommandBuffer *commandBuffer,
|
SDL_GPUCommandBuffer *commandBuffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info);
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flipMode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
bool cycle);
|
|
||||||
|
|
||||||
// Submission/Presentation
|
// Submission/Presentation
|
||||||
|
|
||||||
|
@ -4173,11 +4173,7 @@ static void D3D11_PushFragmentUniformData(
|
|||||||
|
|
||||||
static void D3D11_Blit(
|
static void D3D11_Blit(
|
||||||
SDL_GPUCommandBuffer *commandBuffer,
|
SDL_GPUCommandBuffer *commandBuffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info)
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flipMode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
bool cycle)
|
|
||||||
{
|
{
|
||||||
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
|
D3D11CommandBuffer *d3d11CommandBuffer = (D3D11CommandBuffer *)commandBuffer;
|
||||||
D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer;
|
D3D11Renderer *renderer = (D3D11Renderer *)d3d11CommandBuffer->renderer;
|
||||||
@ -4185,11 +4181,7 @@ static void D3D11_Blit(
|
|||||||
|
|
||||||
SDL_GPU_BlitCommon(
|
SDL_GPU_BlitCommon(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
source,
|
info,
|
||||||
destination,
|
|
||||||
flipMode,
|
|
||||||
filter,
|
|
||||||
cycle,
|
|
||||||
renderer->blitLinearSampler,
|
renderer->blitLinearSampler,
|
||||||
renderer->blitNearestSampler,
|
renderer->blitNearestSampler,
|
||||||
NULL,
|
NULL,
|
||||||
@ -5281,7 +5273,6 @@ static SDL_GPUTexture *D3D11_AcquireSwapchainTexture(
|
|||||||
// Check for window size changes and resize the swapchain if needed.
|
// Check for window size changes and resize the swapchain if needed.
|
||||||
IDXGISwapChain_GetDesc(windowData->swapchain, &swapchainDesc);
|
IDXGISwapChain_GetDesc(windowData->swapchain, &swapchainDesc);
|
||||||
SDL_GetWindowSize(window, &windowW, &windowH);
|
SDL_GetWindowSize(window, &windowW, &windowH);
|
||||||
SDL_Log("%d x %d", windowW, windowH);
|
|
||||||
|
|
||||||
if ((UINT)windowW != swapchainDesc.BufferDesc.Width || (UINT)windowH != swapchainDesc.BufferDesc.Height) {
|
if ((UINT)windowW != swapchainDesc.BufferDesc.Width || (UINT)windowH != swapchainDesc.BufferDesc.Height) {
|
||||||
res = D3D11_INTERNAL_ResizeSwapchain(
|
res = D3D11_INTERNAL_ResizeSwapchain(
|
||||||
|
@ -5729,7 +5729,6 @@ static void D3D12_GenerateMipmaps(
|
|||||||
D3D12Renderer *renderer = d3d12CommandBuffer->renderer;
|
D3D12Renderer *renderer = d3d12CommandBuffer->renderer;
|
||||||
D3D12TextureContainer *container = (D3D12TextureContainer *)texture;
|
D3D12TextureContainer *container = (D3D12TextureContainer *)texture;
|
||||||
SDL_GPUGraphicsPipeline *blitPipeline;
|
SDL_GPUGraphicsPipeline *blitPipeline;
|
||||||
SDL_GPUBlitRegion srcRegion, dstRegion;
|
|
||||||
|
|
||||||
blitPipeline = SDL_GPU_FetchBlitPipeline(
|
blitPipeline = SDL_GPU_FetchBlitPipeline(
|
||||||
renderer->sdlGPUDevice,
|
renderer->sdlGPUDevice,
|
||||||
@ -5752,30 +5751,31 @@ static void D3D12_GenerateMipmaps(
|
|||||||
// We have to do this one subresource at a time
|
// We have to do this one subresource at a time
|
||||||
for (Uint32 layerOrDepthIndex = 0; layerOrDepthIndex < container->header.info.layer_count_or_depth; layerOrDepthIndex += 1) {
|
for (Uint32 layerOrDepthIndex = 0; layerOrDepthIndex < container->header.info.layer_count_or_depth; layerOrDepthIndex += 1) {
|
||||||
for (Uint32 levelIndex = 1; levelIndex < container->header.info.num_levels; levelIndex += 1) {
|
for (Uint32 levelIndex = 1; levelIndex < container->header.info.num_levels; levelIndex += 1) {
|
||||||
|
SDL_GPUBlitInfo blitInfo;
|
||||||
|
SDL_zero(blitInfo);
|
||||||
|
|
||||||
srcRegion.texture = texture;
|
blitInfo.source.texture = texture;
|
||||||
srcRegion.mip_level = levelIndex - 1;
|
blitInfo.source.mip_level = levelIndex - 1;
|
||||||
srcRegion.layer_or_depth_plane = layerOrDepthIndex;
|
blitInfo.source.layer_or_depth_plane = layerOrDepthIndex;
|
||||||
srcRegion.x = 0;
|
blitInfo.source.x = 0;
|
||||||
srcRegion.y = 0;
|
blitInfo.source.y = 0;
|
||||||
srcRegion.w = container->header.info.width >> (levelIndex - 1);
|
blitInfo.source.w = container->header.info.width >> (levelIndex - 1);
|
||||||
srcRegion.h = container->header.info.height >> (levelIndex - 1);
|
blitInfo.source.h = container->header.info.height >> (levelIndex - 1);
|
||||||
|
|
||||||
dstRegion.texture = texture;
|
blitInfo.destination.texture = texture;
|
||||||
dstRegion.mip_level = levelIndex;
|
blitInfo.destination.mip_level = levelIndex;
|
||||||
dstRegion.layer_or_depth_plane = layerOrDepthIndex;
|
blitInfo.destination.layer_or_depth_plane = layerOrDepthIndex;
|
||||||
dstRegion.x = 0;
|
blitInfo.destination.x = 0;
|
||||||
dstRegion.y = 0;
|
blitInfo.destination.y = 0;
|
||||||
dstRegion.w = container->header.info.width >> levelIndex;
|
blitInfo.destination.w = container->header.info.width >> levelIndex;
|
||||||
dstRegion.h = container->header.info.height >> levelIndex;
|
blitInfo.destination.h = container->header.info.height >> levelIndex;
|
||||||
|
|
||||||
|
blitInfo.load_op = SDL_GPU_LOADOP_DONT_CARE;
|
||||||
|
blitInfo.filter = SDL_GPU_FILTER_LINEAR;
|
||||||
|
|
||||||
SDL_BlitGPUTexture(
|
SDL_BlitGPUTexture(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
&srcRegion,
|
&blitInfo);
|
||||||
&dstRegion,
|
|
||||||
SDL_FLIP_NONE,
|
|
||||||
SDL_GPU_FILTER_LINEAR,
|
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5784,22 +5784,14 @@ static void D3D12_GenerateMipmaps(
|
|||||||
|
|
||||||
static void D3D12_Blit(
|
static void D3D12_Blit(
|
||||||
SDL_GPUCommandBuffer *commandBuffer,
|
SDL_GPUCommandBuffer *commandBuffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info)
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flipMode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
bool cycle)
|
|
||||||
{
|
{
|
||||||
D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer;
|
D3D12CommandBuffer *d3d12CommandBuffer = (D3D12CommandBuffer *)commandBuffer;
|
||||||
D3D12Renderer *renderer = (D3D12Renderer *)d3d12CommandBuffer->renderer;
|
D3D12Renderer *renderer = (D3D12Renderer *)d3d12CommandBuffer->renderer;
|
||||||
|
|
||||||
SDL_GPU_BlitCommon(
|
SDL_GPU_BlitCommon(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
source,
|
info,
|
||||||
destination,
|
|
||||||
flipMode,
|
|
||||||
filter,
|
|
||||||
cycle,
|
|
||||||
renderer->blitLinearSampler,
|
renderer->blitLinearSampler,
|
||||||
renderer->blitNearestSampler,
|
renderer->blitNearestSampler,
|
||||||
renderer->blitVertexShader,
|
renderer->blitVertexShader,
|
||||||
|
@ -2903,22 +2903,14 @@ static void METAL_PushFragmentUniformData(
|
|||||||
|
|
||||||
static void METAL_Blit(
|
static void METAL_Blit(
|
||||||
SDL_GPUCommandBuffer *commandBuffer,
|
SDL_GPUCommandBuffer *commandBuffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info)
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flipMode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
bool cycle)
|
|
||||||
{
|
{
|
||||||
MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer;
|
MetalCommandBuffer *metalCommandBuffer = (MetalCommandBuffer *)commandBuffer;
|
||||||
MetalRenderer *renderer = (MetalRenderer *)metalCommandBuffer->renderer;
|
MetalRenderer *renderer = (MetalRenderer *)metalCommandBuffer->renderer;
|
||||||
|
|
||||||
SDL_GPU_BlitCommon(
|
SDL_GPU_BlitCommon(
|
||||||
commandBuffer,
|
commandBuffer,
|
||||||
source,
|
info,
|
||||||
destination,
|
|
||||||
flipMode,
|
|
||||||
filter,
|
|
||||||
cycle,
|
|
||||||
renderer->blitLinearSampler,
|
renderer->blitLinearSampler,
|
||||||
renderer->blitNearestSampler,
|
renderer->blitNearestSampler,
|
||||||
renderer->blitVertexShader,
|
renderer->blitVertexShader,
|
||||||
|
@ -9252,35 +9252,49 @@ static void VULKAN_EndCopyPass(
|
|||||||
|
|
||||||
static void VULKAN_Blit(
|
static void VULKAN_Blit(
|
||||||
SDL_GPUCommandBuffer *commandBuffer,
|
SDL_GPUCommandBuffer *commandBuffer,
|
||||||
const SDL_GPUBlitRegion *source,
|
const SDL_GPUBlitInfo *info)
|
||||||
const SDL_GPUBlitRegion *destination,
|
|
||||||
SDL_FlipMode flipMode,
|
|
||||||
SDL_GPUFilter filter,
|
|
||||||
bool cycle)
|
|
||||||
{
|
{
|
||||||
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer;
|
VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer;
|
||||||
VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer;
|
VulkanRenderer *renderer = (VulkanRenderer *)vulkanCommandBuffer->renderer;
|
||||||
TextureCommonHeader *srcHeader = (TextureCommonHeader *)source->texture;
|
TextureCommonHeader *srcHeader = (TextureCommonHeader *)info->source.texture;
|
||||||
TextureCommonHeader *dstHeader = (TextureCommonHeader *)destination->texture;
|
TextureCommonHeader *dstHeader = (TextureCommonHeader *)info->destination.texture;
|
||||||
VkImageBlit region;
|
VkImageBlit region;
|
||||||
Uint32 srcLayer = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : source->layer_or_depth_plane;
|
Uint32 srcLayer = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : info->source.layer_or_depth_plane;
|
||||||
Uint32 srcDepth = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? source->layer_or_depth_plane : 0;
|
Uint32 srcDepth = srcHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? info->source.layer_or_depth_plane : 0;
|
||||||
Uint32 dstLayer = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : destination->layer_or_depth_plane;
|
Uint32 dstLayer = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? 0 : info->destination.layer_or_depth_plane;
|
||||||
Uint32 dstDepth = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? destination->layer_or_depth_plane : 0;
|
Uint32 dstDepth = dstHeader->info.type == SDL_GPU_TEXTURETYPE_3D ? info->destination.layer_or_depth_plane : 0;
|
||||||
int32_t swap;
|
int32_t swap;
|
||||||
|
|
||||||
|
// Using BeginRenderPass to clear because vkCmdClearColorImage requires barriers anyway
|
||||||
|
if (info->load_op == SDL_GPU_LOADOP_CLEAR) {
|
||||||
|
SDL_GPUColorTargetInfo targetInfo;
|
||||||
|
targetInfo.texture = info->destination.texture;
|
||||||
|
targetInfo.mip_level = info->destination.mip_level;
|
||||||
|
targetInfo.layer_or_depth_plane = info->destination.layer_or_depth_plane;
|
||||||
|
targetInfo.load_op = SDL_GPU_LOADOP_CLEAR;
|
||||||
|
targetInfo.store_op = SDL_GPU_STOREOP_STORE;
|
||||||
|
targetInfo.clear_color = info->clear_color;
|
||||||
|
targetInfo.cycle = info->cycle;
|
||||||
|
VULKAN_BeginRenderPass(
|
||||||
|
commandBuffer,
|
||||||
|
&targetInfo,
|
||||||
|
1,
|
||||||
|
NULL);
|
||||||
|
VULKAN_EndRenderPass(commandBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
VulkanTextureSubresource *srcSubresource = VULKAN_INTERNAL_FetchTextureSubresource(
|
VulkanTextureSubresource *srcSubresource = VULKAN_INTERNAL_FetchTextureSubresource(
|
||||||
(VulkanTextureContainer *)source->texture,
|
(VulkanTextureContainer *)info->source.texture,
|
||||||
srcLayer,
|
srcLayer,
|
||||||
source->mip_level);
|
info->source.mip_level);
|
||||||
|
|
||||||
VulkanTextureSubresource *dstSubresource = VULKAN_INTERNAL_PrepareTextureSubresourceForWrite(
|
VulkanTextureSubresource *dstSubresource = VULKAN_INTERNAL_PrepareTextureSubresourceForWrite(
|
||||||
renderer,
|
renderer,
|
||||||
vulkanCommandBuffer,
|
vulkanCommandBuffer,
|
||||||
(VulkanTextureContainer *)destination->texture,
|
(VulkanTextureContainer *)info->destination.texture,
|
||||||
dstLayer,
|
dstLayer,
|
||||||
destination->mip_level,
|
info->destination.mip_level,
|
||||||
cycle,
|
info->cycle,
|
||||||
VULKAN_TEXTURE_USAGE_MODE_COPY_DESTINATION);
|
VULKAN_TEXTURE_USAGE_MODE_COPY_DESTINATION);
|
||||||
|
|
||||||
VULKAN_INTERNAL_TextureSubresourceTransitionFromDefaultUsage(
|
VULKAN_INTERNAL_TextureSubresourceTransitionFromDefaultUsage(
|
||||||
@ -9293,21 +9307,21 @@ static void VULKAN_Blit(
|
|||||||
region.srcSubresource.baseArrayLayer = srcSubresource->layer;
|
region.srcSubresource.baseArrayLayer = srcSubresource->layer;
|
||||||
region.srcSubresource.layerCount = 1;
|
region.srcSubresource.layerCount = 1;
|
||||||
region.srcSubresource.mipLevel = srcSubresource->level;
|
region.srcSubresource.mipLevel = srcSubresource->level;
|
||||||
region.srcOffsets[0].x = source->x;
|
region.srcOffsets[0].x = info->source.x;
|
||||||
region.srcOffsets[0].y = source->y;
|
region.srcOffsets[0].y = info->source.y;
|
||||||
region.srcOffsets[0].z = srcDepth;
|
region.srcOffsets[0].z = srcDepth;
|
||||||
region.srcOffsets[1].x = source->x + source->w;
|
region.srcOffsets[1].x = info->source.x + info->source.w;
|
||||||
region.srcOffsets[1].y = source->y + source->h;
|
region.srcOffsets[1].y = info->source.y + info->source.h;
|
||||||
region.srcOffsets[1].z = srcDepth + 1;
|
region.srcOffsets[1].z = srcDepth + 1;
|
||||||
|
|
||||||
if (flipMode & SDL_FLIP_HORIZONTAL) {
|
if (info->flip_mode & SDL_FLIP_HORIZONTAL) {
|
||||||
// flip the x positions
|
// flip the x positions
|
||||||
swap = region.srcOffsets[0].x;
|
swap = region.srcOffsets[0].x;
|
||||||
region.srcOffsets[0].x = region.srcOffsets[1].x;
|
region.srcOffsets[0].x = region.srcOffsets[1].x;
|
||||||
region.srcOffsets[1].x = swap;
|
region.srcOffsets[1].x = swap;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flipMode & SDL_FLIP_VERTICAL) {
|
if (info->flip_mode & SDL_FLIP_VERTICAL) {
|
||||||
// flip the y positions
|
// flip the y positions
|
||||||
swap = region.srcOffsets[0].y;
|
swap = region.srcOffsets[0].y;
|
||||||
region.srcOffsets[0].y = region.srcOffsets[1].y;
|
region.srcOffsets[0].y = region.srcOffsets[1].y;
|
||||||
@ -9318,11 +9332,11 @@ static void VULKAN_Blit(
|
|||||||
region.dstSubresource.baseArrayLayer = dstSubresource->layer;
|
region.dstSubresource.baseArrayLayer = dstSubresource->layer;
|
||||||
region.dstSubresource.layerCount = 1;
|
region.dstSubresource.layerCount = 1;
|
||||||
region.dstSubresource.mipLevel = dstSubresource->level;
|
region.dstSubresource.mipLevel = dstSubresource->level;
|
||||||
region.dstOffsets[0].x = destination->x;
|
region.dstOffsets[0].x = info->destination.x;
|
||||||
region.dstOffsets[0].y = destination->y;
|
region.dstOffsets[0].y = info->destination.y;
|
||||||
region.dstOffsets[0].z = dstDepth;
|
region.dstOffsets[0].z = dstDepth;
|
||||||
region.dstOffsets[1].x = destination->x + destination->w;
|
region.dstOffsets[1].x = info->destination.x + info->destination.w;
|
||||||
region.dstOffsets[1].y = destination->y + destination->h;
|
region.dstOffsets[1].y = info->destination.y + info->destination.h;
|
||||||
region.dstOffsets[1].z = dstDepth + 1;
|
region.dstOffsets[1].z = dstDepth + 1;
|
||||||
|
|
||||||
renderer->vkCmdBlitImage(
|
renderer->vkCmdBlitImage(
|
||||||
@ -9333,7 +9347,7 @@ static void VULKAN_Blit(
|
|||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||||
1,
|
1,
|
||||||
®ion,
|
®ion,
|
||||||
SDLToVK_Filter[filter]);
|
SDLToVK_Filter[info->filter]);
|
||||||
|
|
||||||
VULKAN_INTERNAL_TextureSubresourceTransitionToDefaultUsage(
|
VULKAN_INTERNAL_TextureSubresourceTransitionToDefaultUsage(
|
||||||
renderer,
|
renderer,
|
||||||
|
@ -965,19 +965,20 @@ static bool GPU_RenderPresent(SDL_Renderer *renderer)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SDL_GPUTextureFormat swapchain_fmt = SDL_GetGPUSwapchainTextureFormat(data->device, renderer->window);
|
SDL_GPUTextureFormat swapchain_fmt = SDL_GetGPUSwapchainTextureFormat(data->device, renderer->window);
|
||||||
SDL_GPUBlitRegion src;
|
|
||||||
SDL_zero(src);
|
|
||||||
src.texture = data->backbuffer.texture;
|
|
||||||
src.w = data->backbuffer.width;
|
|
||||||
src.h = data->backbuffer.height;
|
|
||||||
|
|
||||||
SDL_GPUBlitRegion dst;
|
SDL_GPUBlitInfo blit_info;
|
||||||
SDL_zero(dst);
|
SDL_zero(blit_info);
|
||||||
dst.texture = swapchain;
|
|
||||||
dst.w = swapchain_w;
|
|
||||||
dst.h = swapchain_h;
|
|
||||||
|
|
||||||
SDL_BlitGPUTexture(data->state.command_buffer, &src, &dst, SDL_FLIP_NONE, SDL_GPU_FILTER_LINEAR, true);
|
blit_info.source.texture = data->backbuffer.texture;
|
||||||
|
blit_info.source.w = data->backbuffer.width;
|
||||||
|
blit_info.source.h = data->backbuffer.height;
|
||||||
|
blit_info.destination.texture = swapchain;
|
||||||
|
blit_info.destination.w = swapchain_w;
|
||||||
|
blit_info.destination.h = swapchain_h;
|
||||||
|
blit_info.load_op = SDL_GPU_LOADOP_DONT_CARE;
|
||||||
|
blit_info.filter = SDL_GPU_FILTER_LINEAR;
|
||||||
|
|
||||||
|
SDL_BlitGPUTexture(data->state.command_buffer, &blit_info);
|
||||||
|
|
||||||
if (swapchain_w != data->backbuffer.width || swapchain_h != data->backbuffer.height || swapchain_fmt != data->backbuffer.format) {
|
if (swapchain_w != data->backbuffer.width || swapchain_h != data->backbuffer.height || swapchain_fmt != data->backbuffer.format) {
|
||||||
SDL_ReleaseGPUTexture(data->device, data->backbuffer.texture);
|
SDL_ReleaseGPUTexture(data->device, data->backbuffer.texture);
|
||||||
|
@ -306,8 +306,7 @@ Render(SDL_Window *window, const int windownum)
|
|||||||
SDL_GPUCommandBuffer *cmd;
|
SDL_GPUCommandBuffer *cmd;
|
||||||
SDL_GPURenderPass *pass;
|
SDL_GPURenderPass *pass;
|
||||||
SDL_GPUBufferBinding vertex_binding;
|
SDL_GPUBufferBinding vertex_binding;
|
||||||
SDL_GPUBlitRegion src_region;
|
SDL_GPUBlitInfo blit_info;
|
||||||
SDL_GPUBlitRegion dst_region;
|
|
||||||
|
|
||||||
/* Acquire the swapchain texture */
|
/* Acquire the swapchain texture */
|
||||||
|
|
||||||
@ -393,15 +392,19 @@ Render(SDL_Window *window, const int windownum)
|
|||||||
|
|
||||||
/* Blit MSAA to swapchain, if needed */
|
/* Blit MSAA to swapchain, if needed */
|
||||||
if (render_state.sample_count > SDL_GPU_SAMPLECOUNT_1) {
|
if (render_state.sample_count > SDL_GPU_SAMPLECOUNT_1) {
|
||||||
SDL_zero(src_region);
|
SDL_zero(blit_info);
|
||||||
src_region.texture = winstate->tex_msaa;
|
blit_info.source.texture = winstate->tex_msaa;
|
||||||
src_region.w = drawablew;
|
blit_info.source.w = drawablew;
|
||||||
src_region.h = drawableh;
|
blit_info.source.h = drawableh;
|
||||||
|
|
||||||
dst_region = src_region;
|
blit_info.destination.texture = swapchain;
|
||||||
dst_region.texture = swapchain;
|
blit_info.destination.w = drawablew;
|
||||||
|
blit_info.destination.h = drawableh;
|
||||||
|
|
||||||
SDL_BlitGPUTexture(cmd, &src_region, &dst_region, SDL_FLIP_NONE, SDL_GPU_FILTER_LINEAR, SDL_FALSE);
|
blit_info.load_op = SDL_GPU_LOADOP_DONT_CARE;
|
||||||
|
blit_info.filter = SDL_GPU_FILTER_LINEAR;
|
||||||
|
|
||||||
|
SDL_BlitGPUTexture(cmd, &blit_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Submit the command buffer! */
|
/* Submit the command buffer! */
|
||||||
|
Loading…
Reference in New Issue
Block a user