aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/program
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/program')
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp3
-rw-r--r--mesalib/src/mesa/program/prog_cache.c11
-rw-r--r--mesalib/src/mesa/program/prog_statevars.c8
-rw-r--r--mesalib/src/mesa/program/register_allocate.c31
-rw-r--r--mesalib/src/mesa/program/register_allocate.h1
5 files changed, 47 insertions, 7 deletions
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 2cb5f02f4..14cf5baa7 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -2048,6 +2048,9 @@ ir_to_mesa_visitor::visit(ir_texture *ir)
case ir_txf_ms:
assert(!"Unexpected ir_txf_ms opcode");
break;
+ case ir_lod:
+ assert(!"Unexpected ir_lod opcode");
+ break;
}
const glsl_type *sampler_type = ir->sampler->type;
diff --git a/mesalib/src/mesa/program/prog_cache.c b/mesalib/src/mesa/program/prog_cache.c
index 47f926b1b..1f1c6142d 100644
--- a/mesalib/src/mesa/program/prog_cache.c
+++ b/mesalib/src/mesa/program/prog_cache.c
@@ -37,6 +37,7 @@
struct cache_item
{
GLuint hash;
+ unsigned keysize;
void *key;
struct gl_program *program;
struct cache_item *next;
@@ -174,7 +175,8 @@ struct gl_program *
_mesa_search_program_cache(struct gl_program_cache *cache,
const void *key, GLuint keysize)
{
- if (cache->last &&
+ if (cache->last &&
+ cache->last->keysize == keysize &&
memcmp(cache->last->key, key, keysize) == 0) {
return cache->last->program;
}
@@ -183,7 +185,10 @@ _mesa_search_program_cache(struct gl_program_cache *cache,
struct cache_item *c;
for (c = cache->items[hash % cache->size]; c; c = c->next) {
- if (c->hash == hash && memcmp(c->key, key, keysize) == 0) {
+ if (c->hash == hash &&
+ c->keysize == keysize &&
+ memcmp(c->key, key, keysize) == 0) {
+
cache->last = c;
return c->program;
}
@@ -207,6 +212,7 @@ _mesa_program_cache_insert(struct gl_context *ctx,
c->key = malloc(keysize);
memcpy(c->key, key, keysize);
+ c->keysize = keysize;
c->program = program; /* no refcount change */
@@ -235,6 +241,7 @@ _mesa_shader_cache_insert(struct gl_context *ctx,
c->key = malloc(keysize);
memcpy(c->key, key, keysize);
+ c->keysize = keysize;
c->program = (struct gl_program *)program; /* no refcount change */
diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c
index 5a350798c..09d2a568a 100644
--- a/mesalib/src/mesa/program/prog_statevars.c
+++ b/mesalib/src/mesa/program/prog_statevars.c
@@ -31,6 +31,7 @@
#include "main/glheader.h"
#include "main/context.h"
+#include "main/blend.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mtypes.h"
@@ -239,14 +240,14 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
{
/* state[1] is the texture unit */
const GLuint unit = (GLuint) state[1];
- if(ctx->Color._ClampFragmentColor)
+ if (_mesa_get_clamp_fragment_color(ctx))
COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
else
COPY_4V(value, ctx->Texture.Unit[unit].EnvColorUnclamped);
}
return;
case STATE_FOG_COLOR:
- if(ctx->Color._ClampFragmentColor)
+ if (_mesa_get_clamp_fragment_color(ctx))
COPY_4V(value, ctx->Fog.Color);
else
COPY_4V(value, ctx->Fog.ColorUnclamped);
@@ -871,6 +872,9 @@ append_token(char *dst, gl_state_index k)
case STATE_CURRENT_ATTRIB:
append(dst, "current");
break;
+ case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED:
+ append(dst, "currentAttribMaybeVPClamped");
+ break;
case STATE_NORMAL_SCALE:
append(dst, "normalScale");
break;
diff --git a/mesalib/src/mesa/program/register_allocate.c b/mesalib/src/mesa/program/register_allocate.c
index a9064c38c..2c826fc66 100644
--- a/mesalib/src/mesa/program/register_allocate.c
+++ b/mesalib/src/mesa/program/register_allocate.c
@@ -70,6 +70,7 @@
* this during ra_set_finalize().
*/
+#include <stdbool.h>
#include <ralloc.h>
#include "main/imports.h"
@@ -93,6 +94,8 @@ struct ra_regs {
struct ra_class **classes;
unsigned int class_count;
+
+ bool round_robin;
};
struct ra_class {
@@ -185,6 +188,22 @@ ra_alloc_reg_set(void *mem_ctx, unsigned int count)
return regs;
}
+/**
+ * The register allocator by default prefers to allocate low register numbers,
+ * since it was written for hardware (gen4/5 Intel) that is limited in its
+ * multithreadedness by the number of registers used in a given shader.
+ *
+ * However, for hardware without that restriction, densely packed register
+ * allocation can put serious constraints on instruction scheduling. This
+ * function tells the allocator to rotate around the registers if possible as
+ * it allocates the nodes.
+ */
+void
+ra_set_allocate_round_robin(struct ra_regs *regs)
+{
+ regs->round_robin = true;
+}
+
static void
ra_add_conflict_list(struct ra_regs *regs, unsigned int r1, unsigned int r2)
{
@@ -436,16 +455,19 @@ GLboolean
ra_select(struct ra_graph *g)
{
int i;
+ int start_search_reg = 0;
while (g->stack_count != 0) {
- unsigned int r;
+ unsigned int ri;
+ unsigned int r = -1;
int n = g->stack[g->stack_count - 1];
struct ra_class *c = g->regs->classes[g->nodes[n].class];
/* Find the lowest-numbered reg which is not used by a member
* of the graph adjacent to us.
*/
- for (r = 0; r < g->regs->count; r++) {
+ for (ri = 0; ri < g->regs->count; ri++) {
+ r = (start_search_reg + ri) % g->regs->count;
if (!c->regs[r])
continue;
@@ -461,12 +483,15 @@ ra_select(struct ra_graph *g)
if (i == g->nodes[n].adjacency_count)
break;
}
- if (r == g->regs->count)
+ if (ri == g->regs->count)
return GL_FALSE;
g->nodes[n].reg = r;
g->nodes[n].in_stack = GL_FALSE;
g->stack_count--;
+
+ if (g->regs->round_robin)
+ start_search_reg = r + 1;
}
return GL_TRUE;
diff --git a/mesalib/src/mesa/program/register_allocate.h b/mesalib/src/mesa/program/register_allocate.h
index 2a9d61191..fa119e320 100644
--- a/mesalib/src/mesa/program/register_allocate.h
+++ b/mesalib/src/mesa/program/register_allocate.h
@@ -37,6 +37,7 @@ struct ra_regs;
* two real registers from which they are composed.
*/
struct ra_regs *ra_alloc_reg_set(void *mem_ctx, unsigned int count);
+void ra_set_allocate_round_robin(struct ra_regs *regs);
unsigned int ra_alloc_reg_class(struct ra_regs *regs);
void ra_add_reg_conflict(struct ra_regs *regs,
unsigned int r1, unsigned int r2);