diff options
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_atom_rasterizer.c | 6 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_atom_texture.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c | 8 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_fbo.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_context.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.c | 25 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_extensions.h | 1 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 19 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_manager.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_program.c | 46 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_program.h | 25 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_texture.c | 5 |
12 files changed, 86 insertions, 58 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c index 2bad64334..a2285383e 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/mesalib/src/mesa/state_tracker/st_atom_rasterizer.c @@ -33,6 +33,7 @@ #include "main/macros.h" #include "st_context.h" #include "st_atom.h" +#include "st_program.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" #include "cso_cache/cso_context.h" @@ -171,9 +172,10 @@ static void update_raster_state( struct st_context *st ) raster->sprite_coord_enable |= 1 << i; } } - if (fragProg->Base.InputsRead & VARYING_BIT_PNTC) { + if (!st->needs_texcoord_semantic && + fragProg->Base.InputsRead & VARYING_BIT_PNTC) { raster->sprite_coord_enable |= - 1 << (VARYING_SLOT_PNTC - VARYING_SLOT_TEX0); + 1 << st_get_generic_varying_index(st, VARYING_SLOT_PNTC); } raster->point_quad_rasterization = 1; diff --git a/mesalib/src/mesa/state_tracker/st_atom_texture.c b/mesalib/src/mesa/state_tracker/st_atom_texture.c index ed9a44429..19072ae2f 100644 --- a/mesalib/src/mesa/state_tracker/st_atom_texture.c +++ b/mesalib/src/mesa/state_tracker/st_atom_texture.c @@ -223,7 +223,7 @@ static unsigned last_level(struct st_texture_object *stObj) static unsigned last_layer(struct st_texture_object *stObj) { - if (stObj->base.Immutable) + if (stObj->base.Immutable && stObj->pt->array_size > 1) return MIN2(stObj->base.MinLayer + stObj->base.NumLayers - 1, stObj->pt->array_size - 1); return stObj->pt->array_size - 1; diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c index e0cb979f2..d53602c8b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -246,21 +246,23 @@ st_bufferobj_data(struct gl_context *ctx, /* BufferData */ switch (usage) { case GL_STATIC_DRAW: - case GL_STATIC_READ: case GL_STATIC_COPY: default: pipe_usage = PIPE_USAGE_DEFAULT; break; case GL_DYNAMIC_DRAW: - case GL_DYNAMIC_READ: case GL_DYNAMIC_COPY: pipe_usage = PIPE_USAGE_DYNAMIC; break; case GL_STREAM_DRAW: - case GL_STREAM_READ: case GL_STREAM_COPY: pipe_usage = PIPE_USAGE_STREAM; break; + case GL_STATIC_READ: + case GL_DYNAMIC_READ: + case GL_STREAM_READ: + pipe_usage = PIPE_USAGE_STAGING; + break; } } diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c index 470ab278b..7b6a444e6 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c @@ -451,7 +451,8 @@ st_update_renderbuffer_surface(struct st_context *st, } /* Adjust for texture views */ - if (strb->is_rtt) { + if (strb->is_rtt && resource->array_size > 1 && + strb->Base.TexImage->TexObject->Immutable) { struct gl_texture_object *tex = strb->Base.TexImage->TexObject; first_layer += tex->MinLayer; if (!strb->rtt_layered) diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 768a66790..17235132e 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -242,7 +242,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, /* GL limits and extensions */ st_init_limits(st->pipe->screen, &ctx->Const, &ctx->Extensions); - st_init_extensions(st->pipe->screen, ctx->API, &ctx->Const, + st_init_extensions(st->pipe->screen, &ctx->Const, &ctx->Extensions, &st->options, ctx->Mesa_DXTn); /* Enable shader-based fallbacks for ARB_color_buffer_float if needed. */ diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index c7bc0ca50..5dd827800 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -407,7 +407,6 @@ get_max_samples_for_formats(struct pipe_screen *screen, * Some fine tuning may still be needed. */ void st_init_extensions(struct pipe_screen *screen, - gl_api api, struct gl_constants *consts, struct gl_extensions *extensions, struct st_config_options *options, @@ -715,9 +714,8 @@ void st_init_extensions(struct pipe_screen *screen, #endif } - extensions->NV_primitive_restart = GL_TRUE; - if (!screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) { - consts->PrimitiveRestartInSoftware = GL_TRUE; + if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) { + extensions->NV_primitive_restart = GL_TRUE; } /* ARB_color_buffer_float. */ @@ -844,17 +842,16 @@ void st_init_extensions(struct pipe_screen *screen, consts->DisableVaryingPacking = GL_TRUE; } - if (api == API_OPENGL_CORE) { - consts->MaxViewports = screen->get_param(screen, PIPE_CAP_MAX_VIEWPORTS); - if (consts->MaxViewports >= 16) { - consts->ViewportBounds.Min = -16384.0; - consts->ViewportBounds.Max = 16384.0; - extensions->ARB_viewport_array = GL_TRUE; - extensions->ARB_fragment_layer_viewport = GL_TRUE; - if (extensions->AMD_vertex_shader_layer) - extensions->AMD_vertex_shader_viewport_index = GL_TRUE; - } + consts->MaxViewports = screen->get_param(screen, PIPE_CAP_MAX_VIEWPORTS); + if (consts->MaxViewports >= 16) { + consts->ViewportBounds.Min = -16384.0; + consts->ViewportBounds.Max = 16384.0; + extensions->ARB_viewport_array = GL_TRUE; + extensions->ARB_fragment_layer_viewport = GL_TRUE; + if (extensions->AMD_vertex_shader_layer) + extensions->AMD_vertex_shader_viewport_index = GL_TRUE; } + if (consts->MaxProgramTextureGatherComponents > 0) extensions->ARB_texture_gather = GL_TRUE; diff --git a/mesalib/src/mesa/state_tracker/st_extensions.h b/mesalib/src/mesa/state_tracker/st_extensions.h index 8d2724d67..faff11fd5 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.h +++ b/mesalib/src/mesa/state_tracker/st_extensions.h @@ -38,7 +38,6 @@ extern void st_init_limits(struct pipe_screen *screen, struct gl_extensions *extensions); extern void st_init_extensions(struct pipe_screen *screen, - gl_api api, struct gl_constants *consts, struct gl_extensions *extensions, struct st_config_options *options, 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 b338a9836..a0da9f635 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1072,8 +1072,8 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) if (ir->data.mode == ir_var_uniform && strncmp(ir->name, "gl_", 3) == 0) { unsigned int i; - const ir_state_slot *const slots = ir->state_slots; - assert(ir->state_slots != NULL); + const ir_state_slot *const slots = ir->get_state_slots(); + assert(slots != NULL); /* Check if this statevar's setup in the STATE file exactly * matches how we'll want to reference it as a @@ -1081,7 +1081,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) * temporary storage and hope that it'll get copy-propagated * out. */ - for (i = 0; i < ir->num_state_slots; i++) { + for (i = 0; i < ir->get_num_state_slots(); i++) { if (slots[i].swizzle != SWIZZLE_XYZW) { break; } @@ -1089,7 +1089,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) variable_storage *storage; st_dst_reg dst; - if (i == ir->num_state_slots) { + if (i == ir->get_num_state_slots()) { /* We'll set the index later. */ storage = new(mem_ctx) variable_storage(ir, PROGRAM_STATE_VAR, -1); this->variables.push_tail(storage); @@ -1100,7 +1100,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) * of the type. However, this had better match the number of state * elements that we're going to copy into the new temporary. */ - assert((int) ir->num_state_slots == type_size(ir->type)); + assert((int) ir->get_num_state_slots() == type_size(ir->type)); dst = st_dst_reg(get_temp(ir->type)); @@ -1110,7 +1110,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) } - for (unsigned int i = 0; i < ir->num_state_slots; i++) { + for (unsigned int i = 0; i < ir->get_num_state_slots(); i++) { int index = _mesa_add_state_reference(this->prog->Parameters, (gl_state_index *)slots[i].tokens); @@ -1135,7 +1135,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir) } if (storage->file == PROGRAM_TEMPORARY && - dst.index != storage->index + (int) ir->num_state_slots) { + dst.index != storage->index + (int) ir->get_num_state_slots()) { fail_link(this->shader_program, "failed to load builtin uniform `%s' (%d/%d regs loaded)\n", ir->name, dst.index - storage->index, @@ -2617,10 +2617,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir) case GLSL_TYPE_BOOL: gl_type = native_integers ? GL_BOOL : GL_FLOAT; for (i = 0; i < ir->type->vector_elements; i++) { - if (native_integers) - values[i].u = ir->value.b[i] ? ~0 : 0; - else - values[i].f = ir->value.b[i]; + values[i].u = ir->value.b[i] ? ctx->Const.UniformBooleanTrue : 0; } break; default: diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index 7bc33268e..df6de737f 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -928,7 +928,7 @@ static unsigned get_version(struct pipe_screen *screen, _mesa_init_extensions(&extensions); st_init_limits(screen, &consts, &extensions); - st_init_extensions(screen, api, &consts, &extensions, options, GL_TRUE); + st_init_extensions(screen, &consts, &extensions, options, GL_TRUE); return _mesa_get_version(&extensions, &consts, api); } diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index fbf8930cb..926086bf8 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -275,17 +275,18 @@ st_prepare_vertex_program(struct gl_context *ctx, case VARYING_SLOT_TEX5: case VARYING_SLOT_TEX6: case VARYING_SLOT_TEX7: - stvp->output_semantic_name[slot] = st->needs_texcoord_semantic ? - TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC; - stvp->output_semantic_index[slot] = attr - VARYING_SLOT_TEX0; - break; - + if (st->needs_texcoord_semantic) { + stvp->output_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD; + stvp->output_semantic_index[slot] = attr - VARYING_SLOT_TEX0; + break; + } + /* fall through */ case VARYING_SLOT_VAR0: default: assert(attr < VARYING_SLOT_MAX); stvp->output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - stvp->output_semantic_index[slot] = st->needs_texcoord_semantic ? - (attr - VARYING_SLOT_VAR0) : (attr - VARYING_SLOT_TEX0); + stvp->output_semantic_index[slot] = + st_get_generic_varying_index(st, attr); break; } } @@ -655,9 +656,8 @@ st_translate_fragment_program(struct st_context *st, * the user varyings on VAR0. Otherwise, we use TEX0 as base index. */ assert(attr >= VARYING_SLOT_TEX0); - input_semantic_index[slot] = st->needs_texcoord_semantic ? - (attr - VARYING_SLOT_VAR0) : (attr - VARYING_SLOT_TEX0); input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + input_semantic_index[slot] = st_get_generic_varying_index(st, attr); if (attr == VARYING_SLOT_PNTC) interpMode[slot] = TGSI_INTERPOLATE_LINEAR; else @@ -974,16 +974,18 @@ st_translate_geometry_program(struct st_context *st, case VARYING_SLOT_TEX5: case VARYING_SLOT_TEX6: case VARYING_SLOT_TEX7: - stgp->input_semantic_name[slot] = st->needs_texcoord_semantic ? - TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC; - stgp->input_semantic_index[slot] = (attr - VARYING_SLOT_TEX0); - break; + if (st->needs_texcoord_semantic) { + stgp->input_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD; + stgp->input_semantic_index[slot] = attr - VARYING_SLOT_TEX0; + break; + } + /* fall through */ case VARYING_SLOT_VAR0: default: assert(attr >= VARYING_SLOT_VAR0 && attr < VARYING_SLOT_MAX); stgp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - stgp->input_semantic_index[slot] = st->needs_texcoord_semantic ? - (attr - VARYING_SLOT_VAR0) : (attr - VARYING_SLOT_TEX0); + stgp->input_semantic_index[slot] = + st_get_generic_varying_index(st, attr); break; } } @@ -1069,17 +1071,19 @@ st_translate_geometry_program(struct st_context *st, case VARYING_SLOT_TEX5: case VARYING_SLOT_TEX6: case VARYING_SLOT_TEX7: - gs_output_semantic_name[slot] = st->needs_texcoord_semantic ? - TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC; - gs_output_semantic_index[slot] = (attr - VARYING_SLOT_TEX0); - break; + if (st->needs_texcoord_semantic) { + gs_output_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD; + gs_output_semantic_index[slot] = attr - VARYING_SLOT_TEX0; + break; + } + /* fall through */ case VARYING_SLOT_VAR0: default: assert(slot < Elements(gs_output_semantic_name)); assert(attr >= VARYING_SLOT_VAR0); gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - gs_output_semantic_index[slot] = st->needs_texcoord_semantic ? - (attr - VARYING_SLOT_VAR0) : (attr - VARYING_SLOT_TEX0); + gs_output_semantic_index[slot] = + st_get_generic_varying_index(st, attr); break; } } diff --git a/mesalib/src/mesa/state_tracker/st_program.h b/mesalib/src/mesa/state_tracker/st_program.h index 9a5b6a847..cf1b40a55 100644 --- a/mesalib/src/mesa/state_tracker/st_program.h +++ b/mesalib/src/mesa/state_tracker/st_program.h @@ -270,6 +270,31 @@ st_reference_fragprog(struct st_context *st, (struct gl_program *) prog); } +/** + * This defines mapping from Mesa VARYING_SLOTs to TGSI GENERIC slots. + */ +static INLINE unsigned +st_get_generic_varying_index(struct st_context *st, GLuint attr) +{ + if (attr >= VARYING_SLOT_VAR0) { + if (st->needs_texcoord_semantic) + return attr - VARYING_SLOT_VAR0; + else + return 9 + (attr - VARYING_SLOT_VAR0); + } + if (attr == VARYING_SLOT_PNTC) { + assert(!st->needs_texcoord_semantic); + return 8; + } + if (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) { + assert(!st->needs_texcoord_semantic); + return attr - VARYING_SLOT_TEX0; + } + + assert(0); + return 0; +} + extern struct st_vp_variant * st_get_vp_variant(struct st_context *st, diff --git a/mesalib/src/mesa/state_tracker/st_texture.c b/mesalib/src/mesa/state_tracker/st_texture.c index c84aa4566..5996b7d1b 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.c +++ b/mesalib/src/mesa/state_tracker/st_texture.c @@ -88,7 +88,7 @@ st_texture_create(struct st_context *st, pt.width0 = width0; pt.height0 = height0; pt.depth0 = depth0; - pt.array_size = (target == PIPE_TEXTURE_CUBE ? 6 : layers); + pt.array_size = layers; pt.usage = PIPE_USAGE_DEFAULT; pt.bind = bind; pt.flags = 0; @@ -263,7 +263,8 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage, if (stObj->base.Immutable) { level += stObj->base.MinLevel; z += stObj->base.MinLayer; - d = MIN2(d, stObj->base.NumLayers); + if (stObj->pt->array_size > 1) + d = MIN2(d, stObj->base.NumLayers); } z += stImage->base.Face; |