Skip to content

Commit 9d552d0

Browse files
authored
Merge pull request #12 from allkern/master
renderer: Fix bilinear setting
2 parents fc65f1b + a11d016 commit 9d552d0

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/gs/renderer/software_thread.cpp

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ void software_thread_destroy(void* udata) {
422422
// release buffers
423423
SDL_ReleaseGPUBuffer(ctx->device, ctx->vertex_buffer);
424424
SDL_ReleaseGPUBuffer(ctx->device, ctx->index_buffer);
425-
SDL_ReleaseGPUSampler(ctx->device, ctx->sampler);
425+
SDL_ReleaseGPUSampler(ctx->device, ctx->sampler[0]);
426+
SDL_ReleaseGPUSampler(ctx->device, ctx->sampler[1]);
426427

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

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

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

1531-
SDL_GPUSamplerCreateInfo sci = {
1532-
.min_filter = ctx->bilinear ? SDL_GPU_FILTER_LINEAR : SDL_GPU_FILTER_NEAREST,
1533-
.mag_filter = ctx->bilinear ? SDL_GPU_FILTER_LINEAR : SDL_GPU_FILTER_NEAREST,
1532+
SDL_GPUSamplerCreateInfo nearest_sci = {
1533+
.min_filter = SDL_GPU_FILTER_NEAREST,
1534+
.mag_filter = SDL_GPU_FILTER_NEAREST,
15341535
.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST,
15351536
.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
15361537
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
15371538
.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
15381539
};
15391540

1540-
ctx->sampler = SDL_CreateGPUSampler(ctx->device, &sci);
1541+
SDL_GPUSamplerCreateInfo linear_sci = {
1542+
.min_filter = SDL_GPU_FILTER_LINEAR,
1543+
.mag_filter = SDL_GPU_FILTER_LINEAR,
1544+
.mipmap_mode = SDL_GPU_SAMPLERMIPMAPMODE_NEAREST,
1545+
.address_mode_u = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
1546+
.address_mode_v = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
1547+
.address_mode_w = SDL_GPU_SAMPLERADDRESSMODE_CLAMP_TO_EDGE,
1548+
};
1549+
1550+
ctx->sampler[0] = SDL_CreateGPUSampler(ctx->device, &nearest_sci);
1551+
ctx->sampler[1] = SDL_CreateGPUSampler(ctx->device, &linear_sci);
15411552
}
15421553

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

28232834
SDL_GPUTextureSamplerBinding tsb = {
28242835
.texture = ctx->texture,
2825-
.sampler = ctx->sampler,
2836+
.sampler = ctx->bilinear ? ctx->sampler[1] : ctx->sampler[0],
28262837
};
28272838

28282839
SDL_BindGPUFragmentSamplers(render_pass, 0, &tsb, 1);

src/gs/renderer/software_thread.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ struct software_thread_state {
4949
SDL_GPUBuffer* vertex_buffer = nullptr;
5050
SDL_GPUBuffer* index_buffer = nullptr;
5151
SDL_GPUTexture* texture = nullptr;
52-
SDL_GPUSampler* sampler = nullptr;
52+
SDL_GPUSampler* sampler[2] = { nullptr };
5353
SDL_GPUGraphicsPipeline* pipeline = nullptr;
5454

5555
// Context

0 commit comments

Comments
 (0)