Use ctx->XXProgram._Current instead of the st_context variables.
v2: split from a bigger commit
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19859>
/* vertex program validation must be done before this */
/* _NEW_PROGRAM, ST_NEW_VS_STATE */
- const struct gl_vertex_program *vp = (struct gl_vertex_program *)st->vp;
+ const struct gl_vertex_program *vp =
+ (struct gl_vertex_program *)ctx->VertexProgram._Current;
const struct st_common_variant *vp_variant = st->vp_variant;
struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
shader_type == PIPE_SHADER_COMPUTE);
/* update the ATI constants before rendering */
- if (shader_type == PIPE_SHADER_FRAGMENT && st->fp->ati_fs) {
- struct ati_fragment_shader *ati_fs = st->fp->ati_fs;
+ if (shader_type == PIPE_SHADER_FRAGMENT && prog->ati_fs) {
+ struct ati_fragment_shader *ati_fs = prog->ati_fs;
unsigned c;
for (c = 0; c < MAX_NUM_FRAGMENT_CONSTANTS_ATI; c++) {
void
st_update_vs_constants(struct st_context *st)
{
- st_upload_constants(st, st->vp, MESA_SHADER_VERTEX);
+ st_upload_constants(st, st->ctx->VertexProgram._Current,
+ MESA_SHADER_VERTEX);
}
/**
void
st_update_fs_constants(struct st_context *st)
{
- st_upload_constants(st, st->fp, MESA_SHADER_FRAGMENT);
+ st_upload_constants(st, st->ctx->FragmentProgram._Current,
+ MESA_SHADER_FRAGMENT);
}
void
st_update_gs_constants(struct st_context *st)
{
- st_upload_constants(st, st->gp, MESA_SHADER_GEOMETRY);
+ st_upload_constants(st, st->ctx->GeometryProgram._Current,
+ MESA_SHADER_GEOMETRY);
}
/* Tessellation control shader:
void
st_update_tcs_constants(struct st_context *st)
{
- st_upload_constants(st, st->tcp, MESA_SHADER_TESS_CTRL);
+ st_upload_constants(st, st->ctx->TessCtrlProgram._Current,
+ MESA_SHADER_TESS_CTRL);
}
/* Tessellation evaluation shader:
void
st_update_tes_constants(struct st_context *st)
{
- st_upload_constants(st, st->tep, MESA_SHADER_TESS_EVAL);
+ st_upload_constants(st, st->ctx->TessEvalProgram._Current,
+ MESA_SHADER_TESS_EVAL);
}
/* Compute shader:
void
st_update_cs_constants(struct st_context *st)
{
- st_upload_constants(st, st->cp, MESA_SHADER_COMPUTE);
+ st_upload_constants(st, st->ctx->ComputeProgram._Current,
+ MESA_SHADER_COMPUTE);
}
static void
void
st_update_sample_shading(struct st_context *st)
{
- if (!st->fp)
- return;
+ struct gl_program *fp = st->ctx->FragmentProgram._Current;
- if (!st->ctx->Extensions.ARB_sample_shading)
+ if (!fp || !st->ctx->Extensions.ARB_sample_shading)
return;
cso_set_min_samples(st->cso_context,
- _mesa_get_min_invocations_per_fragment(st->ctx, st->fp));
+ _mesa_get_min_invocations_per_fragment(st->ctx, fp));
}
ctx->Color._ClampFragmentColor;
key.lower_alpha_func = COMPARE_FUNC_ALWAYS;
- fpv = st_get_fp_variant(st, st->fp, &key);
+ fpv = st_get_fp_variant(st, ctx->FragmentProgram._Current, &key);
return fpv;
}
ctx->Color._ClampFragmentColor;
key.lower_alpha_func = COMPARE_FUNC_ALWAYS;
- fpv = st_get_fp_variant(st, st->fp, &key);
+ fpv = st_get_fp_variant(st, ctx->FragmentProgram._Current, &key);
return fpv;
}
/* compiling a new fragment shader variant added new state constants
* into the constant buffer, we need to update them
*/
- st_upload_constants(st, st->fp, MESA_SHADER_FRAGMENT);
+ st_upload_constants(st, ctx->FragmentProgram._Current, MESA_SHADER_FRAGMENT);
}
{
/* compiling a new fragment shader variant added new state constants
* into the constant buffer, we need to update them
*/
- st_upload_constants(st, st->fp, MESA_SHADER_FRAGMENT);
+ st_upload_constants(st, ctx->FragmentProgram._Current, MESA_SHADER_FRAGMENT);
} else if (type == GL_DEPTH) {
rbRead = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
driver_fp = get_drawpix_z_stencil_program(st, GL_TRUE, GL_FALSE);
feedback_vertex(struct gl_context *ctx, const struct draw_context *draw,
const struct vertex_header *v)
{
- const struct st_context *st = st_context(ctx);
- struct gl_vertex_program *stvp = (struct gl_vertex_program *)st->vp;
+ struct gl_vertex_program *stvp =
+ (struct gl_vertex_program *)ctx->VertexProgram._Current;
GLfloat win[4];
const GLfloat *color, *texcoord;
ubyte slot;
{
struct rastpos_stage *rs = rastpos_stage(stage);
struct gl_context *ctx = rs->ctx;
- struct st_context *st = st_context(ctx);
const GLfloat height = (GLfloat) ctx->DrawBuffer->Height;
- struct gl_vertex_program *stvp = (struct gl_vertex_program *)st->vp;
+ struct gl_vertex_program *stvp =
+ (struct gl_vertex_program *)ctx->VertexProgram._Current;
const ubyte *outputMapping = stvp->result_to_output;
const GLfloat *pos;
GLuint i;
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
struct draw_context *draw = st_get_draw_context(st);
- const struct gl_vertex_program *vp;
+ struct gl_vertex_program *vp;
struct st_common_variant *vp_variant;
struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
unsigned num_vbuffers = 0;
memcpy(&key, &st->vp_variant->key, sizeof(key));
key.is_draw_shader = true;
- vp = (struct gl_vertex_program *)st->vp;
- vp_variant = st_get_common_variant(st, st->vp, &key);
+ vp = (struct gl_vertex_program *)ctx->VertexProgram._Current;
+ vp_variant = st_get_common_variant(st, &vp->Base, &key);
/*
* Set up the draw module's state.
}
/* set constant buffer 0 */
- struct gl_program_parameter_list *params = st->vp->Parameters;
+ struct gl_program_parameter_list *params = vp->Base.Parameters;
/* Update the constants which come from fixed-function state, such as
* transformation matrices, fog factors, etc.
st_draw_hw_select_prepare_common(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
- if (st->gp || st->tcp || st->tep) {
+ if (ctx->GeometryProgram._Current ||
+ ctx->TessCtrlProgram._Current ||
+ ctx->TessEvalProgram._Current) {
fprintf(stderr, "HW GL_SELECT does not support user geometry/tessellation shader\n");
return false;
}
}
/* TODO: support gl_ClipDistance/gl_CullDistance, but it costs more regs */
- struct gl_program *vp = ctx->st->vp;
+ struct gl_program *vp = ctx->VertexProgram._Current;
if (vp->info.clip_distance_array_size || vp->info.cull_distance_array_size) {
fprintf(stderr, "HW GL_SELECT does not support gl_ClipDistance/gl_CullDistance\n");
return (union state_key){0};
void
st_finalize_program(struct st_context *st, struct gl_program *prog)
{
- if (st->current_program[prog->info.stage] == prog) {
+ bool is_bound = false;
+
+ if (prog->info.stage == MESA_SHADER_VERTEX)
+ is_bound = prog == st->ctx->VertexProgram._Current;
+ else if (prog->info.stage == MESA_SHADER_TESS_CTRL)
+ is_bound = prog == st->ctx->TessCtrlProgram._Current;
+ else if (prog->info.stage == MESA_SHADER_TESS_EVAL)
+ is_bound = prog == st->ctx->TessEvalProgram._Current;
+ else if (prog->info.stage == MESA_SHADER_GEOMETRY)
+ is_bound = prog == st->ctx->GeometryProgram._Current;
+ else if (prog->info.stage == MESA_SHADER_FRAGMENT)
+ is_bound = prog == st->ctx->FragmentProgram._Current;
+ else if (prog->info.stage == MESA_SHADER_COMPUTE)
+ is_bound = prog == st->ctx->ComputeProgram._Current;
+
+ if (is_bound) {
if (prog->info.stage == MESA_SHADER_VERTEX) {
st->ctx->Array.NewVertexElements = true;
st->dirty |= ST_NEW_VERTEX_PROGRAM(st->ctx, prog);