Skip to content

Commit

Permalink
added r32f format, fixed image buffer binding
Browse files Browse the repository at this point in the history
  • Loading branch information
MrFrenik committed Oct 28, 2023
1 parent 18aef07 commit 18bbc62
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion impl/gs_graphics_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions util/gs_idraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 18bbc62

Please sign in to comment.