renderer: move explicit locations hack into shader cfg

macos/master
Dave Airlie 10 years ago
parent 484353ae8c
commit aca150b35b
  1. 7
      src/vrend_renderer.c
  2. 6
      src/vrend_shader.c
  3. 1
      src/vrend_shader.h

@ -61,7 +61,6 @@ static void vrend_update_frontface_state(struct vrend_context *ctx);
static void vrender_get_glsl_version(int *glsl_version); static void vrender_get_glsl_version(int *glsl_version);
static void vrend_destroy_resource_object(void *obj_ptr); static void vrend_destroy_resource_object(void *obj_ptr);
static void vrend_renderer_detach_res_ctx_p(struct vrend_context *ctx, int res_handle); static void vrend_renderer_detach_res_ctx_p(struct vrend_context *ctx, int res_handle);
extern int vrend_shader_use_explicit;
int vrend_dump_shaders; int vrend_dump_shaders;
@ -111,6 +110,8 @@ struct global_renderer_state {
bool have_bit_encoding; bool have_bit_encoding;
bool have_vertex_attrib_binding; bool have_vertex_attrib_binding;
/* these appeared broken on at least one driver */
bool use_explicit_locations;
uint32_t max_uniform_blocks; uint32_t max_uniform_blocks;
struct list_head active_ctx_list; struct list_head active_ctx_list;
}; };
@ -2292,7 +2293,7 @@ static void vrend_draw_bind_vertex_legacy(struct vrend_context *ctx,
continue; continue;
} }
if (vrend_shader_use_explicit || vrend_state.have_vertex_attrib_binding) { if (vrend_state.use_explicit_locations || vrend_state.have_vertex_attrib_binding) {
loc = i; loc = i;
} else { } else {
if (ctx->sub->prog->attrib_locs) { if (ctx->sub->prog->attrib_locs) {
@ -3570,7 +3571,7 @@ struct vrend_context *vrend_create_context(int id, uint32_t nlen, const char *de
grctx->res_hash = vrend_object_init_ctx_table(); grctx->res_hash = vrend_object_init_ctx_table();
grctx->shader_cfg.use_core_profile = vrend_state.use_core_profile; grctx->shader_cfg.use_core_profile = vrend_state.use_core_profile;
grctx->shader_cfg.use_explicit_locations = vrend_state.use_explicit_locations;
vrend_renderer_create_sub_ctx(grctx, 0); vrend_renderer_create_sub_ctx(grctx, 0);
vrend_renderer_set_sub_ctx(grctx, 0); vrend_renderer_set_sub_ctx(grctx, 0);

@ -42,8 +42,6 @@ extern int vrend_dump_shaders;
#define INTERP_PREFIX " " #define INTERP_PREFIX " "
int vrend_shader_use_explicit = 0;
struct vrend_shader_io { struct vrend_shader_io {
unsigned name; unsigned name;
unsigned gpr; unsigned gpr;
@ -1857,7 +1855,7 @@ static char *emit_header(struct dump_ctx *ctx, char *glsl_hdr)
STRCAT_WITH_RET(glsl_hdr, "#version 140\n"); STRCAT_WITH_RET(glsl_hdr, "#version 140\n");
else else
STRCAT_WITH_RET(glsl_hdr, "#version 130\n"); STRCAT_WITH_RET(glsl_hdr, "#version 130\n");
if (ctx->prog_type == TGSI_PROCESSOR_VERTEX && vrend_shader_use_explicit) if (ctx->prog_type == TGSI_PROCESSOR_VERTEX && ctx->cfg->use_explicit_locations)
STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_explicit_attrib_location : enable\n"); STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_explicit_attrib_location : enable\n");
if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && fs_emit_layout(ctx)) if (ctx->prog_type == TGSI_PROCESSOR_FRAGMENT && fs_emit_layout(ctx))
STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_fragment_coord_conventions : enable\n"); STRCAT_WITH_RET(glsl_hdr, "#extension GL_ARB_fragment_coord_conventions : enable\n");
@ -1954,7 +1952,7 @@ static char *emit_ios(struct dump_ctx *ctx, char *glsl_hdr)
} }
for (i = 0; i < ctx->num_inputs; i++) { for (i = 0; i < ctx->num_inputs; i++) {
if (!ctx->inputs[i].glsl_predefined_no_emit) { if (!ctx->inputs[i].glsl_predefined_no_emit) {
if (ctx->prog_type == TGSI_PROCESSOR_VERTEX && vrend_shader_use_explicit) { if (ctx->prog_type == TGSI_PROCESSOR_VERTEX && ctx->cfg->use_explicit_locations) {
snprintf(buf, 255, "layout(location=%d) ", ctx->inputs[i].first); snprintf(buf, 255, "layout(location=%d) ", ctx->inputs[i].first);
STRCAT_WITH_RET(glsl_hdr, buf); STRCAT_WITH_RET(glsl_hdr, buf);
} }

@ -67,6 +67,7 @@ struct vrend_shader_key {
struct vrend_shader_cfg { struct vrend_shader_cfg {
int glsl_version; int glsl_version;
bool use_core_profile; bool use_core_profile;
bool use_explicit_locations;
}; };
bool vrend_patch_vertex_shader_interpolants(char *program, bool vrend_patch_vertex_shader_interpolants(char *program,

Loading…
Cancel
Save