mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 07:00:12 +01:00
mesa: renumber shader indices according to their placement in pipeline
See my explanation in mtypes.h. v2: don't do this in gallium v3: also updated the comment at the gl_shader_type definition Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
parent
84f367e69a
commit
030ca230e2
9 changed files with 32 additions and 44 deletions
|
|
@ -1514,31 +1514,31 @@ static bool
|
||||||
check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
|
check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
static const char *const shader_names[MESA_SHADER_TYPES] = {
|
static const char *const shader_names[MESA_SHADER_TYPES] = {
|
||||||
"vertex", "fragment", "geometry"
|
"vertex", "geometry", "fragment"
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned max_samplers[MESA_SHADER_TYPES] = {
|
const unsigned max_samplers[MESA_SHADER_TYPES] = {
|
||||||
ctx->Const.VertexProgram.MaxTextureImageUnits,
|
ctx->Const.VertexProgram.MaxTextureImageUnits,
|
||||||
ctx->Const.FragmentProgram.MaxTextureImageUnits,
|
ctx->Const.GeometryProgram.MaxTextureImageUnits,
|
||||||
ctx->Const.GeometryProgram.MaxTextureImageUnits
|
ctx->Const.FragmentProgram.MaxTextureImageUnits
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned max_default_uniform_components[MESA_SHADER_TYPES] = {
|
const unsigned max_default_uniform_components[MESA_SHADER_TYPES] = {
|
||||||
ctx->Const.VertexProgram.MaxUniformComponents,
|
ctx->Const.VertexProgram.MaxUniformComponents,
|
||||||
ctx->Const.FragmentProgram.MaxUniformComponents,
|
ctx->Const.GeometryProgram.MaxUniformComponents,
|
||||||
ctx->Const.GeometryProgram.MaxUniformComponents
|
ctx->Const.FragmentProgram.MaxUniformComponents
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned max_combined_uniform_components[MESA_SHADER_TYPES] = {
|
const unsigned max_combined_uniform_components[MESA_SHADER_TYPES] = {
|
||||||
ctx->Const.VertexProgram.MaxCombinedUniformComponents,
|
ctx->Const.VertexProgram.MaxCombinedUniformComponents,
|
||||||
ctx->Const.FragmentProgram.MaxCombinedUniformComponents,
|
ctx->Const.GeometryProgram.MaxCombinedUniformComponents,
|
||||||
ctx->Const.GeometryProgram.MaxCombinedUniformComponents
|
ctx->Const.FragmentProgram.MaxCombinedUniformComponents
|
||||||
};
|
};
|
||||||
|
|
||||||
const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
|
const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = {
|
||||||
ctx->Const.VertexProgram.MaxUniformBlocks,
|
ctx->Const.VertexProgram.MaxUniformBlocks,
|
||||||
ctx->Const.FragmentProgram.MaxUniformBlocks,
|
|
||||||
ctx->Const.GeometryProgram.MaxUniformBlocks,
|
ctx->Const.GeometryProgram.MaxUniformBlocks,
|
||||||
|
ctx->Const.FragmentProgram.MaxUniformBlocks
|
||||||
};
|
};
|
||||||
|
|
||||||
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
|
for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
|
||||||
|
|
|
||||||
|
|
@ -117,17 +117,13 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
|
||||||
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
|
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
|
||||||
struct brw_shader *shader =
|
struct brw_shader *shader =
|
||||||
(struct brw_shader *)shProg->_LinkedShaders[stage];
|
(struct brw_shader *)shProg->_LinkedShaders[stage];
|
||||||
static const GLenum targets[] = {
|
|
||||||
GL_VERTEX_PROGRAM_ARB,
|
|
||||||
GL_FRAGMENT_PROGRAM_ARB,
|
|
||||||
GL_GEOMETRY_PROGRAM_NV
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!shader)
|
if (!shader)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
struct gl_program *prog =
|
struct gl_program *prog =
|
||||||
ctx->Driver.NewProgram(ctx, targets[stage], shader->base.Name);
|
ctx->Driver.NewProgram(ctx, _mesa_program_index_to_target(stage),
|
||||||
|
shader->base.Name);
|
||||||
if (!prog)
|
if (!prog)
|
||||||
return false;
|
return false;
|
||||||
prog->Parameters = _mesa_new_parameter_list();
|
prog->Parameters = _mesa_new_parameter_list();
|
||||||
|
|
|
||||||
|
|
@ -2173,13 +2173,16 @@ struct gl_shader
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shader stages. Note that these will become 5 with tessellation.
|
* Shader stages. Note that these will become 5 with tessellation.
|
||||||
* These MUST have the same values as gallium's PIPE_SHADER_*
|
*
|
||||||
|
* The order must match how shaders are ordered in the pipeline.
|
||||||
|
* The GLSL linker assumes that if i<j, then the j-th shader is
|
||||||
|
* executed later than the i-th shader.
|
||||||
*/
|
*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
MESA_SHADER_VERTEX = 0,
|
MESA_SHADER_VERTEX = 0,
|
||||||
MESA_SHADER_FRAGMENT = 1,
|
MESA_SHADER_GEOMETRY = 1,
|
||||||
MESA_SHADER_GEOMETRY = 2,
|
MESA_SHADER_FRAGMENT = 2,
|
||||||
MESA_SHADER_TYPES = 3
|
MESA_SHADER_TYPES = 3
|
||||||
} gl_shader_type;
|
} gl_shader_type;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,8 +123,8 @@ _mesa_shader_index_to_type(GLuint i)
|
||||||
{
|
{
|
||||||
static const GLenum enums[MESA_SHADER_TYPES] = {
|
static const GLenum enums[MESA_SHADER_TYPES] = {
|
||||||
GL_VERTEX_SHADER,
|
GL_VERTEX_SHADER,
|
||||||
GL_FRAGMENT_SHADER,
|
GL_GEOMETRY_SHADER,
|
||||||
GL_GEOMETRY_SHADER ,
|
GL_FRAGMENT_SHADER
|
||||||
};
|
};
|
||||||
if (i >= MESA_SHADER_TYPES)
|
if (i >= MESA_SHADER_TYPES)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -3073,12 +3073,6 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||||
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
|
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
|
||||||
|
|
||||||
if (linked_prog) {
|
if (linked_prog) {
|
||||||
static const GLenum targets[] = {
|
|
||||||
GL_VERTEX_PROGRAM_ARB,
|
|
||||||
GL_FRAGMENT_PROGRAM_ARB,
|
|
||||||
GL_GEOMETRY_PROGRAM_NV
|
|
||||||
};
|
|
||||||
|
|
||||||
if (i == MESA_SHADER_VERTEX) {
|
if (i == MESA_SHADER_VERTEX) {
|
||||||
((struct gl_vertex_program *)linked_prog)->UsesClipDistance
|
((struct gl_vertex_program *)linked_prog)->UsesClipDistance
|
||||||
= prog->Vert.UsesClipDistance;
|
= prog->Vert.UsesClipDistance;
|
||||||
|
|
@ -3086,7 +3080,9 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||||
|
|
||||||
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||||
linked_prog);
|
linked_prog);
|
||||||
if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
|
if (!ctx->Driver.ProgramStringNotify(ctx,
|
||||||
|
_mesa_program_index_to_target(i),
|
||||||
|
linked_prog)) {
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -205,8 +205,8 @@ _mesa_program_index_to_target(GLuint i)
|
||||||
{
|
{
|
||||||
static const GLenum enums[MESA_SHADER_TYPES] = {
|
static const GLenum enums[MESA_SHADER_TYPES] = {
|
||||||
GL_VERTEX_PROGRAM_ARB,
|
GL_VERTEX_PROGRAM_ARB,
|
||||||
GL_FRAGMENT_PROGRAM_ARB,
|
|
||||||
GL_GEOMETRY_PROGRAM_NV,
|
GL_GEOMETRY_PROGRAM_NV,
|
||||||
|
GL_FRAGMENT_PROGRAM_ARB
|
||||||
};
|
};
|
||||||
if(i >= MESA_SHADER_TYPES)
|
if(i >= MESA_SHADER_TYPES)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -221,11 +221,6 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
|
||||||
struct gl_context *shareCtx = share ? share->ctx : NULL;
|
struct gl_context *shareCtx = share ? share->ctx : NULL;
|
||||||
struct dd_function_table funcs;
|
struct dd_function_table funcs;
|
||||||
|
|
||||||
/* Sanity checks */
|
|
||||||
STATIC_ASSERT(MESA_SHADER_VERTEX == PIPE_SHADER_VERTEX);
|
|
||||||
STATIC_ASSERT(MESA_SHADER_FRAGMENT == PIPE_SHADER_FRAGMENT);
|
|
||||||
STATIC_ASSERT(MESA_SHADER_GEOMETRY == PIPE_SHADER_GEOMETRY);
|
|
||||||
|
|
||||||
memset(&funcs, 0, sizeof(funcs));
|
memset(&funcs, 0, sizeof(funcs));
|
||||||
st_init_driver_functions(&funcs);
|
st_init_driver_functions(&funcs);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ void st_init_limits(struct st_context *st)
|
||||||
{
|
{
|
||||||
struct pipe_screen *screen = st->pipe->screen;
|
struct pipe_screen *screen = st->pipe->screen;
|
||||||
struct gl_constants *c = &st->ctx->Const;
|
struct gl_constants *c = &st->ctx->Const;
|
||||||
gl_shader_type sh;
|
unsigned sh;
|
||||||
boolean can_ubo = TRUE;
|
boolean can_ubo = TRUE;
|
||||||
|
|
||||||
c->MaxTextureLevels
|
c->MaxTextureLevels
|
||||||
|
|
@ -149,23 +149,25 @@ void st_init_limits(struct st_context *st)
|
||||||
can_ubo = FALSE;
|
can_ubo = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (sh = 0; sh < MESA_SHADER_TYPES; ++sh) {
|
for (sh = 0; sh < PIPE_SHADER_TYPES; ++sh) {
|
||||||
struct gl_shader_compiler_options *options =
|
struct gl_shader_compiler_options *options;
|
||||||
&st->ctx->ShaderCompilerOptions[sh];
|
|
||||||
struct gl_program_constants *pc;
|
struct gl_program_constants *pc;
|
||||||
|
|
||||||
switch (sh) {
|
switch (sh) {
|
||||||
case PIPE_SHADER_FRAGMENT:
|
case PIPE_SHADER_FRAGMENT:
|
||||||
pc = &c->FragmentProgram;
|
pc = &c->FragmentProgram;
|
||||||
|
options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_FRAGMENT];
|
||||||
break;
|
break;
|
||||||
case PIPE_SHADER_VERTEX:
|
case PIPE_SHADER_VERTEX:
|
||||||
pc = &c->VertexProgram;
|
pc = &c->VertexProgram;
|
||||||
|
options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX];
|
||||||
break;
|
break;
|
||||||
case PIPE_SHADER_GEOMETRY:
|
case PIPE_SHADER_GEOMETRY:
|
||||||
pc = &c->GeometryProgram;
|
pc = &c->GeometryProgram;
|
||||||
|
options = &st->ctx->ShaderCompilerOptions[MESA_SHADER_GEOMETRY];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
/* compute shader, etc. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5271,15 +5271,11 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
||||||
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
|
linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
|
||||||
|
|
||||||
if (linked_prog) {
|
if (linked_prog) {
|
||||||
static const GLenum targets[] = {
|
|
||||||
GL_VERTEX_PROGRAM_ARB,
|
|
||||||
GL_FRAGMENT_PROGRAM_ARB,
|
|
||||||
GL_GEOMETRY_PROGRAM_NV
|
|
||||||
};
|
|
||||||
|
|
||||||
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||||
linked_prog);
|
linked_prog);
|
||||||
if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
|
if (!ctx->Driver.ProgramStringNotify(ctx,
|
||||||
|
_mesa_program_index_to_target(i),
|
||||||
|
linked_prog)) {
|
||||||
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
_mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
|
||||||
NULL);
|
NULL);
|
||||||
_mesa_reference_program(ctx, &linked_prog, NULL);
|
_mesa_reference_program(ctx, &linked_prog, NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue