From 18bbc62d3c52138678467443a0a398746ab1f07d Mon Sep 17 00:00:00 2001 From: John Jackson Date: Fri, 27 Oct 2023 21:22:47 -0500 Subject: [PATCH] added r32f format, fixed image buffer binding --- impl/gs_graphics_impl.h | 5 ++++- util/gs_idraw.h | 12 ++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/impl/gs_graphics_impl.h b/impl/gs_graphics_impl.h index 419b37f..3be0b48 100644 --- a/impl/gs_graphics_impl.h +++ b/impl/gs_graphics_impl.h @@ -258,6 +258,7 @@ uint32_t gsgl_texture_format_to_gl_data_type(gs_graphics_texture_format_type typ case GS_GRAPHICS_TEXTURE_FORMAT_RGBA8: format = GL_UNSIGNED_BYTE; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGBA16F: format = GL_FLOAT; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGBA32F: format = GL_FLOAT; break; + case GS_GRAPHICS_TEXTURE_FORMAT_R32F: format = GL_FLOAT; break; case GS_GRAPHICS_TEXTURE_FORMAT_DEPTH8: format = GL_FLOAT; break; case GS_GRAPHICS_TEXTURE_FORMAT_DEPTH16: format = GL_FLOAT; break; case GS_GRAPHICS_TEXTURE_FORMAT_DEPTH24: format = GL_FLOAT; break; @@ -278,6 +279,7 @@ uint32_t gsgl_texture_format_to_gl_texture_format(gs_graphics_texture_format_typ case GS_GRAPHICS_TEXTURE_FORMAT_A8: dt = GL_ALPHA; break; case GS_GRAPHICS_TEXTURE_FORMAT_R8: dt = GL_RED; break; case GS_GRAPHICS_TEXTURE_FORMAT_R32: dt = GL_RED_INTEGER; break; + case GS_GRAPHICS_TEXTURE_FORMAT_R32F: dt = GL_RED; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGB8: dt = GL_RGB; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGBA16F: dt = GL_RGBA; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGBA32F: dt = GL_RGBA; break; @@ -299,6 +301,7 @@ uint32_t gsgl_texture_format_to_gl_texture_internal_format(gs_graphics_texture_f case GS_GRAPHICS_TEXTURE_FORMAT_A8: format = GL_ALPHA; break; case GS_GRAPHICS_TEXTURE_FORMAT_R8: format = GL_RED; break; case GS_GRAPHICS_TEXTURE_FORMAT_R32: format = GL_R32UI; break; + case GS_GRAPHICS_TEXTURE_FORMAT_R32F: format = GL_R32F; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGB8: format = GL_RGB8; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGBA8: format = GL_RGBA8; break; case GS_GRAPHICS_TEXTURE_FORMAT_RGBA16F: format = GL_RGBA16F; break; @@ -2305,7 +2308,7 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb) uint32_t gl_format = gsgl_texture_format_to_gl_texture_internal_format(tex->desc.format); // Bind image texture - CHECK_GL_CORE(glBindImageTexture(0, tex->id, 0, GL_FALSE, 0, gl_access, gl_format);) + CHECK_GL_CORE(glBindImageTexture(binding, tex->id, 0, GL_FALSE, 0, gl_access, gl_format);) } break; default: gs_assert(false); break; diff --git a/util/gs_idraw.h b/util/gs_idraw.h index 5f33f47..73d8df9 100644 --- a/util/gs_idraw.h +++ b/util/gs_idraw.h @@ -1297,22 +1297,26 @@ void gsi_rectx(gs_immediate_draw_t* gsi, float l, float b, float r, float t, flo } } -void gsi_rect(gs_immediate_draw_t* gsi, float l, float b, float r, float t, uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a, gs_graphics_primitive_type type) +GS_API_DECL void +gsi_rect(gs_immediate_draw_t* gsi, float l, float b, float r, float t, uint8_t _r, uint8_t _g, uint8_t _b, uint8_t _a, gs_graphics_primitive_type type) { gsi_rectx(gsi, l, b, r, t, 0.f, 0.f, 1.f, 1.f, _r, _g, _b, _a, type); } -void gsi_rectv(gs_immediate_draw_t* gsi, gs_vec2 bl, gs_vec2 tr, gs_color_t color, gs_graphics_primitive_type type) +GS_API_DECL void +gsi_rectv(gs_immediate_draw_t* gsi, gs_vec2 bl, gs_vec2 tr, gs_color_t color, gs_graphics_primitive_type type) { gsi_rectx(gsi, bl.x, bl.y, tr.x, tr.y, 0.f, 0.f, 1.f, 1.f, color.r, color.g, color.b, color.a, type); } -void gsi_rectvx(gs_immediate_draw_t* gsi, gs_vec2 bl, gs_vec2 tr, gs_vec2 uv0, gs_vec2 uv1, gs_color_t color, gs_graphics_primitive_type type) +GS_API_DECL void +gsi_rectvx(gs_immediate_draw_t* gsi, gs_vec2 bl, gs_vec2 tr, gs_vec2 uv0, gs_vec2 uv1, gs_color_t color, gs_graphics_primitive_type type) { gsi_rectx(gsi, bl.x, bl.y, tr.x, tr.y, uv0.x, uv0.y, uv1.x, uv1.y, color.r, color.g, color.b, color.a, type); } -void gsi_rectvd(gs_immediate_draw_t* gsi, gs_vec2 xy, gs_vec2 wh, gs_vec2 uv0, gs_vec2 uv1, gs_color_t color, gs_graphics_primitive_type type) +GS_API_DECL void +gsi_rectvd(gs_immediate_draw_t* gsi, gs_vec2 xy, gs_vec2 wh, gs_vec2 uv0, gs_vec2 uv1, gs_color_t color, gs_graphics_primitive_type type) { gsi_rectx(gsi, xy.x, xy.y, xy.x + wh.x, xy.y + wh.y, uv0.x, uv0.y, uv1.x, uv1.y, color.r, color.g, color.b, color.a, type); }