aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c3
-rwxr-xr-xmesalib/src/mesa/drivers/dri/common/dri_util.c2
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.c8
-rw-r--r--mesalib/src/mesa/drivers/dri/common/xmlconfig.h8
-rw-r--r--mesalib/src/mesa/main/compiler.h14
-rw-r--r--mesalib/src/mesa/main/extensions.c1
-rw-r--r--mesalib/src/mesa/main/mtypes.h3
-rw-r--r--mesalib/src/mesa/main/shader_query.cpp24
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp31
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_queryobj.c6
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c11
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp123
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c4
16 files changed, 128 insertions, 126 deletions
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index f313f5645..f1f57297c 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -2592,8 +2592,7 @@ _mesa_meta_setup_texture_coords(GLenum faceTarget,
coord = coords3;
break;
default:
- assert(0);
- unreachable();
+ unreachable("not reached");
}
coord[3] = (float) (slice / 6);
diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c
index f4707c483..f18fac61e 100755
--- a/mesalib/src/mesa/drivers/dri/common/dri_util.c
+++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c
@@ -681,7 +681,7 @@ dri2ReleaseBuffer(__DRIscreen *screen, __DRIbuffer *buffer)
static int
-dri2ConfigQueryb(__DRIscreen *screen, const char *var, bool *val)
+dri2ConfigQueryb(__DRIscreen *screen, const char *var, unsigned char *val)
{
if (!driCheckOption(&screen->optionCache, var, DRI_BOOL))
return -1;
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
index 2639202c4..b129979d2 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c
@@ -312,7 +312,7 @@ strndup(const char *str, size_t size)
#endif /* _WIN32 should be !HAVE_STRNDUP */
/** \brief Parse a value of a given type. */
-static bool parseValue (driOptionValue *v, driOptionType type,
+static unsigned char parseValue (driOptionValue *v, driOptionType type,
const XML_Char *string) {
const XML_Char *tail = NULL;
/* skip leading white-space */
@@ -355,7 +355,7 @@ static bool parseValue (driOptionValue *v, driOptionType type,
}
/** \brief Parse a list of ranges of type info->type. */
-static bool parseRanges (driOptionInfo *info, const XML_Char *string) {
+static unsigned char parseRanges (driOptionInfo *info, const XML_Char *string) {
XML_Char *cp, *range;
uint32_t nRanges, i;
driOptionRange *ranges;
@@ -1030,13 +1030,13 @@ void driDestroyOptionCache (driOptionCache *cache) {
free(cache->values);
}
-bool driCheckOption (const driOptionCache *cache, const char *name,
+unsigned char driCheckOption (const driOptionCache *cache, const char *name,
driOptionType type) {
uint32_t i = findOption (cache, name);
return cache->info[i].name != NULL && cache->info[i].type == type;
}
-bool driQueryOptionb (const driOptionCache *cache, const char *name) {
+unsigned char driQueryOptionb (const driOptionCache *cache, const char *name) {
uint32_t i = findOption (cache, name);
/* make sure the option is defined and has the correct type */
assert (cache->info[i].name != NULL);
diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.h b/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
index 9cb831571..59a67b328 100644
--- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
+++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.h
@@ -30,8 +30,6 @@
#ifndef __XMLCONFIG_H
#define __XMLCONFIG_H
-#include <stdbool.h>
-
#define STRING_CONF_MAXLEN 25
/** \brief Option data types */
@@ -41,7 +39,7 @@ typedef enum driOptionType {
/** \brief Option value */
typedef union driOptionValue {
- bool _bool; /**< \brief Boolean */
+ unsigned char _bool; /**< \brief Boolean */
int _int; /**< \brief Integer or Enum */
float _float; /**< \brief Floating-point */
char *_string; /**< \brief String */
@@ -114,11 +112,11 @@ void driDestroyOptionInfo (driOptionCache *info);
void driDestroyOptionCache (driOptionCache *cache);
/** \brief Check if there exists a certain option */
-bool driCheckOption (const driOptionCache *cache, const char *name,
+unsigned char driCheckOption (const driOptionCache *cache, const char *name,
driOptionType type);
/** \brief Query a boolean option value */
-bool driQueryOptionb (const driOptionCache *cache, const char *name);
+unsigned char driQueryOptionb (const driOptionCache *cache, const char *name);
/** \brief Query an integer option value */
int driQueryOptioni (const driOptionCache *cache, const char *name);
/** \brief Query a floating-point option value */
diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h
index 600691724..79d8740e5 100644
--- a/mesalib/src/mesa/main/compiler.h
+++ b/mesalib/src/mesa/main/compiler.h
@@ -253,15 +253,23 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
* function" warnings.
*/
#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
-#define unreachable() __builtin_unreachable()
+#define unreachable(str) \
+do { \
+ assert(!str); \
+ __builtin_unreachable(); \
+} while (0)
#elif (defined(__clang__) && defined(__has_builtin))
# if __has_builtin(__builtin_unreachable)
-# define unreachable() __builtin_unreachable()
+# define unreachable(str) \
+do { \
+ assert(!str); \
+ __builtin_unreachable(); \
+} while (0)
# endif
#endif
#ifndef unreachable
-#define unreachable()
+#define unreachable(str)
#endif
/*
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 6f2536170..92e3f0d68 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -323,6 +323,7 @@ static const struct extension extension_table[] = {
{ "GL_AMD_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 },
{ "GL_AMD_shader_trinary_minmax", o(dummy_true), GL, 2012 },
{ "GL_AMD_vertex_shader_layer", o(AMD_vertex_shader_layer), GLC, 2012 },
+ { "GL_AMD_vertex_shader_viewport_index", o(AMD_vertex_shader_viewport_index), GLC, 2012 },
{ "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL, 2006 },
{ "GL_APPLE_packed_pixels", o(dummy_true), GLL, 2002 },
{ "GL_APPLE_texture_max_level", o(dummy_true), ES1 | ES2, 2009 },
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index eaf377610..a7126fd55 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2560,7 +2560,7 @@ struct gl_uniform_block
GLuint Binding;
/**
- * Minimum size of a buffer object to back this uniform buffer
+ * Minimum size (in bytes) of a buffer object to back this uniform buffer
* (GL_UNIFORM_BLOCK_DATA_SIZE).
*/
GLuint UniformBufferSize;
@@ -3616,6 +3616,7 @@ struct gl_extensions
GLboolean AMD_performance_monitor;
GLboolean AMD_seamless_cubemap_per_texture;
GLboolean AMD_vertex_shader_layer;
+ GLboolean AMD_vertex_shader_viewport_index;
GLboolean APPLE_object_purgeable;
GLboolean ATI_texture_compression_3dc;
GLboolean ATI_texture_mirror_once;
diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp
index 36d1d9cc0..426774316 100644
--- a/mesalib/src/mesa/main/shader_query.cpp
+++ b/mesalib/src/mesa/main/shader_query.cpp
@@ -126,8 +126,8 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
unsigned current_index = 0;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
if (!is_active_attrib(var))
continue;
@@ -236,8 +236,8 @@ _mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name)
return -1;
exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
/* The extra check against VERT_ATTRIB_GENERIC0 is because
* glGetAttribLocation cannot be used on "conventional" attributes.
@@ -274,8 +274,8 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg)
exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
unsigned i = 0;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
if (!is_active_attrib(var))
continue;
@@ -298,8 +298,8 @@ _mesa_longest_attribute_name_length(struct gl_shader_program *shProg)
exec_list *const ir = shProg->_LinkedShaders[MESA_SHADER_VERTEX]->ir;
size_t longest = 0;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
if (var == NULL
|| var->data.mode != ir_var_shader_in
@@ -400,8 +400,8 @@ _mesa_GetFragDataIndex(GLuint program, const GLchar *name)
return -1;
exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
/* The extra check against FRAG_RESULT_DATA0 is because
* glGetFragDataLocation cannot be used on "conventional" attributes.
@@ -456,8 +456,8 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
return -1;
exec_list *ir = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir;
- foreach_list(node, ir) {
- const ir_variable *const var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, ir) {
+ const ir_variable *const var = node->as_variable();
/* The extra check against FRAG_RESULT_DATA0 is because
* glGetFragDataLocation cannot be used on "conventional" attributes.
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 59cf1232a..1109051e9 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -663,11 +663,7 @@ ir_to_mesa_visitor::get_temp(const glsl_type *type)
variable_storage *
ir_to_mesa_visitor::find_variable_storage(const ir_variable *var)
{
- variable_storage *entry;
-
- foreach_list(node, &this->variables) {
- entry = (variable_storage *) node;
-
+ foreach_in_list(variable_storage, entry, &this->variables) {
if (entry->var == var)
return entry;
}
@@ -801,9 +797,7 @@ ir_to_mesa_visitor::visit(ir_function *ir)
assert(sig);
- foreach_list(node, &sig->body) {
- ir_instruction *ir = (ir_instruction *) node;
-
+ foreach_in_list(ir_instruction, ir, &sig->body) {
ir->accept(this);
}
}
@@ -1868,8 +1862,7 @@ ir_to_mesa_visitor::visit(ir_constant *ir)
src_reg temp_base = get_temp(ir->type);
dst_reg temp = dst_reg(temp_base);
- foreach_list(node, &ir->components) {
- ir_constant *field_value = (ir_constant *) node;
+ foreach_in_list(ir_constant, field_value, &ir->components) {
int size = type_size(field_value->type);
assert(size > 0);
@@ -2338,9 +2331,7 @@ set_branchtargets(ir_to_mesa_visitor *v,
mesa_instructions[loop_stack[loop_stack_pos]].BranchTarget = i;
break;
case OPCODE_CAL:
- foreach_list(n, &v->function_signatures) {
- function_entry *entry = (function_entry *) n;
-
+ foreach_in_list(function_entry, entry, &v->function_signatures) {
if (entry->sig_id == mesa_instructions[i].BranchTarget) {
mesa_instructions[i].BranchTarget = entry->inst;
break;
@@ -2495,8 +2486,8 @@ _mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
{
add_uniform_to_shader add(shader_program, params, sh->Stage);
- foreach_list(node, sh->ir) {
- ir_variable *var = ((ir_instruction *) node)->as_variable();
+ foreach_in_list(ir_instruction, node, sh->ir) {
+ ir_variable *var = node->as_variable();
if ((var == NULL) || (var->data.mode != ir_var_uniform)
|| var->is_in_uniform_block() || (strncmp(var->name, "gl_", 3) == 0))
@@ -2621,9 +2612,7 @@ ir_to_mesa_visitor::copy_propagate(void)
int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4);
int level = 0;
- foreach_list(node, &this->instructions) {
- ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *) node;
-
+ foreach_in_list(ir_to_mesa_instruction, inst, &this->instructions) {
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
@@ -2826,7 +2815,7 @@ get_mesa_program(struct gl_context *ctx,
prog->NumTemporaries = v.next_temp;
int num_instructions = 0;
- foreach_list(node, &v.instructions) {
+ foreach_in_list(ir_instruction, node, &v.instructions) {
num_instructions++;
}
@@ -2842,9 +2831,7 @@ get_mesa_program(struct gl_context *ctx,
*/
mesa_inst = mesa_instructions;
i = 0;
- foreach_list(node, &v.instructions) {
- const ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *) node;
-
+ foreach_in_list(const ir_to_mesa_instruction, inst, &v.instructions) {
mesa_inst->Opcode = inst->op;
mesa_inst->CondUpdate = inst->cond_update;
if (inst->saturate)
diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
index 02624617b..3b4d28d47 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -225,6 +225,9 @@ st_bufferobj_data(struct gl_context *ctx,
case GL_UNIFORM_BUFFER:
bind = PIPE_BIND_CONSTANT_BUFFER;
break;
+ case GL_DRAW_INDIRECT_BUFFER:
+ bind = PIPE_BIND_COMMAND_ARGS_BUFFER;
+ break;
default:
bind = 0;
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 371f7fcda..4bfa8d75a 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -136,7 +136,7 @@ set_vertex_shader_layered(struct st_context *st)
struct pipe_context *pipe = st->pipe;
if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_INSTANCEID) ||
- !pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER)) {
+ !pipe->screen->get_param(pipe->screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT)) {
assert(!"Got layered clear, but the VS layer output is unsupported");
set_vertex_shader(st);
return;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
index 78a737094..489f537d8 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.c
@@ -132,13 +132,13 @@ st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
type == PIPE_QUERY_TIMESTAMP) {
/* Determine time elapsed by emitting two timestamp queries. */
if (!stq->pq_begin) {
- stq->pq_begin = pipe->create_query(pipe, type);
+ stq->pq_begin = pipe->create_query(pipe, type, 0);
stq->type = type;
}
pipe->end_query(pipe, stq->pq_begin);
} else {
if (!stq->pq) {
- stq->pq = pipe->create_query(pipe, type);
+ stq->pq = pipe->create_query(pipe, type, q->Stream);
stq->type = type;
}
if (stq->pq) {
@@ -164,7 +164,7 @@ st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
if ((q->Target == GL_TIMESTAMP ||
q->Target == GL_TIME_ELAPSED) &&
!stq->pq) {
- stq->pq = pipe->create_query(pipe, PIPE_QUERY_TIMESTAMP);
+ stq->pq = pipe->create_query(pipe, PIPE_QUERY_TIMESTAMP, 0);
stq->type = PIPE_QUERY_TIMESTAMP;
}
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index c8189faad..64d6ef525 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -244,6 +244,14 @@ st_draw_vbo(struct gl_context *ctx,
}
}
+ if (indirect) {
+ info.indirect = st_buffer_object(indirect)->buffer;
+
+ /* Primitive restart is not handled by the VBO module in this case. */
+ info.primitive_restart = ctx->Array._PrimitiveRestart;
+ info.restart_index = ctx->Array.RestartIndex;
+ }
+
/* do actual drawing */
for (i = 0; i < nr_prims; i++) {
info.mode = translate_prim(ctx, prims[i].mode);
@@ -256,6 +264,7 @@ st_draw_vbo(struct gl_context *ctx,
info.min_index = info.start;
info.max_index = info.start + info.count - 1;
}
+ info.indirect_offset = prims[i].indirect_offset;
if (ST_DEBUG & DEBUG_DRAW) {
debug_printf("st/draw: mode %s start %u count %u indexed %d\n",
@@ -265,7 +274,7 @@ st_draw_vbo(struct gl_context *ctx,
info.indexed);
}
- if (info.count_from_stream_output) {
+ if (info.count_from_stream_output || info.indirect) {
cso_draw_vbo(st->cso_context, &info);
}
else if (info.primitive_restart) {
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index e93804689..4207cb64a 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -287,6 +287,11 @@ void st_init_limits(struct st_context *st)
screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS);
c->MaxTransformFeedbackInterleavedComponents =
screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS);
+ c->MaxVertexStreams =
+ MAX2(1, screen->get_param(screen, PIPE_CAP_MAX_VERTEX_STREAMS));
+
+ /* The vertex stream must fit into pipe_stream_output_info::stream */
+ assert(c->MaxVertexStreams <= 4);
c->StripTextureBorder = GL_TRUE;
@@ -427,6 +432,7 @@ void st_init_extensions(struct st_context *st)
{ o(ARB_texture_multisample), PIPE_CAP_TEXTURE_MULTISAMPLE },
{ o(ARB_texture_query_lod), PIPE_CAP_TEXTURE_QUERY_LOD },
{ o(ARB_sample_shading), PIPE_CAP_SAMPLE_SHADING },
+ { o(ARB_draw_indirect), PIPE_CAP_DRAW_INDIRECT }
};
/* Required: render target and sampler support */
@@ -618,7 +624,7 @@ void st_init_extensions(struct st_context *st)
/* This extension needs full OpenGL 3.2, but we don't know if that's
* supported at this point. Only check the GLSL version. */
if (ctx->Const.GLSLVersion >= 150 &&
- screen->get_param(screen, PIPE_CAP_TGSI_VS_LAYER)) {
+ screen->get_param(screen, PIPE_CAP_TGSI_VS_LAYER_VIEWPORT)) {
ctx->Extensions.AMD_vertex_shader_layer = GL_TRUE;
}
@@ -809,6 +815,9 @@ void st_init_extensions(struct st_context *st)
ctx->Const.ViewportBounds.Min = -16384.0;
ctx->Const.ViewportBounds.Max = 16384.0;
ctx->Extensions.ARB_viewport_array = GL_TRUE;
+ ctx->Extensions.ARB_fragment_layer_viewport = GL_TRUE;
+ if (ctx->Extensions.AMD_vertex_shader_layer)
+ ctx->Extensions.AMD_vertex_shader_viewport_index = GL_TRUE;
}
}
if (ctx->Const.MaxProgramTextureGatherComponents > 0)
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 cac1e0fe2..9e1943139 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -919,9 +919,7 @@ glsl_to_tgsi_visitor::add_constant(gl_register_file file,
/* Search immediate storage to see if we already have an identical
* immediate that we can use instead of adding a duplicate entry.
*/
- foreach_list(node, &this->immediates) {
- entry = (immediate_storage *) node;
-
+ foreach_in_list(immediate_storage, entry, &this->immediates) {
if (entry->size == size &&
entry->type == datatype &&
!memcmp(entry->values, values, size * sizeof(gl_constant_value))) {
@@ -1061,11 +1059,7 @@ variable_storage *
glsl_to_tgsi_visitor::find_variable_storage(ir_variable *var)
{
- variable_storage *entry;
-
- foreach_list(node, &this->variables) {
- entry = (variable_storage *) node;
-
+ foreach_in_list(variable_storage, entry, &this->variables) {
if (entry->var == var)
return entry;
}
@@ -1202,9 +1196,7 @@ glsl_to_tgsi_visitor::visit(ir_function *ir)
assert(sig);
- foreach_list(node, &sig->body) {
- ir_instruction *ir = (ir_instruction *) node;
-
+ foreach_in_list(ir_instruction, ir, &sig->body) {
ir->accept(this);
}
}
@@ -1971,9 +1963,17 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
assert(ir->type->is_vector() || ir->type->is_scalar());
if (const_offset_ir) {
- index_reg = st_src_reg_for_int(const_offset / 16);
- } else {
- emit(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), op[1], st_src_reg_for_int(4));
+ /* Constant index into constant buffer */
+ cbuf.reladdr = NULL;
+ cbuf.index = const_offset / 16;
+ cbuf.has_index2 = true;
+ }
+ else {
+ /* Relative/variable index into constant buffer */
+ emit(ir, TGSI_OPCODE_USHR, st_dst_reg(index_reg), op[1],
+ st_src_reg_for_int(4));
+ cbuf.reladdr = ralloc(mem_ctx, st_src_reg);
+ memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg));
}
cbuf.swizzle = swizzle_for_size(ir->type->vector_elements);
@@ -1982,9 +1982,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
const_offset % 16 / 4,
const_offset % 16 / 4);
- cbuf.reladdr = ralloc(mem_ctx, st_src_reg);
- memcpy(cbuf.reladdr, &index_reg, sizeof(index_reg));
-
if (ir->type->base_type == GLSL_TYPE_BOOL) {
emit(ir, TGSI_OPCODE_USNE, result_dst, cbuf, st_src_reg_for_int(0));
} else {
@@ -2549,8 +2546,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
st_src_reg temp_base = get_temp(ir->type);
st_dst_reg temp = st_dst_reg(temp_base);
- foreach_list(node, &ir->components) {
- ir_constant *field_value = (ir_constant *) node;
+ foreach_in_list(ir_constant, field_value, &ir->components) {
int size = type_size(field_value->type);
assert(size > 0);
@@ -2664,11 +2660,7 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir)
function_entry *
glsl_to_tgsi_visitor::get_function_signature(ir_function_signature *sig)
{
- function_entry *entry;
-
- foreach_list(node, &this->function_signatures) {
- entry = (function_entry *) node;
-
+ foreach_in_list_use_after(function_entry, entry, &this->function_signatures) {
if (entry->sig == sig)
return entry;
}
@@ -2679,8 +2671,7 @@ glsl_to_tgsi_visitor::get_function_signature(ir_function_signature *sig)
entry->bgn_inst = NULL;
/* Allocate storage for all the parameters. */
- foreach_list(node, &sig->parameters) {
- ir_variable *param = (ir_variable *) node;
+ foreach_in_list(ir_variable, param, &sig->parameters) {
variable_storage *storage;
storage = find_variable_storage(param);
@@ -3139,14 +3130,18 @@ void
glsl_to_tgsi_visitor::visit(ir_emit_vertex *ir)
{
assert(this->prog->Target == GL_GEOMETRY_PROGRAM_NV);
- emit(ir, TGSI_OPCODE_EMIT);
+
+ ir->stream->accept(this);
+ emit(ir, TGSI_OPCODE_EMIT, undef_dst, this->result);
}
void
glsl_to_tgsi_visitor::visit(ir_end_primitive *ir)
{
assert(this->prog->Target == GL_GEOMETRY_PROGRAM_NV);
- emit(ir, TGSI_OPCODE_ENDPRIM);
+
+ ir->stream->accept(this);
+ emit(ir, TGSI_OPCODE_ENDPRIM, undef_dst, this->result);
}
glsl_to_tgsi_visitor::glsl_to_tgsi_visitor()
@@ -3190,9 +3185,7 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog)
{
v->samplers_used = 0;
- foreach_list(node, &v->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &v->instructions) {
if (is_tex_instruction(inst->op)) {
v->samplers_used |= 1 << inst->sampler;
@@ -3336,8 +3329,7 @@ glsl_to_tgsi_visitor::simplify_cmp(void)
memset(tempWrites, 0, sizeof(unsigned) * MAX_TEMPS);
memset(outputWrites, 0, sizeof(outputWrites));
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
unsigned prevWriteMask = 0;
/* Give up if we encounter relative addressing or flow control. */
@@ -3382,8 +3374,7 @@ glsl_to_tgsi_visitor::simplify_cmp(void)
void
glsl_to_tgsi_visitor::rename_temp_register(int index, int new_index)
{
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
unsigned j;
for (j=0; j < num_inst_src_regs(inst->op); j++) {
@@ -3413,9 +3404,7 @@ glsl_to_tgsi_visitor::get_first_temp_read(int index)
int loop_start = -1; /* index of the first active BGNLOOP (if any) */
unsigned i = 0, j;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
for (j=0; j < num_inst_src_regs(inst->op); j++) {
if (inst->src[j].file == PROGRAM_TEMPORARY &&
inst->src[j].index == index) {
@@ -3451,9 +3440,7 @@ glsl_to_tgsi_visitor::get_first_temp_write(int index)
int loop_start = -1; /* index of the first active BGNLOOP (if any) */
int i = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index) {
return (depth == 0) ? i : loop_start;
}
@@ -3480,9 +3467,7 @@ glsl_to_tgsi_visitor::get_last_temp_read(int index)
int last = -1; /* index of last instruction that reads the temporary */
unsigned i = 0, j;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
for (j=0; j < num_inst_src_regs(inst->op); j++) {
if (inst->src[j].file == PROGRAM_TEMPORARY &&
inst->src[j].index == index) {
@@ -3516,9 +3501,7 @@ glsl_to_tgsi_visitor::get_last_temp_write(int index)
int last = -1; /* index of last instruction that writes to the temporary */
int i = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index)
last = (depth == 0) ? i : -2;
@@ -3565,9 +3548,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4);
int level = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
@@ -3761,9 +3742,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
int level = 0;
int removed = 0;
- foreach_list(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) {
assert(inst->dst.file != PROGRAM_TEMPORARY
|| inst->dst.index < this->next_temp);
@@ -3889,9 +3868,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void)
/* Now actually remove the instructions that are completely dead and update
* the writemask of other instructions with dead channels.
*/
- foreach_list_safe(node, &this->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
-
+ foreach_in_list_safe(glsl_to_tgsi_instruction, inst, &this->instructions) {
if (!inst->dead_mask || !inst->dst.writemask)
continue;
else if ((inst->dst.writemask & ~inst->dead_mask) == 0) {
@@ -4077,8 +4054,7 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp,
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
* new visitor. */
- foreach_list(node, &original->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &original->instructions) {
glsl_to_tgsi_instruction *newinst;
st_src_reg src_regs[3];
@@ -4162,8 +4138,7 @@ get_bitmap_visitor(struct st_fragment_program *fp,
/* Now copy the instructions from the original glsl_to_tgsi_visitor into the
* new visitor. */
- foreach_list(node, &original->instructions) {
- glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node;
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &original->instructions) {
glsl_to_tgsi_instruction *newinst;
st_src_reg src_regs[3];
@@ -4396,7 +4371,7 @@ src_register(struct st_translate *t,
case PROGRAM_CONSTANT: /* ie, immediate */
if (index2D) {
struct ureg_src src;
- src = ureg_src_register(TGSI_FILE_CONSTANT, 0);
+ src = ureg_src_register(TGSI_FILE_CONSTANT, index);
src.Dimension = 1;
src.DimensionIndex = index2D;
return src;
@@ -4484,7 +4459,10 @@ 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);
- if (t->procType == TGSI_PROCESSOR_GEOMETRY && src_reg->has_index2) {
+ 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]),
@@ -5115,7 +5093,14 @@ st_translate_program(
unsigned num_ubos = program->shader->NumUniformBlocks;
for (i = 0; i < num_ubos; i++) {
- ureg_DECL_constant2D(t->ureg, 0, program->shader->UniformBlocks[i].UniformBufferSize / 4, i + 1);
+ unsigned size =
+ program->shader_program->UniformBlocks[i].UniformBufferSize;
+ unsigned num_const_vecs = (size + 15) / 16;
+ unsigned first, last;
+ assert(num_const_vecs > 0);
+ first = 0;
+ last = num_const_vecs > 0 ? num_const_vecs - 1 : 0;
+ ureg_DECL_constant2D(t->ureg, first, last, i + 1);
}
}
@@ -5128,8 +5113,7 @@ st_translate_program(
goto out;
}
i = 0;
- foreach_list(node, &program->immediates) {
- immediate_storage *imm = (immediate_storage *) node;
+ foreach_in_list(immediate_storage, imm, &program->immediates) {
assert(i < program->num_immediates);
t->immediates[i++] = emit_immediate(t, imm->values, imm->type, imm->size);
}
@@ -5144,9 +5128,9 @@ st_translate_program(
/* Emit each instruction in turn:
*/
- foreach_list(n, &program->instructions) {
+ foreach_in_list(glsl_to_tgsi_instruction, inst, &program->instructions) {
set_insn_start(t, ureg_get_instruction_number(ureg));
- compile_tgsi_instruction(t, (glsl_to_tgsi_instruction *) n, clamp_color);
+ compile_tgsi_instruction(t, inst, clamp_color);
}
/* Fix up all emitted labels:
@@ -5257,9 +5241,7 @@ get_mesa_program(struct gl_context *ctx,
do {
progress = GL_FALSE;
- foreach_list(node, &v->function_signatures) {
- function_entry *entry = (function_entry *) node;
-
+ foreach_in_list(function_entry, entry, &v->function_signatures) {
if (!entry->bgn_inst) {
v->current_function = entry;
@@ -5524,6 +5506,7 @@ st_translate_stream_output_info(glsl_to_tgsi_visitor *glsl_to_tgsi,
so->output[i].num_components = info->Outputs[i].NumComponents;
so->output[i].output_buffer = info->Outputs[i].OutputBuffer;
so->output[i].dst_offset = info->Outputs[i].DstOffset;
+ so->output[i].stream = info->Outputs[i].StreamId;
}
for (i = 0; i < PIPE_MAX_SO_BUFFERS; i++) {
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 1df411c3b..3570557fe 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -262,6 +262,10 @@ st_prepare_vertex_program(struct gl_context *ctx,
stvp->output_semantic_name[slot] = TGSI_SEMANTIC_LAYER;
stvp->output_semantic_index[slot] = 0;
break;
+ case VARYING_SLOT_VIEWPORT:
+ stvp->output_semantic_name[slot] = TGSI_SEMANTIC_VIEWPORT_INDEX;
+ stvp->output_semantic_index[slot] = 0;
+ break;
case VARYING_SLOT_TEX0:
case VARYING_SLOT_TEX1: