Skip to content

Commit

Permalink
fix compiler warnings: misc
Browse files Browse the repository at this point in the history
  • Loading branch information
Samdal committed Feb 7, 2024
1 parent 01c4d40 commit ca43145
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
28 changes: 12 additions & 16 deletions impl/gs_graphics_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ gs_graphics_uniform_create_impl(const gs_graphics_uniform_desc_t* desc)
gsgl_data_t* ogl = (gsgl_data_t*)gs_subsystem(graphics)->user_data;

// Assert if data isn't named
if (desc->name == NULL) {
if (*desc->name == 0) {
gs_println("Warning: Uniform must be named for OpenGL.");
return gs_handle_invalid(gs_graphics_uniform_t);
}
Expand Down Expand Up @@ -920,7 +920,7 @@ gs_graphics_storage_buffer_create_impl(const gs_graphics_storage_buffer_desc_t*
gs_handle(gs_graphics_storage_buffer_t) hndl = gs_default_val();
gsgl_storage_buffer_t sbo = gs_default_val();

if (desc->name == NULL) {
if (*desc->name == 0) {
gs_println("Warning: Storage buffer must be named for Opengl.");
}

Expand Down Expand Up @@ -1282,14 +1282,14 @@ gs_graphics_texture_desc_query(gs_handle(gs_graphics_texture_t) hndl, gs_graphic
gsgl_texture_t* tex = gs_slot_array_getp(ogl->textures, hndl.id);

// Read back pixels
if (out->data && out->read.width && out->read.height)
if (out->read.width && out->read.height)
{
uint32_t type = gsgl_texture_format_to_gl_data_type(tex->desc.format);
uint32_t format = gsgl_texture_format_to_gl_texture_format(tex->desc.format);
CHECK_GL_CORE(
glActiveTexture(GL_TEXTURE0);
glGetTextureSubImage(tex->id, 0, out->read.x, out->read.y, 0, out->read.width, out->read.height, 1, format, type, out->read.size, out->data);
);
glActiveTexture(GL_TEXTURE0);
glGetTextureSubImage(tex->id, 0, out->read.x, out->read.y, 0, out->read.width, out->read.height, 1, format, type, out->read.size, out->data);
);
}

*out = tex->desc;
Expand Down Expand Up @@ -1373,7 +1373,6 @@ gs_graphics_index_buffer_update_impl(gs_handle(gs_graphics_index_buffer_t) hndl,
int32_t glusage = gsgl_buffer_usage_to_gl_enum(desc->usage);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer);
switch (desc->update.type) {
l:
case GS_GRAPHICS_BUFFER_UPDATE_SUBDATA: glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, desc->update.offset, desc->size, desc->data); break;
default: glBufferData(GL_ELEMENT_ARRAY_BUFFER, desc->size, desc->data, glusage); break;
}
Expand Down Expand Up @@ -1994,14 +1993,11 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb)
// Construct temp name, concat with base name + uniform field name
char name[256] = gs_default_val();
memcpy(name, ul->name, 64);
if (u->name)
{
gs_snprintfc(UTMP, 256, "%s%s", ul->name, u->name);
memcpy(name, UTMP, 256);
}
gs_snprintfc(UTMP, 256, "%s%s", ul->name, u->name);
memcpy(name, UTMP, 256);

// Grab location of uniform based on name
u->location = glGetUniformLocation(shader, name ? name : "__EMPTY_UNIFORM_NAME");
u->location = glGetUniformLocation(shader, *name ? name : "__EMPTY_UNIFORM_NAME");

if (u->location >= UINT32_MAX) {
gs_println("Warning: Bind Uniform: Uniform not found: \"%s\"", name);
Expand Down Expand Up @@ -2193,7 +2189,7 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb)
gsgl_shader_t shader = gs_slot_array_get(ogl->shaders, sid);

// Get uniform location based on name and bound shader
u->location = glGetUniformBlockIndex(shader, u->name ? u->name : "__EMPTY_UNIFORM_NAME");
u->location = glGetUniformBlockIndex(shader, *u->name ? u->name : "__EMPTY_UNIFORM_NAME");

// Set binding for uniform block
glUniformBlockBinding(shader, u->location, binding);
Expand Down Expand Up @@ -2257,7 +2253,7 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb)
{
// Get uniform location based on name and bound shader
CHECK_GL_CORE(
sbo->block_idx = glGetProgramResourceIndex(shader, GL_SHADER_STORAGE_BLOCK, sbo->name ? sbo->name : "__EMPTY_BUFFER_NAME");
sbo->block_idx = glGetProgramResourceIndex(shader, GL_SHADER_STORAGE_BLOCK, *sbo->name ? sbo->name : "__EMPTY_BUFFER_NAME");
int32_t params[1];
GLenum props[1] = {GL_BUFFER_BINDING};
glGetProgramResourceiv(shader, GL_SHADER_STORAGE_BLOCK, sbo->block_idx, 1, props, 1, NULL, params);
Expand Down Expand Up @@ -2483,7 +2479,7 @@ void gs_graphics_command_buffer_submit_impl(gs_command_buffer_t* cb)
gsgl_buffer_t vbo = vdecl.vbo;

// Manual override. If you manually set divisor/stride/offset, then will not automatically calculate any of those.
bool is_manual = pip->layout[i].stride | pip->layout[i].divisor | pip->layout[i].offset | vdecl.data_type == GS_GRAPHICS_VERTEX_DATA_NONINTERLEAVED;
bool is_manual = pip->layout[i].stride | pip->layout[i].divisor | pip->layout[i].offset | (vdecl.data_type == GS_GRAPHICS_VERTEX_DATA_NONINTERLEAVED);

// Bind buffer
glBindBuffer(GL_ARRAY_BUFFER, vbo);
Expand Down
18 changes: 10 additions & 8 deletions util/gs_gfxt.h
Original file line number Diff line number Diff line change
Expand Up @@ -2349,33 +2349,34 @@ bool gs_parse_code(gs_lexer_t* lex, gs_gfxt_pipeline_desc_t* desc, gs_ppd_t* ppd
{
case GS_TOKEN_IDENTIFIER:
{
// evil replace a const char*
if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_MODEL_VIEW_PROJECTION_MATRIX"))
{
gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_VIEW_PROJECTION_MATRIX, (char)32);
gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_VIEW_PROJECTION_MATRIX, (char)32);
}
else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_VIEW_PROJECTION_MATRIX"))
{
gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_PROJECTION_MATRIX, (char)32);
gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_PROJECTION_MATRIX, (char)32);
}
else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_MODEL_MATRIX"))
{
gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_MATRIX, (char)32);
gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_MODEL_MATRIX, (char)32);
}
else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_INVERSE_MODEL_MATRIX"))
{
gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_INVERSE_MODEL_MATRIX, (char)32);
gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_INVERSE_MODEL_MATRIX, (char)32);
}
else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_VIEW_MATRIX"))
{
gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_MATRIX, (char)32);
gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_VIEW_MATRIX, (char)32);
}
else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_PROJECTION_MATRIX"))
{
gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_PROJECTION_MATRIX, (char)32);
gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_PROJECTION_MATRIX, (char)32);
}
else if (gs_token_compare_text(&tkn, "GS_GFXT_UNIFORM_TIME"))
{
gs_util_string_replace(tkn.text, tkn.len, GS_GFXT_UNIFORM_TIME, (char)32);
gs_util_string_replace((char*)tkn.text, tkn.len, GS_GFXT_UNIFORM_TIME, (char)32);
}
} break;

Expand All @@ -2397,7 +2398,8 @@ bool gs_parse_code(gs_lexer_t* lex, gs_gfxt_pipeline_desc_t* desc, gs_ppd_t* ppd
if (tkn.type == GS_TOKEN_STRING)
{
memcpy(includes[iidx], tkn.text + 1, tkn.len - 2);
gs_util_string_replace(tkn.text - ilen, tkn.len + ilen,
// evil replace a const char*
gs_util_string_replace((char*)tkn.text - ilen, tkn.len + ilen,
" ", (char)32);
iidx++;
}
Expand Down
18 changes: 7 additions & 11 deletions util/gs_gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -6317,7 +6317,7 @@ gs_gui_label_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector_
gs_gui_parse_id_tag(ctx, label, id_tag, sizeof(id_tag), opt);
gs_gui_parse_label_tag(ctx, label, label_tag, sizeof(label_tag));

if (id_tag) gs_gui_push_id(ctx, id_tag, strlen(id_tag));
gs_gui_push_id(ctx, id_tag, strlen(id_tag));

gs_gui_style_t style = gs_default_val();
gs_gui_animation_t* anim = gs_gui_get_animation(ctx, id, desc, elementid);
Expand All @@ -6341,7 +6341,7 @@ gs_gui_label_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector_
gs_gui_update_control(ctx, id, r, 0x00);
gs_gui_draw_control_text(ctx, label_tag, r, &style, 0x00);
gs_gui_pop_style(ctx, save);
if (id_tag) gs_gui_pop_id(ctx);
gs_gui_pop_id(ctx);

/* handle click */
if (
Expand Down Expand Up @@ -6525,9 +6525,7 @@ gs_gui_button_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector
gs_gui_animation_t* anim = gs_gui_get_animation(ctx, id, desc, GS_GUI_ELEMENT_BUTTON);

// Push id if tag available
if (id_tag) {
gs_gui_push_id(ctx, id_tag, strlen(id_tag));
}
gs_gui_push_id(ctx, id_tag, strlen(id_tag));

// Update anim (keep states locally within animation, only way to do this)
if (anim)
Expand Down Expand Up @@ -6567,7 +6565,7 @@ gs_gui_button_ex(gs_gui_context_t* ctx, const char* label, const gs_gui_selector

gs_gui_pop_style(ctx, save);

if (id_tag) gs_gui_pop_id(ctx);
gs_gui_pop_id(ctx);

return res;
}
Expand Down Expand Up @@ -6999,7 +6997,7 @@ static int32_t _gs_gui_header(gs_gui_context_t *ctx, const char *label, int32_t
gs_gui_id id = gs_gui_get_id(ctx, id_tag, strlen(id_tag));
int32_t idx = gs_gui_pool_get(ctx, ctx->treenode_pool, GS_GUI_TREENODEPOOL_SIZE, id);

if (id_tag) gs_gui_push_id(ctx, id_tag, strlen(id_tag));
gs_gui_push_id(ctx, id_tag, strlen(id_tag));

active = (idx >= 0);
expanded = (opt & GS_GUI_OPT_EXPANDED) ? !active : active;
Expand Down Expand Up @@ -7060,7 +7058,7 @@ static int32_t _gs_gui_header(gs_gui_context_t *ctx, const char *label, int32_t
r.w -= r.h - ctx->style->padding[GS_GUI_PADDING_BOTTOM];
gs_gui_draw_control_text(ctx, label_tag, r, &ctx->style_sheet->styles[GS_GUI_ELEMENT_TEXT][0x00], 0);

if (id_tag) gs_gui_pop_id(ctx);
gs_gui_pop_id(ctx);

return expanded ? GS_GUI_RES_ACTIVE : 0;
}
Expand Down Expand Up @@ -7160,9 +7158,7 @@ gs_gui_window_begin_ex(gs_gui_context_t * ctx, const char* title, gs_gui_rect_t
}

// Push id flag
if (id_tag) {
// cnt->flags |= GS_GUI_WINDOW_FLAGS_PUSH_ID;
}
// cnt->flags |= GS_GUI_WINDOW_FLAGS_PUSH_ID;

if (cnt->flags & GS_GUI_WINDOW_FLAGS_FIRST_INIT) {
memcpy(cnt->name, label_tag, 256);
Expand Down

0 comments on commit ca43145

Please sign in to comment.