Commit 670c4dd3 authored by Marek Olšák's avatar Marek Olšák

mesa: don't flag _NEW_PROGRAM_CONSTANTS for non-GLSL programs for st/mesa

This has the benefit that we get to set up constants for exactly
the shader stage that needs it.
Reviewed-by: default avatarNicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri's avatarTimothy Arceri <tarceri@itsqueeze.com>
parent 0b70d6ec
......@@ -41,6 +41,23 @@
#include "program/program.h"
#include "program/prog_print.h"
static void
flush_vertices_for_program_constants(struct gl_context *ctx, GLenum target)
{
uint64_t new_driver_state;
if (target == GL_FRAGMENT_PROGRAM_ARB) {
new_driver_state =
ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT];
} else {
new_driver_state =
ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX];
}
FLUSH_VERTICES(ctx, new_driver_state ? 0 : _NEW_PROGRAM_CONSTANTS);
ctx->NewDriverState |= new_driver_state;
}
/**
* Bind a program (make it current)
* \note Called from the GL API dispatcher by both glBindProgramNV
......@@ -105,7 +122,8 @@ _mesa_BindProgramARB(GLenum target, GLuint id)
}
/* signal new program (and its new constants) */
FLUSH_VERTICES(ctx, _NEW_PROGRAM | _NEW_PROGRAM_CONSTANTS);
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
flush_vertices_for_program_constants(ctx, target);
/* bind newProg */
if (target == GL_VERTEX_PROGRAM_ARB) {
......@@ -434,7 +452,7 @@ _mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
flush_vertices_for_program_constants(ctx, target);
if (get_env_param_pointer(ctx, "glProgramEnvParameter",
target, index, &param)) {
......@@ -456,7 +474,7 @@ _mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
flush_vertices_for_program_constants(ctx, target);
if (get_env_param_pointer(ctx, "glProgramEnvParameter4fv",
target, index, &param)) {
......@@ -472,7 +490,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
GET_CURRENT_CONTEXT(ctx);
GLfloat * dest;
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
flush_vertices_for_program_constants(ctx, target);
if (count <= 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(count)");
......@@ -539,7 +557,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
GET_CURRENT_CONTEXT(ctx);
GLfloat *param;
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
flush_vertices_for_program_constants(ctx, target);
if (get_local_param_pointer(ctx, "glProgramLocalParameterARB",
target, index, &param)) {
......@@ -565,7 +583,7 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
GET_CURRENT_CONTEXT(ctx);
GLfloat *dest;
FLUSH_VERTICES(ctx, _NEW_PROGRAM_CONSTANTS);
flush_vertices_for_program_constants(ctx, target);
if (count <= 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fv(count)");
......
......@@ -4531,6 +4531,9 @@ struct gl_driver_flags
/** gl_context::ViewportArray */
uint64_t NewViewport;
/** Shader constants (uniforms, program parameters, state constants) */
uint64_t NewShaderConstants[MESA_SHADER_STAGES];
};
struct gl_uniform_buffer_binding
......
......@@ -230,7 +230,12 @@ update_program_constants(struct gl_context *ctx)
const struct gl_program_parameter_list *params =
ctx->FragmentProgram._Current->Parameters;
if (params && params->StateFlags & ctx->NewState) {
new_state |= _NEW_PROGRAM_CONSTANTS;
if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT]) {
ctx->NewDriverState |=
ctx->DriverFlags.NewShaderConstants[MESA_SHADER_FRAGMENT];
} else {
new_state |= _NEW_PROGRAM_CONSTANTS;
}
}
}
......@@ -242,7 +247,12 @@ update_program_constants(struct gl_context *ctx)
const struct gl_program_parameter_list *params =
ctx->VertexProgram._Current->Parameters;
if (params && params->StateFlags & ctx->NewState) {
new_state |= _NEW_PROGRAM_CONSTANTS;
if (ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX]) {
ctx->NewDriverState |=
ctx->DriverFlags.NewShaderConstants[MESA_SHADER_VERTEX];
} else {
new_state |= _NEW_PROGRAM_CONSTANTS;
}
}
}
......
......@@ -486,10 +486,20 @@ static void st_init_driver_flags(struct st_context *st)
f->NewRasterizerDiscard = ST_NEW_RASTERIZER;
f->NewUniformBuffer = ST_NEW_UNIFORM_BUFFER;
f->NewDefaultTessLevels = ST_NEW_TESS_STATE;
/* Shader resources */
f->NewTextureBuffer = ST_NEW_SAMPLER_VIEWS;
f->NewAtomicBuffer = ST_NEW_ATOMIC_BUFFER;
f->NewShaderStorageBuffer = ST_NEW_STORAGE_BUFFER;
f->NewImageUnits = ST_NEW_IMAGE_UNITS;
f->NewShaderConstants[MESA_SHADER_VERTEX] = ST_NEW_VS_CONSTANTS;
f->NewShaderConstants[MESA_SHADER_TESS_CTRL] = ST_NEW_TCS_CONSTANTS;
f->NewShaderConstants[MESA_SHADER_TESS_EVAL] = ST_NEW_TES_CONSTANTS;
f->NewShaderConstants[MESA_SHADER_GEOMETRY] = ST_NEW_GS_CONSTANTS;
f->NewShaderConstants[MESA_SHADER_FRAGMENT] = ST_NEW_FS_CONSTANTS;
f->NewShaderConstants[MESA_SHADER_COMPUTE] = ST_NEW_CS_CONSTANTS;
f->NewWindowRectangles = ST_NEW_WINDOW_RECTANGLES;
f->NewFramebufferSRGB = ST_NEW_FB_STATE;
f->NewScissorRect = ST_NEW_SCISSOR;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment