diff options
author | Jordan Justen <[email protected]> | 2016-03-17 01:38:05 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2016-03-17 01:44:07 -0700 |
commit | 3fd308a357b9057447d21c67718d13524dbbb40d (patch) | |
tree | 9f59a4b5c5fd2a2edefed9a51377221f6ddc3a20 | |
parent | 5464f0c046ac68630355932639f18a02dc4b2d92 (diff) | |
parent | 7d021cb15e6d67ecef8b020fd36c4a680bcc9c39 (diff) |
Merge remote-tracking branch 'origin/master' into vulkan
26 files changed, 266 insertions, 285 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index ae37cbf7325..ab1afdbc475 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -88,9 +88,9 @@ typedef enum { nir_var_local, nir_var_uniform, nir_var_shader_storage, - nir_var_shared, nir_var_system_value, nir_var_param, + nir_var_shared, } nir_variable_mode; /** diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 84e353775cf..9d502ee4e9c 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -361,10 +361,11 @@ nir_lower_io_block(nir_block *block, void *void_state) atomic->const_index[0] = intrin->variables[0]->var->data.driver_location; - nir_src_copy(&atomic->src[1], &intrin->src[0], atomic); - - if (intrin->intrinsic == nir_intrinsic_var_atomic_comp_swap) - nir_src_copy(&atomic->src[2], &intrin->src[1], atomic); + for (unsigned i = 0; + i < nir_op_infos[intrin->intrinsic].num_inputs; + i++) { + nir_src_copy(&atomic->src[i+1], &intrin->src[i], atomic); + } if (intrin->dest.is_ssa) { nir_ssa_dest_init(&atomic->instr, &atomic->dest, diff --git a/src/gallium/drivers/vc4/vc4_opt_dead_code.c b/src/gallium/drivers/vc4/vc4_opt_dead_code.c index 9e79a2d1b2e..44d0779c611 100644 --- a/src/gallium/drivers/vc4/vc4_opt_dead_code.c +++ b/src/gallium/drivers/vc4/vc4_opt_dead_code.c @@ -86,12 +86,8 @@ qir_opt_dead_code(struct vc4_compile *c) /* Whether we're eliminating texture setup currently. */ bool dce_tex = false; - struct list_head *node, *t; - for (node = c->instructions.prev, t = node->prev; - &c->instructions != node; - node = t, t = t->prev) { - struct qinst *inst = (struct qinst *)node; - + list_for_each_entry_safe_rev(struct qinst, inst, &c->instructions, + link) { if (inst->dst.file == QFILE_TEMP && !used[inst->dst.index] && !inst->sf && diff --git a/src/gallium/drivers/vc4/vc4_program.c b/src/gallium/drivers/vc4/vc4_program.c index 81e8e9150d6..f5826d85174 100644 --- a/src/gallium/drivers/vc4/vc4_program.c +++ b/src/gallium/drivers/vc4/vc4_program.c @@ -1184,8 +1184,11 @@ emit_frag_end(struct vc4_compile *c) color = qir_uniform_ui(c, 0); } - if (c->discard.file != QFILE_NULL) - qir_TLB_DISCARD_SETUP(c, c->discard); + uint32_t discard_cond = QPU_COND_ALWAYS; + if (c->discard.file != QFILE_NULL) { + qir_SF(c, c->discard); + discard_cond = QPU_COND_ZS; + } if (c->fs_key->stencil_enabled) { qir_TLB_STENCIL_SETUP(c, qir_uniform(c, QUNIFORM_STENCIL, 0)); @@ -1209,14 +1212,18 @@ emit_frag_end(struct vc4_compile *c) } else { z = qir_FRAG_Z(c); } - qir_TLB_Z_WRITE(c, z); + struct qinst *inst = qir_TLB_Z_WRITE(c, z); + inst->cond = discard_cond; } if (!c->msaa_per_sample_output) { - qir_TLB_COLOR_WRITE(c, color); + struct qinst *inst = qir_TLB_COLOR_WRITE(c, color); + inst->cond = discard_cond; } else { - for (int i = 0; i < VC4_MAX_SAMPLES; i++) - qir_TLB_COLOR_WRITE_MS(c, c->sample_colors[i]); + for (int i = 0; i < VC4_MAX_SAMPLES; i++) { + struct qinst *inst = qir_TLB_COLOR_WRITE_MS(c, c->sample_colors[i]); + inst->cond = discard_cond; + } } } diff --git a/src/gallium/drivers/vc4/vc4_qir.c b/src/gallium/drivers/vc4/vc4_qir.c index 65f0067c61e..e73e3899410 100644 --- a/src/gallium/drivers/vc4/vc4_qir.c +++ b/src/gallium/drivers/vc4/vc4_qir.c @@ -69,7 +69,6 @@ static const struct qir_op_info qir_op_info[] = { [QOP_RSQ] = { "rsq", 1, 1, false, true }, [QOP_EXP2] = { "exp2", 1, 2, false, true }, [QOP_LOG2] = { "log2", 1, 2, false, true }, - [QOP_TLB_DISCARD_SETUP] = { "discard", 0, 1, true }, [QOP_TLB_STENCIL_SETUP] = { "tlb_stencil_setup", 0, 1, true }, [QOP_TLB_Z_WRITE] = { "tlb_z", 0, 1, true }, [QOP_TLB_COLOR_WRITE] = { "tlb_color", 0, 1, true }, @@ -488,11 +487,15 @@ qir_SF(struct vc4_compile *c, struct qreg src) if (!list_empty(&c->instructions)) last_inst = (struct qinst *)c->instructions.prev; + /* We don't have any way to guess which kind of MOV is implied. */ + assert(!src.pack); + if (src.file != QFILE_TEMP || !c->defs[src.index] || last_inst != c->defs[src.index] || qir_is_multi_instruction(last_inst)) { - src = qir_MOV(c, src); + struct qreg null = { QFILE_NULL, 0 }; + last_inst = qir_MOV_dest(c, null, src); last_inst = (struct qinst *)c->instructions.prev; } last_inst->sf = true; diff --git a/src/gallium/drivers/vc4/vc4_qir.h b/src/gallium/drivers/vc4/vc4_qir.h index 4f39d72f552..3fbf5d749e7 100644 --- a/src/gallium/drivers/vc4/vc4_qir.h +++ b/src/gallium/drivers/vc4/vc4_qir.h @@ -101,7 +101,6 @@ enum qop { QOP_LOG2, QOP_VW_SETUP, QOP_VR_SETUP, - QOP_TLB_DISCARD_SETUP, QOP_TLB_STENCIL_SETUP, QOP_TLB_Z_WRITE, QOP_TLB_COLOR_WRITE, @@ -551,17 +550,23 @@ qir_##name##_dest(struct vc4_compile *c, struct qreg dest, \ } #define QIR_NODST_1(name) \ -static inline void \ +static inline struct qinst * \ qir_##name(struct vc4_compile *c, struct qreg a) \ { \ - qir_emit(c, qir_inst(QOP_##name, c->undef, a, c->undef)); \ + struct qinst *inst = qir_inst(QOP_##name, c->undef, \ + a, c->undef); \ + qir_emit(c, inst); \ + return inst; \ } #define QIR_NODST_2(name) \ -static inline void \ +static inline struct qinst * \ qir_##name(struct vc4_compile *c, struct qreg a, struct qreg b) \ { \ - qir_emit(c, qir_inst(QOP_##name, c->undef, a, b)); \ + struct qinst *inst = qir_inst(QOP_##name, c->undef, \ + a, b); \ + qir_emit(c, inst); \ + return inst; \ } #define QIR_PACK(name) \ @@ -623,7 +628,6 @@ QIR_ALU0(TLB_COLOR_READ) QIR_NODST_1(TLB_COLOR_WRITE) QIR_NODST_1(TLB_COLOR_WRITE_MS) QIR_NODST_1(TLB_Z_WRITE) -QIR_NODST_1(TLB_DISCARD_SETUP) QIR_NODST_1(TLB_STENCIL_SETUP) QIR_NODST_1(MS_MASK) diff --git a/src/gallium/drivers/vc4/vc4_qir_schedule.c b/src/gallium/drivers/vc4/vc4_qir_schedule.c index ee1e9aafbb9..186e81be750 100644 --- a/src/gallium/drivers/vc4/vc4_qir_schedule.c +++ b/src/gallium/drivers/vc4/vc4_qir_schedule.c @@ -236,11 +236,6 @@ calculate_deps(struct schedule_setup_state *state, struct schedule_node *n) add_write_dep(dir, &state->last_tlb, n); break; - case QOP_TLB_DISCARD_SETUP: - add_write_dep(dir, &state->last_sf, n); - add_write_dep(dir, &state->last_tlb, n); - break; - default: break; } diff --git a/src/gallium/drivers/vc4/vc4_qpu_emit.c b/src/gallium/drivers/vc4/vc4_qpu_emit.c index 450b97fc014..b507e370683 100644 --- a/src/gallium/drivers/vc4/vc4_qpu_emit.c +++ b/src/gallium/drivers/vc4/vc4_qpu_emit.c @@ -171,7 +171,6 @@ void vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c) { struct qpu_reg *temp_registers = vc4_register_allocate(vc4, c); - bool discard = false; uint32_t inputs_remaining = c->num_inputs; uint32_t vpm_read_fifo_count = 0; uint32_t vpm_read_offset = 0; @@ -375,12 +374,6 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c) */ break; - case QOP_TLB_DISCARD_SETUP: - discard = true; - queue(c, qpu_a_MOV(src[0], src[0]) | unpack); - *last_inst(c) |= QPU_SF; - break; - case QOP_TLB_STENCIL_SETUP: assert(!unpack); queue(c, qpu_a_MOV(qpu_ra(QPU_W_TLB_STENCIL_SETUP), @@ -390,9 +383,8 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c) case QOP_TLB_Z_WRITE: queue(c, qpu_a_MOV(qpu_ra(QPU_W_TLB_Z), src[0]) | unpack); - if (discard) { - set_last_cond_add(c, QPU_COND_ZS); - } + set_last_cond_add(c, qinst->cond); + handled_qinst_cond = true; break; case QOP_TLB_COLOR_READ: @@ -406,16 +398,14 @@ vc4_generate_code(struct vc4_context *vc4, struct vc4_compile *c) case QOP_TLB_COLOR_WRITE: queue(c, qpu_a_MOV(qpu_tlbc(), src[0]) | unpack); - if (discard) { - set_last_cond_add(c, QPU_COND_ZS); - } + set_last_cond_add(c, qinst->cond); + handled_qinst_cond = true; break; case QOP_TLB_COLOR_WRITE_MS: queue(c, qpu_a_MOV(qpu_tlbc_ms(), src[0])); - if (discard) { - set_last_cond_add(c, QPU_COND_ZS); - } + set_last_cond_add(c, qinst->cond); + handled_qinst_cond = true; break; case QOP_VARY_ADD_C: diff --git a/src/intel/vulkan/anv_pipeline.c b/src/intel/vulkan/anv_pipeline.c index abe93a50af8..56d79a02d79 100644 --- a/src/intel/vulkan/anv_pipeline.c +++ b/src/intel/vulkan/anv_pipeline.c @@ -366,10 +366,6 @@ anv_pipeline_compile(struct anv_pipeline *pipeline, if (pipeline->layout) anv_nir_apply_pipeline_layout(pipeline, nir, prog_data, map); - /* Finish the optimization and compilation process */ - if (nir->stage == MESA_SHADER_COMPUTE) - brw_nir_lower_shared(nir); - /* nir_lower_io will only handle the push constants; we need to set this * to the full number of possible uniforms. */ @@ -775,8 +771,6 @@ anv_pipeline_compile_cs(struct anv_pipeline *pipeline, anv_fill_binding_table(&prog_data.base, 1); - prog_data.base.total_shared = nir->num_shared; - void *mem_ctx = ralloc_context(NULL); if (module->nir == NULL) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index ab78f4565da..b673db44b0b 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -121,72 +121,51 @@ _mesa_meta_framebuffer_texture_image(struct gl_context *ctx, level, layer, false, __func__); } -GLuint +struct gl_shader * _mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target, const GLcharARB *source) { - GLuint shader; - GLint ok, size; - GLchar *info; - - shader = _mesa_CreateShader(target); - _mesa_ShaderSource(shader, 1, &source, NULL); - _mesa_CompileShader(shader); - - _mesa_GetShaderiv(shader, GL_COMPILE_STATUS, &ok); - if (ok) - return shader; - - _mesa_GetShaderiv(shader, GL_INFO_LOG_LENGTH, &size); - if (size == 0) { - _mesa_DeleteShader(shader); - return 0; - } + const GLuint name = ~0; + struct gl_shader *sh; + + sh = ctx->Driver.NewShader(ctx, name, target); + sh->Source = strdup(source); + sh->CompileStatus = false; + _mesa_compile_shader(ctx, sh); + + if (!sh->CompileStatus) { + if (sh->InfoLog) { + _mesa_problem(ctx, + "meta program compile failed:\n%s\nsource:\n%s\n", + sh->InfoLog, source); + } - info = malloc(size); - if (!info) { - _mesa_DeleteShader(shader); - return 0; + _mesa_reference_shader(ctx, &sh, NULL); } - _mesa_GetShaderInfoLog(shader, size, NULL, info); - _mesa_problem(ctx, - "meta program compile failed:\n%s\n" - "source:\n%s\n", - info, source); - - free(info); - _mesa_DeleteShader(shader); - - return 0; + return sh; } -GLuint -_mesa_meta_link_program_with_debug(struct gl_context *ctx, GLuint program) +void +_mesa_meta_link_program_with_debug(struct gl_context *ctx, + struct gl_shader_program *sh_prog) { - GLint ok, size; - GLchar *info; - - _mesa_LinkProgram(program); - - _mesa_GetProgramiv(program, GL_LINK_STATUS, &ok); - if (ok) - return program; + _mesa_link_program(ctx, sh_prog); - _mesa_GetProgramiv(program, GL_INFO_LOG_LENGTH, &size); - if (size == 0) - return 0; - - info = malloc(size); - if (!info) - return 0; - - _mesa_GetProgramInfoLog(program, size, NULL, info); - _mesa_problem(ctx, "meta program link failed:\n%s", info); + if (!sh_prog->LinkStatus) { + _mesa_problem(ctx, "meta program link failed:\n%s", sh_prog->InfoLog); + } +} - free(info); +void +_mesa_meta_use_program(struct gl_context *ctx, + struct gl_shader_program *sh_prog) +{ + /* Attach shader state to the binding point */ + _mesa_reference_pipeline_object(ctx, &ctx->_Shader, &ctx->Shader); - return 0; + /* Update the program */ + _mesa_use_program(ctx, sh_prog); } void @@ -194,24 +173,25 @@ _mesa_meta_compile_and_link_program(struct gl_context *ctx, const char *vs_source, const char *fs_source, const char *name, - GLuint *program) + struct gl_shader_program **out_sh_prog) { - GLuint vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, - vs_source); - GLuint fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, - fs_source); - - *program = _mesa_CreateProgram(); - _mesa_ObjectLabel(GL_PROGRAM, *program, -1, name); - _mesa_AttachShader(*program, fs); - _mesa_DeleteShader(fs); - _mesa_AttachShader(*program, vs); - _mesa_DeleteShader(vs); - _mesa_BindAttribLocation(*program, 0, "position"); - _mesa_BindAttribLocation(*program, 1, "texcoords"); - _mesa_meta_link_program_with_debug(ctx, *program); - - _mesa_UseProgram(*program); + struct gl_shader_program *sh_prog; + const GLuint id = ~0; + + sh_prog = _mesa_new_shader_program(id); + sh_prog->Label = strdup(name); + sh_prog->NumShaders = 2; + sh_prog->Shaders = malloc(2 * sizeof(struct gl_shader *)); + sh_prog->Shaders[0] = + _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source); + sh_prog->Shaders[1] = + _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source); + + _mesa_meta_link_program_with_debug(ctx, sh_prog); + + _mesa_meta_use_program(ctx, sh_prog); + + *out_sh_prog = sh_prog; } /** @@ -230,19 +210,15 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, { char *vs_source, *fs_source; struct blit_shader *shader = choose_blit_shader(target, table); - const char *vs_input, *vs_output, *fs_input, *vs_preprocess, *fs_preprocess; + const char *fs_input, *vs_preprocess, *fs_preprocess; void *mem_ctx; if (ctx->Const.GLSLVersion < 130) { vs_preprocess = ""; - vs_input = "attribute"; - vs_output = "varying"; fs_preprocess = "#extension GL_EXT_texture_array : enable"; fs_input = "varying"; } else { vs_preprocess = "#version 130"; - vs_input = "in"; - vs_output = "out"; fs_preprocess = "#version 130"; fs_input = "in"; shader->func = "texture"; @@ -250,8 +226,8 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, assert(shader != NULL); - if (shader->shader_prog != 0) { - _mesa_UseProgram(shader->shader_prog); + if (shader->shader_prog != NULL) { + _mesa_meta_use_program(ctx, shader->shader_prog); return; } @@ -259,15 +235,16 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, vs_source = ralloc_asprintf(mem_ctx, "%s\n" - "%s vec2 position;\n" - "%s vec4 textureCoords;\n" - "%s vec4 texCoords;\n" + "#extension GL_ARB_explicit_attrib_location: enable\n" + "layout(location = 0) in vec2 position;\n" + "layout(location = 1) in vec4 textureCoords;\n" + "out vec4 texCoords;\n" "void main()\n" "{\n" " texCoords = textureCoords;\n" " gl_Position = vec4(position, 0.0, 1.0);\n" "}\n", - vs_preprocess, vs_input, vs_input, vs_output); + vs_preprocess); fs_source = ralloc_asprintf(mem_ctx, "%s\n" @@ -1533,7 +1510,6 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) "{\n" " gl_FragColor = color;\n" "}\n"; - GLuint vs, fs; bool has_integer_textures; _mesa_meta_setup_vertex_objects(ctx, &clear->VAO, &clear->buf_obj, true, @@ -1542,21 +1518,8 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) if (clear->ShaderProg != 0) return; - vs = _mesa_CreateShader(GL_VERTEX_SHADER); - _mesa_ShaderSource(vs, 1, &vs_source, NULL); - _mesa_CompileShader(vs); - - fs = _mesa_CreateShader(GL_FRAGMENT_SHADER); - _mesa_ShaderSource(fs, 1, &fs_source, NULL); - _mesa_CompileShader(fs); - - clear->ShaderProg = _mesa_CreateProgram(); - _mesa_AttachShader(clear->ShaderProg, fs); - _mesa_DeleteShader(fs); - _mesa_AttachShader(clear->ShaderProg, vs); - _mesa_DeleteShader(vs); - _mesa_ObjectLabel(GL_PROGRAM, clear->ShaderProg, -1, "meta clear"); - _mesa_LinkProgram(clear->ShaderProg); + _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, "meta clear", + &clear->ShaderProg); has_integer_textures = _mesa_is_gles3(ctx) || (_mesa_is_desktop_gl(ctx) && ctx->Const.GLSLVersion >= 130); @@ -1590,26 +1553,15 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) " out_color = color;\n" "}\n"); - vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, - vs_int_source); - fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, - fs_int_source); + _mesa_meta_compile_and_link_program(ctx, vs_int_source, fs_int_source, + "integer clear", + &clear->IntegerShaderProg); ralloc_free(shader_source_mem_ctx); - clear->IntegerShaderProg = _mesa_CreateProgram(); - _mesa_AttachShader(clear->IntegerShaderProg, fs); - _mesa_DeleteShader(fs); - _mesa_AttachShader(clear->IntegerShaderProg, vs); - _mesa_DeleteShader(vs); - /* Note that user-defined out attributes get automatically assigned * locations starting from 0, so we don't need to explicitly * BindFragDataLocation to 0. */ - - _mesa_ObjectLabel(GL_PROGRAM, clear->IntegerShaderProg, -1, - "integer clear"); - _mesa_meta_link_program_with_debug(ctx, clear->IntegerShaderProg); } } @@ -1621,12 +1573,10 @@ meta_glsl_clear_cleanup(struct gl_context *ctx, struct clear_state *clear) _mesa_DeleteVertexArrays(1, &clear->VAO); clear->VAO = 0; _mesa_reference_buffer_object(ctx, &clear->buf_obj, NULL); - _mesa_DeleteProgram(clear->ShaderProg); - clear->ShaderProg = 0; + _mesa_reference_shader_program(ctx, &clear->ShaderProg, NULL); if (clear->IntegerShaderProg) { - _mesa_DeleteProgram(clear->IntegerShaderProg); - clear->IntegerShaderProg = 0; + _mesa_reference_shader_program(ctx, &clear->IntegerShaderProg, NULL); } } @@ -1740,10 +1690,10 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) if (fb->_IntegerColor) { assert(glsl); - _mesa_UseProgram(clear->IntegerShaderProg); + _mesa_meta_use_program(ctx, clear->IntegerShaderProg); _mesa_Uniform4iv(0, 1, ctx->Color.ClearColor.i); } else if (glsl) { - _mesa_UseProgram(clear->ShaderProg); + _mesa_meta_use_program(ctx, clear->ShaderProg); _mesa_Uniform4fv(0, 1, ctx->Color.ClearColor.f); } @@ -2704,25 +2654,17 @@ choose_blit_shader(GLenum target, struct blit_shader_table *table) } void -_mesa_meta_blit_shader_table_cleanup(struct blit_shader_table *table) +_mesa_meta_blit_shader_table_cleanup(struct gl_context *ctx, + struct blit_shader_table *table) { - _mesa_DeleteProgram(table->sampler_1d.shader_prog); - _mesa_DeleteProgram(table->sampler_2d.shader_prog); - _mesa_DeleteProgram(table->sampler_3d.shader_prog); - _mesa_DeleteProgram(table->sampler_rect.shader_prog); - _mesa_DeleteProgram(table->sampler_cubemap.shader_prog); - _mesa_DeleteProgram(table->sampler_1d_array.shader_prog); - _mesa_DeleteProgram(table->sampler_2d_array.shader_prog); - _mesa_DeleteProgram(table->sampler_cubemap_array.shader_prog); - - table->sampler_1d.shader_prog = 0; - table->sampler_2d.shader_prog = 0; - table->sampler_3d.shader_prog = 0; - table->sampler_rect.shader_prog = 0; - table->sampler_cubemap.shader_prog = 0; - table->sampler_1d_array.shader_prog = 0; - table->sampler_2d_array.shader_prog = 0; - table->sampler_cubemap_array.shader_prog = 0; + _mesa_reference_shader_program(ctx, &table->sampler_1d.shader_prog, NULL); + _mesa_reference_shader_program(ctx, &table->sampler_2d.shader_prog, NULL); + _mesa_reference_shader_program(ctx, &table->sampler_3d.shader_prog, NULL); + _mesa_reference_shader_program(ctx, &table->sampler_rect.shader_prog, NULL); + _mesa_reference_shader_program(ctx, &table->sampler_cubemap.shader_prog, NULL); + _mesa_reference_shader_program(ctx, &table->sampler_1d_array.shader_prog, NULL); + _mesa_reference_shader_program(ctx, &table->sampler_2d_array.shader_prog, NULL); + _mesa_reference_shader_program(ctx, &table->sampler_cubemap_array.shader_prog, NULL); } /** diff --git a/src/mesa/drivers/common/meta.h b/src/mesa/drivers/common/meta.h index c2efa50a33d..0a7321c9d88 100644 --- a/src/mesa/drivers/common/meta.h +++ b/src/mesa/drivers/common/meta.h @@ -218,7 +218,7 @@ struct blit_shader { const char *type; const char *func; const char *texcoords; - GLuint shader_prog; + struct gl_shader_program *shader_prog; }; /** @@ -302,7 +302,7 @@ struct blit_state struct gl_buffer_object *buf_obj; struct blit_shader_table shaders_with_depth; struct blit_shader_table shaders_without_depth; - GLuint msaa_shaders[BLIT_MSAA_SHADER_COUNT]; + struct gl_shader_program *msaa_shaders[BLIT_MSAA_SHADER_COUNT]; struct temp_texture depthTex; bool no_ctsi_fallback; }; @@ -324,8 +324,8 @@ struct clear_state { GLuint VAO; struct gl_buffer_object *buf_obj; - GLuint ShaderProg; - GLuint IntegerShaderProg; + struct gl_shader_program *ShaderProg; + struct gl_shader_program *IntegerShaderProg; }; @@ -577,20 +577,25 @@ _mesa_meta_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, void _mesa_meta_drawbuffers_from_bitfield(GLbitfield bits); -GLuint +struct gl_shader * _mesa_meta_compile_shader_with_debug(struct gl_context *ctx, GLenum target, const GLcharARB *source); -GLuint -_mesa_meta_link_program_with_debug(struct gl_context *ctx, GLuint program); +void +_mesa_meta_link_program_with_debug(struct gl_context *ctx, + struct gl_shader_program *sh_prog); void _mesa_meta_compile_and_link_program(struct gl_context *ctx, const char *vs_source, const char *fs_source, const char *name, - GLuint *program); + struct gl_shader_program **sh_prog_ptr); + +extern void +_mesa_meta_use_program(struct gl_context *ctx, + struct gl_shader_program *sh_prog); GLboolean _mesa_meta_alloc_texture(struct temp_texture *tex, @@ -655,7 +660,8 @@ void _mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit); void -_mesa_meta_blit_shader_table_cleanup(struct blit_shader_table *table); +_mesa_meta_blit_shader_table_cleanup(struct gl_context *ctx, + struct blit_shader_table *table); void _mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx, diff --git a/src/mesa/drivers/common/meta_blit.c b/src/mesa/drivers/common/meta_blit.c index 5d80f7d8fe1..0066f7f9184 100644 --- a/src/mesa/drivers/common/meta_blit.c +++ b/src/mesa/drivers/common/meta_blit.c @@ -105,12 +105,12 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, } if (blit->msaa_shaders[shader_index]) { - _mesa_UseProgram(blit->msaa_shaders[shader_index]); + _mesa_meta_use_program(ctx, blit->msaa_shaders[shader_index]); /* Update the uniform values. */ loc_src_width = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_width"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_width"); loc_src_height = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_height"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_height"); _mesa_Uniform1f(loc_src_width, src_rb->Width); _mesa_Uniform1f(loc_src_height, src_rb->Height); return; @@ -168,8 +168,9 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, static const char vs_source[] = "#version 130\n" - "in vec2 position;\n" - "in vec3 textureCoords;\n" + "#extension GL_ARB_explicit_attrib_location: enable\n" + "layout(location = 0) in vec2 position;\n" + "layout(location = 1) in vec3 textureCoords;\n" "out vec2 texCoords;\n" "flat out int layer;\n" "void main()\n" @@ -236,9 +237,9 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, name, &blit->msaa_shaders[shader_index]); loc_src_width = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_width"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_width"); loc_src_height = - _mesa_GetUniformLocation(blit->msaa_shaders[shader_index], "src_height"); + _mesa_program_resource_location(blit->msaa_shaders[shader_index], GL_UNIFORM, "src_height"); _mesa_Uniform1f(loc_src_width, src_rb->Width); _mesa_Uniform1f(loc_src_height, src_rb->Height); @@ -346,7 +347,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, } if (blit->msaa_shaders[shader_index]) { - _mesa_UseProgram(blit->msaa_shaders[shader_index]); + _mesa_meta_use_program(ctx, blit->msaa_shaders[shader_index]); return; } @@ -384,8 +385,9 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, vs_source = ralloc_asprintf(mem_ctx, "#version 130\n" - "in vec2 position;\n" - "in %s textureCoords;\n" + "#extension GL_ARB_explicit_attrib_location: enable\n" + "layout(location = 0) in vec2 position;\n" + "layout(location = 1) in %s textureCoords;\n" "out %s texCoords;\n" "void main()\n" "{\n" @@ -506,8 +508,9 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, vs_source = ralloc_asprintf(mem_ctx, "#version 130\n" - "in vec2 position;\n" - "in %s textureCoords;\n" + "#extension GL_ARB_explicit_attrib_location: enable\n" + "layout(location = 0) in vec2 position;\n" + "layout(location = 1) in %s textureCoords;\n" "out %s texCoords;\n" "void main()\n" "{\n" @@ -1034,8 +1037,8 @@ _mesa_meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit) _mesa_reference_buffer_object(ctx, &blit->buf_obj, NULL); } - _mesa_meta_blit_shader_table_cleanup(&blit->shaders_with_depth); - _mesa_meta_blit_shader_table_cleanup(&blit->shaders_without_depth); + _mesa_meta_blit_shader_table_cleanup(ctx, &blit->shaders_with_depth); + _mesa_meta_blit_shader_table_cleanup(ctx, &blit->shaders_without_depth); _mesa_DeleteTextures(1, &blit->depthTex.TexObj); blit->depthTex.TexObj = 0; diff --git a/src/mesa/drivers/common/meta_generate_mipmap.c b/src/mesa/drivers/common/meta_generate_mipmap.c index 892d8d34619..d4b75390ebf 100644 --- a/src/mesa/drivers/common/meta_generate_mipmap.c +++ b/src/mesa/drivers/common/meta_generate_mipmap.c @@ -134,7 +134,7 @@ _mesa_meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx, _mesa_reference_sampler_object(ctx, &mipmap->samp_obj, NULL); _mesa_reference_framebuffer(&mipmap->fb, NULL); - _mesa_meta_blit_shader_table_cleanup(&mipmap->shaders); + _mesa_meta_blit_shader_table_cleanup(ctx, &mipmap->shaders); } static GLboolean diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index a953745b114..b45ee5eb69d 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -900,7 +900,7 @@ struct brw_context struct brw_cache cache; /** IDs for meta stencil blit shader programs. */ - unsigned meta_stencil_blit_programs[2]; + struct gl_shader_program *meta_stencil_blit_programs[2]; /* Whether a meta-operation is in progress. */ bool meta_in_progress; diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 6f11f597492..0b99356b27d 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -202,8 +202,20 @@ brw_set_dest(struct brw_codegen *p, brw_inst *inst, struct brw_reg dest) /* Generators should set a default exec_size of either 8 (SIMD4x2 or SIMD8) * or 16 (SIMD16), as that's normally correct. However, when dealing with * small registers, we automatically reduce it to match the register size. + * + * In platforms that support fp64 we can emit instructions with a width of + * 4 that need two SIMD8 registers and an exec_size of 8 or 16. In these + * cases we need to make sure that these instructions have their exec sizes + * set properly when they are emitted and we can't rely on this code to fix + * it. */ - if (dest.width < BRW_EXECUTE_8) + bool fix_exec_size; + if (devinfo->gen >= 6) + fix_exec_size = dest.width < BRW_EXECUTE_4; + else + fix_exec_size = dest.width < BRW_EXECUTE_8; + + if (fix_exec_size) brw_inst_set_exec_size(devinfo, inst, dest.width); } @@ -1229,8 +1241,9 @@ brw_F16TO32(struct brw_codegen *p, struct brw_reg dst, struct brw_reg src) void brw_NOP(struct brw_codegen *p) { brw_inst *insn = next_insn(p, BRW_OPCODE_NOP); - brw_set_dest(p, insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD)); - brw_set_src0(p, insn, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD)); + brw_inst_set_exec_size(p->devinfo, insn, BRW_EXECUTE_1); + brw_set_dest(p, insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD)); + brw_set_src0(p, insn, retype(brw_vec1_grf(0,0), BRW_REGISTER_TYPE_UD)); brw_set_src1(p, insn, brw_imm_ud(0x0)); } @@ -2562,6 +2575,9 @@ brw_send_indirect_message(struct brw_codegen *p, brw_set_src1(p, send, addr); } + if (dst.width < BRW_EXECUTE_8) + brw_inst_set_exec_size(devinfo, send, dst.width); + brw_set_dest(p, send, dst); brw_set_src0(p, send, retype(payload, BRW_REGISTER_TYPE_UD)); brw_inst_set_sfid(devinfo, send, sfid); @@ -3330,11 +3346,14 @@ brw_find_live_channel(struct brw_codegen *p, struct brw_reg dst) /* Overwrite the destination without and with execution masking to * find out which of the channels is active. */ + brw_push_insn_state(p); + brw_set_default_exec_size(p, BRW_EXECUTE_4); brw_MOV(p, brw_writemask(vec4(dst), WRITEMASK_X), brw_imm_ud(1)); inst = brw_MOV(p, brw_writemask(vec4(dst), WRITEMASK_X), brw_imm_ud(0)); + brw_pop_insn_state(p); brw_inst_set_mask_control(devinfo, inst, BRW_MASK_ENABLE); } } diff --git a/src/mesa/drivers/dri/i965/brw_ff_gs_emit.c b/src/mesa/drivers/dri/i965/brw_ff_gs_emit.c index 8589dabe4c5..fea2b93471c 100644 --- a/src/mesa/drivers/dri/i965/brw_ff_gs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_ff_gs_emit.c @@ -406,9 +406,13 @@ gen6_sol_program(struct brw_ff_gs_compile *c, struct brw_ff_gs_prog_key *key, : 0x00020001)); /* (1, 0, 2) */ brw_inst_set_pred_control(p->devinfo, inst, BRW_PREDICATE_NORMAL); } + + assert(c->reg.destination_indices.width == BRW_EXECUTE_4); + brw_push_insn_state(p); + brw_set_default_exec_size(p, BRW_EXECUTE_4); brw_ADD(p, c->reg.destination_indices, c->reg.destination_indices, get_element_ud(c->reg.SVBI, 0)); - + brw_pop_insn_state(p); /* For each vertex, generate code to output each varying using the * appropriate binding table entry. */ @@ -438,8 +442,13 @@ gen6_sol_program(struct brw_ff_gs_compile *c, struct brw_ff_gs_prog_key *key, vertex_slot.swizzle = varying == VARYING_SLOT_PSIZ ? BRW_SWIZZLE_WWWW : key->transform_feedback_swizzles[binding]; brw_set_default_access_mode(p, BRW_ALIGN_16); + brw_push_insn_state(p); + brw_set_default_exec_size(p, BRW_EXECUTE_4); + brw_MOV(p, stride(c->reg.header, 4, 4, 1), retype(vertex_slot, BRW_REGISTER_TYPE_UD)); + brw_pop_insn_state(p); + brw_set_default_access_mode(p, BRW_ALIGN_1); brw_svb_write(p, final_write ? c->reg.temp : brw_null_reg(), /* dest */ diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index b5f1a874368..874053c8489 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -5788,6 +5788,8 @@ brw_compile_cs(const struct brw_compiler *compiler, void *log_data, nir_shader *shader = nir_shader_clone(mem_ctx, src_shader); shader = brw_nir_apply_sampler_key(shader, compiler->devinfo, &key->tex, true); + brw_nir_lower_cs_shared(shader); + prog_data->base.total_shared += shader->num_shared; shader = brw_postprocess_nir(shader, compiler->devinfo, true); prog_data->local_size[0] = shader->info.cs.local_size[0]; diff --git a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp index 75c29c597f5..ae80832544b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_generator.cpp @@ -1288,6 +1288,7 @@ fs_generator::generate_uniform_pull_constant_load_gen7(fs_inst *inst, brw_set_default_compression_control(p, BRW_COMPRESSION_NONE); brw_set_default_mask_control(p, BRW_MASK_DISABLE); brw_inst *send = brw_next_insn(p, BRW_OPCODE_SEND); + brw_inst_set_exec_size(devinfo, send, BRW_EXECUTE_4); brw_pop_insn_state(p); brw_set_dest(p, send, dst); diff --git a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c index b81b1438ba3..1fb5dc83885 100644 --- a/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c +++ b/src/mesa/drivers/dri/i965/brw_meta_fast_clear.c @@ -26,6 +26,7 @@ #include "main/context.h" #include "main/objectlabel.h" #include "main/shaderapi.h" +#include "main/shaderobj.h" #include "main/arrayobj.h" #include "main/bufferobj.h" #include "main/buffers.h" @@ -61,8 +62,8 @@ struct brw_fast_clear_state { struct gl_buffer_object *buf_obj; struct gl_vertex_array_object *array_obj; + struct gl_shader_program *shader_prog; GLuint vao; - GLuint shader_prog; GLint color_location; }; @@ -110,7 +111,8 @@ brw_bind_rep_write_shader(struct brw_context *brw, float *color) const char *vs_source = "#extension GL_AMD_vertex_shader_layer : enable\n" "#extension GL_ARB_draw_instanced : enable\n" - "attribute vec4 position;\n" + "#extension GL_ARB_explicit_attrib_location : enable\n" + "layout(location = 0) in vec4 position;\n" "uniform int layer;\n" "void main()\n" "{\n" @@ -126,32 +128,23 @@ brw_bind_rep_write_shader(struct brw_context *brw, float *color) " gl_FragColor = color;\n" "}\n"; - GLuint vs, fs; struct brw_fast_clear_state *clear = brw->fast_clear_state; struct gl_context *ctx = &brw->ctx; if (clear->shader_prog) { - _mesa_UseProgram(clear->shader_prog); + _mesa_meta_use_program(ctx, clear->shader_prog); _mesa_Uniform4fv(clear->color_location, 1, color); return; } - vs = _mesa_meta_compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source); - fs = _mesa_meta_compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source); - - clear->shader_prog = _mesa_CreateProgram(); - _mesa_AttachShader(clear->shader_prog, fs); - _mesa_DeleteShader(fs); - _mesa_AttachShader(clear->shader_prog, vs); - _mesa_DeleteShader(vs); - _mesa_BindAttribLocation(clear->shader_prog, 0, "position"); - _mesa_ObjectLabel(GL_PROGRAM, clear->shader_prog, -1, "meta repclear"); - _mesa_LinkProgram(clear->shader_prog); + _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, + "meta repclear", + &clear->shader_prog); clear->color_location = - _mesa_GetUniformLocation(clear->shader_prog, "color"); + _mesa_program_resource_location(clear->shader_prog, GL_UNIFORM, "color"); - _mesa_UseProgram(clear->shader_prog); + _mesa_meta_use_program(ctx, clear->shader_prog); _mesa_Uniform4fv(clear->color_location, 1, color); } @@ -168,7 +161,7 @@ brw_meta_fast_clear_free(struct brw_context *brw) _mesa_DeleteVertexArrays(1, &clear->vao); _mesa_reference_buffer_object(&brw->ctx, &clear->buf_obj, NULL); - _mesa_DeleteProgram(clear->shader_prog); + _mesa_reference_shader_program(&brw->ctx, &clear->shader_prog, NULL); free(clear); if (old_context) diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c index 5b0c2e9bdd5..7e0424846a5 100644 --- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c +++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c @@ -193,6 +193,9 @@ static const char *fs_tmpl = " %s;\n" "}\n"; +#define get_uniform_loc(sh_prog, name) \ + _mesa_program_resource_location(sh_prog, GL_UNIFORM, name) + /** * Setup uniforms telling the coordinates of the destination rectangle in the * native w-tiled space. These are needed to ignore pixels that lie outside. @@ -201,12 +204,13 @@ static const char *fs_tmpl = * 16x2 y-tiled). */ static void -setup_bounding_rect(GLuint prog, const struct blit_dims *dims) +setup_bounding_rect(struct gl_shader_program *sh_prog, + const struct blit_dims *dims) { - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_x0"), dims->dst_x0); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_x1"), dims->dst_x1); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_y0"), dims->dst_y0); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_y1"), dims->dst_y1); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_x0"), dims->dst_x0); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_x1"), dims->dst_x1); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_y0"), dims->dst_y0); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_y1"), dims->dst_y1); } /** @@ -215,14 +219,15 @@ setup_bounding_rect(GLuint prog, const struct blit_dims *dims) * between destination and source that may have differing offsets. */ static void -setup_drawing_rect(GLuint prog, const struct blit_dims *dims) +setup_drawing_rect(struct gl_shader_program *sh_prog, + const struct blit_dims *dims) { - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "draw_rect_w"), + _mesa_Uniform1f(get_uniform_loc(sh_prog, "draw_rect_w"), dims->dst_x1 - dims->dst_x0); - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "draw_rect_h"), + _mesa_Uniform1f(get_uniform_loc(sh_prog, "draw_rect_h"), dims->dst_y1 - dims->dst_y0); - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "dst_x_off"), dims->dst_x0); - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "dst_y_off"), dims->dst_y0); + _mesa_Uniform1f(get_uniform_loc(sh_prog, "dst_x_off"), dims->dst_x0); + _mesa_Uniform1f(get_uniform_loc(sh_prog, "dst_y_off"), dims->dst_y0); } /** @@ -241,7 +246,7 @@ setup_drawing_rect(GLuint prog, const struct blit_dims *dims) * src_x = src_x0 + (dst_x1 -dst_x - 0.5) * scale */ static void -setup_coord_coeff(GLuint prog, GLuint multiplier, GLuint offset, +setup_coord_coeff(GLuint multiplier, GLuint offset, int src_0, int src_1, int dst_0, int dst_1, bool mirror) { const float scale = ((float)(src_1 - src_0)) / (dst_1 - dst_0); @@ -265,22 +270,21 @@ setup_coord_coeff(GLuint prog, GLuint multiplier, GLuint offset, * destination rectangle is adjusted for possible msaa and Y-tiling. */ static void -setup_coord_transform(GLuint prog, const struct blit_dims *dims) +setup_coord_transform(struct gl_shader_program *sh_prog, + const struct blit_dims *dims) { - setup_coord_coeff(prog, - _mesa_GetUniformLocation(prog, "src_x_scale"), - _mesa_GetUniformLocation(prog, "src_x_off"), + setup_coord_coeff(get_uniform_loc(sh_prog, "src_x_scale"), + get_uniform_loc(sh_prog, "src_x_off"), dims->src_x0, dims->src_x1, dims->dst_x0, dims->dst_x1, dims->mirror_x); - setup_coord_coeff(prog, - _mesa_GetUniformLocation(prog, "src_y_scale"), - _mesa_GetUniformLocation(prog, "src_y_off"), + setup_coord_coeff(get_uniform_loc(sh_prog, "src_y_scale"), + get_uniform_loc(sh_prog, "src_y_off"), dims->src_y0, dims->src_y1, dims->dst_y0, dims->dst_y1, dims->mirror_y); } -static GLuint +static struct gl_shader_program * setup_program(struct brw_context *brw, bool msaa_tex) { struct gl_context *ctx = &brw->ctx; @@ -291,21 +295,22 @@ setup_program(struct brw_context *brw, bool msaa_tex) _mesa_meta_setup_vertex_objects(&brw->ctx, &blit->VAO, &blit->buf_obj, true, 2, 2, 0); - GLuint *prog_id = &brw->meta_stencil_blit_programs[msaa_tex]; + struct gl_shader_program **sh_prog_p = + &brw->meta_stencil_blit_programs[msaa_tex]; - if (*prog_id) { - _mesa_UseProgram(*prog_id); - return *prog_id; + if (*sh_prog_p) { + _mesa_meta_use_program(ctx, *sh_prog_p); + return *sh_prog_p; } fs_source = ralloc_asprintf(NULL, fs_tmpl, sampler->sampler, sampler->fetch); _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, "i965 stencil blit", - prog_id); + sh_prog_p); ralloc_free(fs_source); - return *prog_id; + return *sh_prog_p; } /** @@ -425,7 +430,7 @@ brw_meta_stencil_blit(struct brw_context *brw, struct gl_context *ctx = &brw->ctx; struct blit_dims dims = *orig_dims; struct fb_tex_blit_state blit; - GLuint prog; + struct gl_shader_program *prog; struct gl_framebuffer *drawFb = NULL; struct gl_renderbuffer *rb = NULL; GLenum target; @@ -467,7 +472,7 @@ brw_meta_stencil_blit(struct brw_context *brw, setup_drawing_rect(prog, &dims); setup_coord_transform(prog, orig_dims); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_num_samples"), + _mesa_Uniform1i(get_uniform_loc(prog, "dst_num_samples"), dst_mt->num_samples); prepare_vertex_data(ctx, ctx->Meta->Blit.buf_obj); diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index ba9cb3f608c..941920adccd 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -378,7 +378,7 @@ brw_nir_lower_uniforms(nir_shader *nir, bool is_scalar) } void -brw_nir_lower_shared(nir_shader *nir) +brw_nir_lower_cs_shared(nir_shader *nir) { nir_assign_var_locations(&nir->shared, &nir->num_shared, type_size_scalar_bytes); @@ -578,9 +578,6 @@ brw_create_nir(struct brw_context *brw, OPT_V(nir_lower_atomics, shader_prog); } - if (nir->stage == MESA_SHADER_COMPUTE) - OPT_V(brw_nir_lower_shared); - return nir; } diff --git a/src/mesa/drivers/dri/i965/brw_nir.h b/src/mesa/drivers/dri/i965/brw_nir.h index 0ef34735561..440b4ceb669 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.h +++ b/src/mesa/drivers/dri/i965/brw_nir.h @@ -83,7 +83,6 @@ nir_shader *brw_create_nir(struct brw_context *brw, nir_shader *brw_preprocess_nir(nir_shader *nir, bool is_scalar); -void brw_nir_lower_shared(nir_shader *nir); void brw_nir_lower_vs_inputs(nir_shader *nir, const struct brw_device_info *devinfo, bool is_scalar, @@ -96,6 +95,7 @@ void brw_nir_lower_fs_inputs(nir_shader *nir); void brw_nir_lower_vue_outputs(nir_shader *nir, bool is_scalar); void brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue); void brw_nir_lower_fs_outputs(nir_shader *nir); +void brw_nir_lower_cs_shared(nir_shader *nir); nir_shader *brw_postprocess_nir(nir_shader *nir, const struct brw_device_info *devinfo, diff --git a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp index 695c4df258b..c9728bfb694 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_generator.cpp @@ -485,10 +485,13 @@ generate_gs_svb_write(struct brw_codegen *p, bool final_write = inst->sol_final_write; brw_push_insn_state(p); + brw_set_default_exec_size(p, BRW_EXECUTE_4); /* Copy Vertex data into M0.x */ brw_MOV(p, stride(dst, 4, 4, 1), stride(retype(src0, BRW_REGISTER_TYPE_UD), 4, 4, 1)); + brw_pop_insn_state(p); + brw_push_insn_state(p); /* Send SVB Write */ brw_svb_write(p, final_write ? src1 : brw_null_reg(), /* dest == src1 */ @@ -702,8 +705,10 @@ generate_gs_ff_sync(struct brw_codegen *p, brw_MOV(p, get_element_ud(header, 0), get_element_ud(dst, 0)); /* src1 is not an immediate when we use transform feedback */ - if (src1.file != BRW_IMMEDIATE_VALUE) + if (src1.file != BRW_IMMEDIATE_VALUE) { + brw_set_default_exec_size(p, BRW_EXECUTE_4); brw_MOV(p, brw_vec4_grf(src1.nr, 0), brw_vec4_grf(dst.nr, 1)); + } brw_pop_insn_state(p); } @@ -1473,6 +1478,7 @@ generate_code(struct brw_codegen *p, assert(inst->mlen <= BRW_MAX_MSG_LENGTH); unsigned pre_emit_nr_insn = p->nr_insn; + bool fix_exec_size = false; if (dst.width == BRW_WIDTH_4) { /* This happens in attribute fixups for "dual instanced" geometry @@ -1497,6 +1503,8 @@ generate_code(struct brw_codegen *p, if (src[i].file == BRW_GENERAL_REGISTER_FILE) src[i] = stride(src[i], 4, 4, 1); } + brw_set_default_exec_size(p, BRW_EXECUTE_4); + fix_exec_size = true; } switch (inst->opcode) { @@ -1988,6 +1996,9 @@ generate_code(struct brw_codegen *p, unreachable("Unsupported opcode"); } + if (fix_exec_size) + brw_set_default_exec_size(p, BRW_EXECUTE_8); + if (inst->opcode == VEC4_OPCODE_PACK_BYTES) { /* Handled dependency hints in the generator. */ diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 3985457f21a..b90a60ba03f 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -105,6 +105,8 @@ client_state(struct gl_context *ctx, GLenum cap, GLboolean state) case GL_POINT_SIZE_ARRAY_OES: var = &vao->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled; flag = VERT_BIT_POINT_SIZE; + FLUSH_VERTICES(ctx, _NEW_PROGRAM); + ctx->VertexProgram.PointSizeEnabled = state; break; /* GL_NV_primitive_restart */ diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index cdf15b48a0d..32fad56f651 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -959,12 +959,9 @@ shader_source(struct gl_shader *sh, const GLchar *source) /** * Compile a shader. */ -static void -compile_shader(struct gl_context *ctx, GLuint shaderObj) +void +_mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh) { - struct gl_shader *sh; - - sh = _mesa_lookup_shader_err(ctx, shaderObj, "glCompileShader"); if (!sh) return; @@ -1023,12 +1020,9 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj) /** * Link a program's shaders. */ -static void -link_program(struct gl_context *ctx, GLuint program) +void +_mesa_link_program(struct gl_context *ctx, struct gl_shader_program *shProg) { - struct gl_shader_program *shProg; - - shProg = _mesa_lookup_shader_program_err(ctx, program, "glLinkProgram"); if (!shProg) return; @@ -1270,7 +1264,8 @@ _mesa_CompileShader(GLuint shaderObj) GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glCompileShader %u\n", shaderObj); - compile_shader(ctx, shaderObj); + _mesa_compile_shader(ctx, _mesa_lookup_shader_err(ctx, shaderObj, + "glCompileShader")); } @@ -1517,7 +1512,8 @@ _mesa_LinkProgram(GLuint programObj) GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & VERBOSE_API) _mesa_debug(ctx, "glLinkProgram %u\n", programObj); - link_program(ctx, programObj); + _mesa_link_program(ctx, _mesa_lookup_shader_program_err(ctx, programObj, + "glLinkProgram")); } #if defined(HAVE_SHA1) @@ -2154,25 +2150,24 @@ _mesa_CreateShaderProgramv(GLenum type, GLsizei count, } if (shader) { - _mesa_ShaderSource(shader, count, strings, NULL); + struct gl_shader *sh = _mesa_lookup_shader(ctx, shader); - compile_shader(ctx, shader); + _mesa_ShaderSource(shader, count, strings, NULL); + _mesa_compile_shader(ctx, sh); program = create_shader_program(ctx); if (program) { struct gl_shader_program *shProg; - struct gl_shader *sh; GLint compiled = GL_FALSE; shProg = _mesa_lookup_shader_program(ctx, program); - sh = _mesa_lookup_shader(ctx, shader); shProg->SeparateShader = GL_TRUE; get_shaderiv(ctx, shader, GL_COMPILE_STATUS, &compiled); if (compiled) { attach_shader(ctx, program, shader); - link_program(ctx, program); + _mesa_link_program(ctx, shProg); detach_shader(ctx, program, shader); #if 0 diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h index 8922c4d0640..d2d7f16ec7c 100644 --- a/src/mesa/main/shaderapi.h +++ b/src/mesa/main/shaderapi.h @@ -54,6 +54,12 @@ extern void _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg, const char *caller); +extern void +_mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh); + +extern void +_mesa_link_program(struct gl_context *ctx, struct gl_shader_program *sh_prog); + extern unsigned _mesa_count_active_attribs(struct gl_shader_program *shProg); |