Skip to content

Commit

Permalink
Got Point, Linear, and Aniso samplers working with Clamp and Repeat
Browse files Browse the repository at this point in the history
  • Loading branch information
klukaszek committed Nov 20, 2024
1 parent 66de5f2 commit e64c553
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
34 changes: 34 additions & 0 deletions src/gpu/SDL_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2719,6 +2719,27 @@ SDL_GPUFence *SDL_SubmitGPUCommandBufferAndAcquireFence(
command_buffer);
}

bool SDL_CancelGPUCommandBuffer(
SDL_GPUCommandBuffer *command_buffer)
{
CommandBufferCommonHeader *commandBufferHeader = (CommandBufferCommonHeader *)command_buffer;

if (command_buffer == NULL) {
SDL_InvalidParamError("command_buffer");
return false;
}

if (COMMAND_BUFFER_DEVICE->debug_mode) {
if (commandBufferHeader->swapchain_texture_acquired) {
SDL_assert_release(!"Cannot cancel command buffer after a swapchain texture has been acquired!");
return false;
}
}

return COMMAND_BUFFER_DEVICE->Cancel(
command_buffer);
}

bool SDL_WaitForGPUIdle(
SDL_GPUDevice *device)
{
Expand Down Expand Up @@ -2775,3 +2796,16 @@ void SDL_ReleaseGPUFence(
device->driverData,
fence);
}

Uint32 SDL_CalculateGPUTextureFormatSize(
SDL_GPUTextureFormat format,
Uint32 width,
Uint32 height,
Uint32 depth_or_layer_count)
{
Uint32 blockWidth = SDL_max(Texture_GetBlockWidth(format), 1);
Uint32 blockHeight = SDL_max(Texture_GetBlockHeight(format), 1);
Uint32 blocksPerRow = (width + blockWidth - 1) / blockWidth;
Uint32 blocksPerColumn = (height + blockHeight - 1) / blockHeight;
return depth_or_layer_count * blocksPerRow * blocksPerColumn * SDL_GPUTextureFormatTexelBlockSize(format);
}
13 changes: 12 additions & 1 deletion src/gpu/webgpu/SDL_gpu_webgpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ static WGPUFilterMode SDLToWGPUFilterMode(SDL_GPUFilter filterMode)
case SDL_GPU_FILTER_LINEAR:
return WGPUFilterMode_Linear;
default:
return WGPUFilterMode_Nearest;
return WGPUFilterMode_Undefined;
}
}

Expand Down Expand Up @@ -2883,6 +2883,17 @@ static SDL_GPUSampler *WebGPU_CreateSampler(
return NULL;
}

/*WGPUSamplerDescriptor samplerDesc = {};*/
/*samplerDesc.addressModeU = WGPUAddressMode_Repeat;*/
/*samplerDesc.addressModeV = WGPUAddressMode_Repeat;*/
/*samplerDesc.magFilter = WGPUFilterMode_Nearest;*/
/*samplerDesc.minFilter = WGPUFilterMode_Nearest;*/
/*samplerDesc.mipmapFilter = WGPUMipmapFilterMode_Nearest;*/
/*samplerDesc.lodMinClamp = 0.0f;*/
/*samplerDesc.lodMaxClamp = 1.0f;*/
/*samplerDesc.maxAnisotropy = 1;*/
/*WGPUSampler pointWrapSampler = wgpuDeviceCreateSampler(renderer->device, &samplerDesc);*/

WGPUSamplerDescriptor samplerDesc = {
.label = "SDL_GPU WebGPU Sampler",
.addressModeU = SDLToWGPUAddressMode(createinfo->address_mode_u),
Expand Down

0 comments on commit e64c553

Please sign in to comment.