diff options
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_clear.c | 7 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_drawpixels.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_texture.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 5 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 180 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c | 11 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_program.c | 22 |
9 files changed, 98 insertions, 146 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c index 3b4d28d47..e0cb979f2 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -31,6 +31,8 @@ */ +#include <inttypes.h> /* for PRId64 macro */ + #include "main/imports.h" #include "main/mtypes.h" #include "main/arrayobj.h" @@ -271,7 +273,8 @@ st_bufferobj_data(struct gl_context *ctx, pipe_resource_reference( &st_obj->buffer, NULL ); if (ST_DEBUG & DEBUG_BUFFER) { - debug_printf("Create buffer size %td bind 0x%x\n", size, bind); + debug_printf("Create buffer size %" PRId64 " bind 0x%x\n", + (int64_t) size, bind); } if (size != 0) { diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index 4bfa8d75a..2c1414e48 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -173,6 +173,9 @@ draw_quad(struct st_context *st, return; } + /* Convert Z from [0,1] to [-1,1] range */ + z = z * 2.0f - 1.0f; + /* positions */ vertices[0][0][0] = x0; vertices[0][0][1] = y0; @@ -319,11 +322,11 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers) struct pipe_viewport_state vp; vp.scale[0] = 0.5f * fb_width; vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f); - vp.scale[2] = 1.0f; + vp.scale[2] = 0.5f; vp.scale[3] = 1.0f; vp.translate[0] = 0.5f * fb_width; vp.translate[1] = 0.5f * fb_height; - vp.translate[2] = 0.0f; + vp.translate[2] = 0.5f; vp.translate[3] = 0.0f; cso_set_viewport(st->cso_context, &vp); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 6119cc275..d13a17f50 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -494,22 +494,19 @@ make_texture(struct st_context *st, pipeFormat = st_choose_matching_format(pipe->screen, PIPE_BIND_SAMPLER_VIEW, format, type, unpack->SwapBytes); - if (pipeFormat != PIPE_FORMAT_NONE) { - mformat = st_pipe_format_to_mesa_format(pipeFormat); - baseInternalFormat = _mesa_get_format_base_format(mformat); - } - else { + if (pipeFormat == PIPE_FORMAT_NONE) { /* Use the generic approach. */ GLenum intFormat = internal_format(ctx, format, type); - baseInternalFormat = _mesa_base_tex_format(ctx, intFormat); pipeFormat = st_choose_format(st, intFormat, format, type, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW, FALSE); assert(pipeFormat != PIPE_FORMAT_NONE); - mformat = st_pipe_format_to_mesa_format(pipeFormat); } + mformat = st_pipe_format_to_mesa_format(pipeFormat); + baseInternalFormat = _mesa_get_format_base_format(mformat); + pixels = _mesa_map_pbo_source(ctx, unpack, pixels); if (!pixels) return NULL; diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index aa6b05f0b..c4b2107ba 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -719,6 +719,8 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims, /* From now on, we need the gallium representation of dimensions. */ if (gl_target == GL_TEXTURE_1D_ARRAY) { + zoffset = yoffset; + yoffset = 0; depth = height; height = 1; } diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index aa59fbfa9..7ac484056 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -146,7 +146,7 @@ void st_init_limits(struct st_context *st) c->MaxUniformBlockSize = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, - PIPE_SHADER_CAP_MAX_CONSTS) * 16; + PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE); if (c->MaxUniformBlockSize < 16384) { can_ubo = FALSE; } @@ -194,7 +194,8 @@ void st_init_limits(struct st_context *st) _min(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_ADDRS), MAX_PROGRAM_ADDRESS_REGS); pc->MaxParameters = pc->MaxNativeParameters = - screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_CONSTS); + screen->get_shader_param(screen, sh, + PIPE_SHADER_CAP_MAX_CONST_BUFFER_SIZE) / sizeof(float[4]); pc->MaxUniformComponents = 4 * MIN2(pc->MaxNativeParameters, MAX_UNIFORMS); diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 5ea146547..0290553c6 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1192,7 +1192,7 @@ glsl_to_tgsi_visitor::visit(ir_function *ir) const ir_function_signature *sig; exec_list empty; - sig = ir->matching_signature(NULL, &empty); + sig = ir->matching_signature(NULL, &empty, false); assert(sig); @@ -1354,7 +1354,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) /* Quick peephole: Emit OPCODE_MAD(-a, -b, a) instead of AND(a, NOT(b)) */ - if (ir->operation == ir_binop_logic_and) { + if (!native_integers && ir->operation == ir_binop_logic_and) { if (try_emit_mad_for_and_not(ir, 1)) return; if (try_emit_mad_for_and_not(ir, 0)) @@ -1947,16 +1947,16 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) break; case ir_binop_ubo_load: { - ir_constant *uniform_block = ir->operands[0]->as_constant(); + ir_constant *const_uniform_block = ir->operands[0]->as_constant(); ir_constant *const_offset_ir = ir->operands[1]->as_constant(); unsigned const_offset = const_offset_ir ? const_offset_ir->value.u[0] : 0; + unsigned const_block = const_uniform_block ? const_uniform_block->value.u[0] + 1 : 0; st_src_reg index_reg = get_temp(glsl_type::uint_type); st_src_reg cbuf; cbuf.type = glsl_type::vec4_type->base_type; cbuf.file = PROGRAM_CONSTANT; cbuf.index = 0; - cbuf.index2D = uniform_block->value.u[0] + 1; cbuf.reladdr = NULL; cbuf.negate = 0; @@ -1966,7 +1966,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) /* Constant index into constant buffer */ cbuf.reladdr = NULL; cbuf.index = const_offset / 16; - cbuf.has_index2 = true; } else { /* Relative/variable index into constant buffer */ @@ -1976,6 +1975,20 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg)); } + if (const_uniform_block) { + /* Constant constant buffer */ + cbuf.reladdr2 = NULL; + cbuf.index2D = const_block; + cbuf.has_index2 = true; + } + else { + /* Relative/variable constant buffer */ + cbuf.reladdr2 = ralloc(mem_ctx, st_src_reg); + cbuf.index2D = 1; + memcpy(cbuf.reladdr2, &op[0], sizeof(st_src_reg)); + cbuf.has_index2 = true; + } + cbuf.swizzle = swizzle_for_size(ir->type->vector_elements); cbuf.swizzle += MAKE_SWIZZLE4(const_offset % 16 / 4, const_offset % 16 / 4, @@ -3216,78 +3229,6 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog) _mesa_update_shader_textures_used(v->shader_program, prog); } -static void -set_uniform_initializer(struct gl_context *ctx, void *mem_ctx, - struct gl_shader_program *shader_program, - const char *name, const glsl_type *type, - ir_constant *val) -{ - if (type->is_record()) { - ir_constant *field_constant; - - field_constant = (ir_constant *)val->components.get_head(); - - for (unsigned int i = 0; i < type->length; i++) { - const glsl_type *field_type = type->fields.structure[i].type; - const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name, - type->fields.structure[i].name); - set_uniform_initializer(ctx, mem_ctx, shader_program, field_name, - field_type, field_constant); - field_constant = (ir_constant *)field_constant->next; - } - return; - } - - unsigned offset; - unsigned index = _mesa_get_uniform_location(ctx, shader_program, name, - &offset); - if (offset == GL_INVALID_INDEX) { - fail_link(shader_program, - "Couldn't find uniform for initializer %s\n", name); - return; - } - int loc = _mesa_uniform_merge_location_offset(shader_program, index, offset); - - for (unsigned int i = 0; i < (type->is_array() ? type->length : 1); i++) { - ir_constant *element; - const glsl_type *element_type; - if (type->is_array()) { - element = val->array_elements[i]; - element_type = type->fields.array; - } else { - element = val; - element_type = type; - } - - void *values; - - if (element_type->base_type == GLSL_TYPE_BOOL) { - int *conv = ralloc_array(mem_ctx, int, element_type->components()); - for (unsigned int j = 0; j < element_type->components(); j++) { - conv[j] = element->value.b[j]; - } - values = (void *)conv; - element_type = glsl_type::get_instance(GLSL_TYPE_INT, - element_type->vector_elements, - 1); - } else { - values = &element->value; - } - - if (element_type->is_matrix()) { - _mesa_uniform_matrix(ctx, shader_program, - element_type->matrix_columns, - element_type->vector_elements, - loc, 1, GL_FALSE, (GLfloat *)values); - } else { - _mesa_uniform(ctx, shader_program, loc, element_type->matrix_columns, - values, element_type->gl_type); - } - - loc++; - } -} - /** * Returns the mask of channels (bitmask of WRITEMASK_X,Y,Z,W) which * are read from the given src in this instruction @@ -4225,14 +4166,22 @@ struct st_translate { }; /** Map Mesa's SYSTEM_VALUE_x to TGSI_SEMANTIC_x */ -static unsigned mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = { - TGSI_SEMANTIC_FACE, +const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = { + /* Vertex shader + */ TGSI_SEMANTIC_VERTEXID, TGSI_SEMANTIC_INSTANCEID, + + /* Geometry shader + */ + TGSI_SEMANTIC_INVOCATIONID, + + /* Fragment shader + */ + TGSI_SEMANTIC_FACE, TGSI_SEMANTIC_SAMPLEID, TGSI_SEMANTIC_SAMPLEPOS, TGSI_SEMANTIC_SAMPLEMASK, - TGSI_SEMANTIC_INVOCATIONID, }; /** @@ -4321,9 +4270,8 @@ dst_register(struct st_translate *t, return ureg_dst_undef(); case PROGRAM_TEMPORARY: - assert(index >= 0); - assert(index < (int) Elements(t->temps)); - + assert(index < Elements(t->temps)); + if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_local_temporary(t->ureg); @@ -4332,8 +4280,7 @@ dst_register(struct st_translate *t, case PROGRAM_ARRAY: array = index >> 16; - assert(array >= 0); - assert(array < (int) Elements(t->arrays)); + assert(array < Elements(t->arrays)); if (ureg_dst_is_undef(t->arrays[array])) t->arrays[array] = ureg_DECL_array_temporary( @@ -4367,51 +4314,45 @@ dst_register(struct st_translate *t, * Map a glsl_to_tgsi src register to a TGSI ureg_src register. */ static struct ureg_src -src_register(struct st_translate *t, - gl_register_file file, - GLint index, GLint index2D) +src_register(struct st_translate *t, const struct st_src_reg *reg) { - switch(file) { + switch(reg->file) { case PROGRAM_UNDEFINED: return ureg_src_undef(); case PROGRAM_TEMPORARY: case PROGRAM_ARRAY: - return ureg_src(dst_register(t, file, index)); + return ureg_src(dst_register(t, reg->file, reg->index)); case PROGRAM_UNIFORM: - assert(index >= 0); - return t->constants[index]; + assert(reg->index >= 0); + return t->constants[reg->index]; case PROGRAM_STATE_VAR: case PROGRAM_CONSTANT: /* ie, immediate */ - if (index2D) { - struct ureg_src src; - src = ureg_src_register(TGSI_FILE_CONSTANT, index); - src.Dimension = 1; - src.DimensionIndex = index2D; - return src; - } else if (index < 0) + if (reg->has_index2) + return ureg_src_register(TGSI_FILE_CONSTANT, reg->index); + else if (reg->index < 0) return ureg_DECL_constant(t->ureg, 0); else - return t->constants[index]; + return t->constants[reg->index]; case PROGRAM_IMMEDIATE: - return t->immediates[index]; + return t->immediates[reg->index]; case PROGRAM_INPUT: - assert(t->inputMapping[index] < Elements(t->inputs)); - return t->inputs[t->inputMapping[index]]; + assert(t->inputMapping[reg->index] < Elements(t->inputs)); + return t->inputs[t->inputMapping[reg->index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[index] < Elements(t->outputs)); - return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */ + assert(t->outputMapping[reg->index] < Elements(t->outputs)); + return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */ case PROGRAM_ADDRESS: - return ureg_src(t->address[index]); + return ureg_src(t->address[reg->index]); case PROGRAM_SYSTEM_VALUE: - assert(index < (int) Elements(t->systemValues)); - return t->systemValues[index]; + assert(reg->index < (int) Elements(t->systemValues)); + return t->systemValues[reg->index]; default: assert(!"unknown src register file"); @@ -4472,13 +4413,12 @@ translate_dst(struct st_translate *t, static struct ureg_src translate_src(struct st_translate *t, const st_src_reg *src_reg) { - struct ureg_src src = src_register(t, src_reg->file, src_reg->index, src_reg->index2D); + struct ureg_src src = src_register(t, src_reg); if (src_reg->has_index2) { /* 2D indexes occur with geometry shader inputs (attrib, vertex) * and UBO constant buffers (buffer, position). */ - src = src_register(t, src_reg->file, src_reg->index, src_reg->index2D); if (src_reg->reladdr2) src = ureg_src_dimension_indirect(src, ureg_src(t->address[1]), src_reg->index2D); @@ -4900,6 +4840,21 @@ st_translate_program( assert(numInputs <= Elements(t->inputs)); assert(numOutputs <= Elements(t->outputs)); + assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_FRONT_FACE] == + TGSI_SEMANTIC_FACE); + assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_VERTEX_ID] == + TGSI_SEMANTIC_VERTEXID); + assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_INSTANCE_ID] == + TGSI_SEMANTIC_INSTANCEID); + assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_SAMPLE_ID] == + TGSI_SEMANTIC_SAMPLEID); + assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_SAMPLE_POS] == + TGSI_SEMANTIC_SAMPLEPOS); + assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_SAMPLE_MASK_IN] == + TGSI_SEMANTIC_SAMPLEMASK); + assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_INVOCATION_ID] == + TGSI_SEMANTIC_INVOCATIONID); + t = CALLOC_STRUCT(st_translate); if (!t) { ret = PIPE_ERROR_OUT_OF_MEMORY; @@ -5035,7 +4990,7 @@ st_translate_program( unsigned numSys = 0; for (i = 0; sysInputs; i++) { if (sysInputs & (1 << i)) { - unsigned semName = mesa_sysval_to_semantic[i]; + unsigned semName = _mesa_sysval_to_semantic[i]; t->systemValues[i] = ureg_DECL_system_value(ureg, numSys, semName, 0); if (semName == TGSI_SEMANTIC_INSTANCEID || semName == TGSI_SEMANTIC_VERTEXID) { @@ -5109,8 +5064,7 @@ st_translate_program( unsigned num_ubos = program->shader->NumUniformBlocks; for (i = 0; i < num_ubos; i++) { - unsigned size = - program->shader_program->UniformBlocks[i].UniformBufferSize; + unsigned size = program->shader->UniformBlocks[i].UniformBufferSize; unsigned num_const_vecs = (size + 15) / 16; unsigned first, last; assert(num_const_vecs > 0); diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h index 2e7cb78d5..18f666f5b 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.h @@ -73,6 +73,7 @@ st_translate_stream_output_info(struct glsl_to_tgsi_visitor *glsl_to_tgsi, const GLuint outputMapping[], struct pipe_stream_output_info *so); +extern const unsigned _mesa_sysval_to_semantic[SYSTEM_VALUE_MAX]; #ifdef __cplusplus } diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c index 683cd1cac..26a5f51c7 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -44,6 +44,7 @@ #include "util/u_debug.h" #include "util/u_math.h" #include "util/u_memory.h" +#include "st_glsl_to_tgsi.h" /* for _mesa_sysval_to_semantic */ #define PROGRAM_ANY_CONST ((1 << PROGRAM_STATE_VAR) | \ @@ -96,14 +97,6 @@ struct st_translate { }; -/** Map Mesa's SYSTEM_VALUE_x to TGSI_SEMANTIC_x */ -static unsigned mesa_sysval_to_semantic[SYSTEM_VALUE_MAX] = { - TGSI_SEMANTIC_FACE, - TGSI_SEMANTIC_VERTEXID, - TGSI_SEMANTIC_INSTANCEID -}; - - /** * Make note of a branch to a label in the TGSI code. * After we've emitted all instructions, we'll go over the list @@ -1147,7 +1140,7 @@ st_translate_mesa_program( unsigned numSys = 0; for (i = 0; sysInputs; i++) { if (sysInputs & (1 << i)) { - unsigned semName = mesa_sysval_to_semantic[i]; + unsigned semName = _mesa_sysval_to_semantic[i]; t->systemValues[i] = ureg_DECL_system_value(ureg, numSys, semName, 0); if (semName == TGSI_SEMANTIC_INSTANCEID || semName == TGSI_SEMANTIC_VERTEXID) { diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index 9d7b7c475..fbf8930cb 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -393,13 +393,12 @@ st_translate_vertex_program(struct st_context *st, &vpv->tgsi.stream_output); } - vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi); - if (ST_DEBUG & DEBUG_TGSI) { - tgsi_dump( vpv->tgsi.tokens, 0 ); + tgsi_dump(vpv->tgsi.tokens, 0); debug_printf("\n"); } + vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi); return vpv; fail: @@ -804,15 +803,15 @@ st_translate_fragment_program(struct st_context *st, variant->tgsi.tokens = ureg_get_tokens( ureg, NULL ); ureg_destroy( ureg ); - /* fill in variant */ - variant->driver_shader = pipe->create_fs_state(pipe, &variant->tgsi); - variant->key = *key; - if (ST_DEBUG & DEBUG_TGSI) { - tgsi_dump( variant->tgsi.tokens, 0/*TGSI_DUMP_VERBOSE*/ ); + tgsi_dump(variant->tgsi.tokens, 0/*TGSI_DUMP_VERBOSE*/); debug_printf("\n"); } + /* fill in variant */ + variant->driver_shader = pipe->create_fs_state(pipe, &variant->tgsi); + variant->key = *key; + if (deleteFP) { /* Free the temporary program made above */ struct gl_fragment_program *fp = &stfp->Base; @@ -1173,10 +1172,6 @@ st_translate_geometry_program(struct st_context *st, &stgp->tgsi.stream_output); } - /* fill in new variant */ - gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi); - gpv->key = *key; - if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { _mesa_print_program(&stgp->Base.Base); debug_printf("\n"); @@ -1187,6 +1182,9 @@ st_translate_geometry_program(struct st_context *st, debug_printf("\n"); } + /* fill in new variant */ + gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi); + gpv->key = *key; return gpv; } |