Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions src/gs/renderer/software_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ void software_thread_destroy(void* udata) {
// release buffers
SDL_ReleaseGPUBuffer(ctx->device, ctx->vertex_buffer);
SDL_ReleaseGPUBuffer(ctx->device, ctx->index_buffer);
SDL_ReleaseGPUSampler(ctx->device, ctx->sampler);
SDL_ReleaseGPUSampler(ctx->device, ctx->sampler[0]);
SDL_ReleaseGPUSampler(ctx->device, ctx->sampler[1]);

if (ctx->texture) SDL_ReleaseGPUTexture(ctx->device, ctx->texture);

Expand Down Expand Up @@ -1528,16 +1529,26 @@ void software_thread_init(void* udata, struct ps2_gs* gs, SDL_Window* window, SD

ctx->index_buffer = SDL_CreateGPUBuffer(device, &ibci);

SDL_GPUSamplerCreateInfo sci = {
.min_filter = ctx->bilinear ? SDL_GPU_FILTER_LINEAR : SDL_GPU_FILTER_NEAREST,
.mag_filter = ctx->bilinear ? SDL_GPU_FILTER_LINEAR : SDL_GPU_FILTER_NEAREST,
SDL_GPUSamplerCreateInfo nearest_sci = {
.min_filter = SDL_GPU_FILTER_NEAREST,
.mag_filter = SDL_GPU_FILTER_NEAREST,
.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST,
.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
};

ctx->sampler = SDL_CreateGPUSampler(ctx->device, &sci);
SDL_GPUSamplerCreateInfo linear_sci = {
.min_filter = SDL_GPU_FILTER_LINEAR,
.mag_filter = SDL_GPU_FILTER_LINEAR,
.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST,
.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
};

ctx->sampler[0] = SDL_CreateGPUSampler(ctx->device, &nearest_sci);
ctx->sampler[1] = SDL_CreateGPUSampler(ctx->device, &linear_sci);
}

static inline void software_thread_vram_blit(struct ps2_gs* gs, software_thread_state* ctx) {
Expand Down Expand Up @@ -2822,7 +2833,7 @@ void software_thread_render(void* udata, SDL_GPUCommandBuffer* command_buffer, S

SDL_GPUTextureSamplerBinding tsb = {
.texture = ctx->texture,
.sampler = ctx->sampler,
.sampler = ctx->bilinear ? ctx->sampler[1] : ctx->sampler[0],
};

SDL_BindGPUFragmentSamplers(render_pass, 0, &tsb, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/gs/renderer/software_thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct software_thread_state {
SDL_GPUBuffer* vertex_buffer = nullptr;
SDL_GPUBuffer* index_buffer = nullptr;
SDL_GPUTexture* texture = nullptr;
SDL_GPUSampler* sampler = nullptr;
SDL_GPUSampler* sampler[2] = { nullptr };
SDL_GPUGraphicsPipeline* pipeline = nullptr;

// Context
Expand Down