st/mesa: subclass st_vertex_program for VP-specific members
Inheritance: gl_program -> st_program -> st_vertex_program Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
This commit is contained in:
parent
16e5f13b64
commit
4e70cba638
|
@ -37,7 +37,7 @@
|
||||||
#include "main/glheader.h"
|
#include "main/glheader.h"
|
||||||
|
|
||||||
struct st_context;
|
struct st_context;
|
||||||
struct st_program;
|
struct st_vertex_program;
|
||||||
struct st_vp_variant;
|
struct st_vp_variant;
|
||||||
struct pipe_vertex_buffer;
|
struct pipe_vertex_buffer;
|
||||||
struct pipe_vertex_element;
|
struct pipe_vertex_element;
|
||||||
|
@ -60,21 +60,21 @@ GLuint st_compare_func_to_pipe(GLenum func);
|
||||||
|
|
||||||
void
|
void
|
||||||
st_setup_arrays(struct st_context *st,
|
st_setup_arrays(struct st_context *st,
|
||||||
const struct st_program *vp,
|
const struct st_vertex_program *vp,
|
||||||
const struct st_vp_variant *vp_variant,
|
const struct st_vp_variant *vp_variant,
|
||||||
struct pipe_vertex_element *velements,
|
struct pipe_vertex_element *velements,
|
||||||
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
|
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
|
||||||
|
|
||||||
void
|
void
|
||||||
st_setup_current(struct st_context *st,
|
st_setup_current(struct st_context *st,
|
||||||
const struct st_program *vp,
|
const struct st_vertex_program *vp,
|
||||||
const struct st_vp_variant *vp_variant,
|
const struct st_vp_variant *vp_variant,
|
||||||
struct pipe_vertex_element *velements,
|
struct pipe_vertex_element *velements,
|
||||||
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
|
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
|
||||||
|
|
||||||
void
|
void
|
||||||
st_setup_current_user(struct st_context *st,
|
st_setup_current_user(struct st_context *st,
|
||||||
const struct st_program *vp,
|
const struct st_vertex_program *vp,
|
||||||
const struct st_vp_variant *vp_variant,
|
const struct st_vp_variant *vp_variant,
|
||||||
struct pipe_vertex_element *velements,
|
struct pipe_vertex_element *velements,
|
||||||
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
|
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers);
|
||||||
|
|
|
@ -318,7 +318,7 @@ static void init_velement(struct pipe_vertex_element *velement,
|
||||||
assert(velement->src_format);
|
assert(velement->src_format);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_velement_lowered(const struct st_program *vp,
|
static void init_velement_lowered(const struct st_vertex_program *vp,
|
||||||
struct pipe_vertex_element *velements,
|
struct pipe_vertex_element *velements,
|
||||||
const struct gl_vertex_format *vformat,
|
const struct gl_vertex_format *vformat,
|
||||||
int src_offset, int instance_divisor,
|
int src_offset, int instance_divisor,
|
||||||
|
@ -385,7 +385,7 @@ set_vertex_attribs(struct st_context *st,
|
||||||
|
|
||||||
void
|
void
|
||||||
st_setup_arrays(struct st_context *st,
|
st_setup_arrays(struct st_context *st,
|
||||||
const struct st_program *vp,
|
const struct st_vertex_program *vp,
|
||||||
const struct st_vp_variant *vp_variant,
|
const struct st_vp_variant *vp_variant,
|
||||||
struct pipe_vertex_element *velements,
|
struct pipe_vertex_element *velements,
|
||||||
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
|
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
|
||||||
|
@ -455,7 +455,7 @@ st_setup_arrays(struct st_context *st,
|
||||||
|
|
||||||
void
|
void
|
||||||
st_setup_current(struct st_context *st,
|
st_setup_current(struct st_context *st,
|
||||||
const struct st_program *vp,
|
const struct st_vertex_program *vp,
|
||||||
const struct st_vp_variant *vp_variant,
|
const struct st_vp_variant *vp_variant,
|
||||||
struct pipe_vertex_element *velements,
|
struct pipe_vertex_element *velements,
|
||||||
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
|
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
|
||||||
|
@ -466,8 +466,6 @@ st_setup_current(struct st_context *st,
|
||||||
/* Process values that should have better been uniforms in the application */
|
/* Process values that should have better been uniforms in the application */
|
||||||
GLbitfield curmask = inputs_read & _mesa_draw_current_bits(ctx);
|
GLbitfield curmask = inputs_read & _mesa_draw_current_bits(ctx);
|
||||||
if (curmask) {
|
if (curmask) {
|
||||||
/* vertex program validation must be done before this */
|
|
||||||
const struct st_program *vp = st->vp;
|
|
||||||
const ubyte *input_to_index = vp->input_to_index;
|
const ubyte *input_to_index = vp->input_to_index;
|
||||||
/* For each attribute, upload the maximum possible size. */
|
/* For each attribute, upload the maximum possible size. */
|
||||||
GLubyte data[VERT_ATTRIB_MAX * sizeof(GLdouble) * 4];
|
GLubyte data[VERT_ATTRIB_MAX * sizeof(GLdouble) * 4];
|
||||||
|
@ -517,7 +515,7 @@ st_setup_current(struct st_context *st,
|
||||||
|
|
||||||
void
|
void
|
||||||
st_setup_current_user(struct st_context *st,
|
st_setup_current_user(struct st_context *st,
|
||||||
const struct st_program *vp,
|
const struct st_vertex_program *vp,
|
||||||
const struct st_vp_variant *vp_variant,
|
const struct st_vp_variant *vp_variant,
|
||||||
struct pipe_vertex_element *velements,
|
struct pipe_vertex_element *velements,
|
||||||
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
|
struct pipe_vertex_buffer *vbuffer, unsigned *num_vbuffers)
|
||||||
|
@ -550,7 +548,7 @@ st_update_array(struct st_context *st)
|
||||||
{
|
{
|
||||||
/* vertex program validation must be done before this */
|
/* vertex program validation must be done before this */
|
||||||
/* _NEW_PROGRAM, ST_NEW_VS_STATE */
|
/* _NEW_PROGRAM, ST_NEW_VS_STATE */
|
||||||
const struct st_program *vp = st->vp;
|
const struct st_vertex_program *vp = (struct st_vertex_program *)st->vp;
|
||||||
const struct st_vp_variant *vp_variant = st->vp_variant;
|
const struct st_vp_variant *vp_variant = st->vp_variant;
|
||||||
|
|
||||||
struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
|
struct pipe_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
|
||||||
|
|
|
@ -84,6 +84,7 @@ feedback_vertex(struct gl_context *ctx, const struct draw_context *draw,
|
||||||
const struct vertex_header *v)
|
const struct vertex_header *v)
|
||||||
{
|
{
|
||||||
const struct st_context *st = st_context(ctx);
|
const struct st_context *st = st_context(ctx);
|
||||||
|
struct st_vertex_program *stvp = (struct st_vertex_program *)st->vp;
|
||||||
GLfloat win[4];
|
GLfloat win[4];
|
||||||
const GLfloat *color, *texcoord;
|
const GLfloat *color, *texcoord;
|
||||||
GLuint slot;
|
GLuint slot;
|
||||||
|
@ -101,13 +102,13 @@ feedback_vertex(struct gl_context *ctx, const struct draw_context *draw,
|
||||||
* color and texcoord attribs to use here.
|
* color and texcoord attribs to use here.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
slot = st->vp->result_to_output[VARYING_SLOT_COL0];
|
slot = stvp->result_to_output[VARYING_SLOT_COL0];
|
||||||
if (slot != ~0U)
|
if (slot != ~0U)
|
||||||
color = v->data[slot];
|
color = v->data[slot];
|
||||||
else
|
else
|
||||||
color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
|
color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
|
||||||
|
|
||||||
slot = st->vp->result_to_output[VARYING_SLOT_TEX0];
|
slot = stvp->result_to_output[VARYING_SLOT_TEX0];
|
||||||
if (slot != ~0U)
|
if (slot != ~0U)
|
||||||
texcoord = v->data[slot];
|
texcoord = v->data[slot];
|
||||||
else
|
else
|
||||||
|
|
|
@ -60,17 +60,15 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id,
|
||||||
{
|
{
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case GL_VERTEX_PROGRAM_ARB: {
|
case GL_VERTEX_PROGRAM_ARB: {
|
||||||
struct st_program *prog = rzalloc(NULL,
|
struct st_vertex_program *prog = rzalloc(NULL, struct st_vertex_program);
|
||||||
struct st_program);
|
return _mesa_init_gl_program(&prog->Base.Base, target, id, is_arb_asm);
|
||||||
return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
|
|
||||||
}
|
}
|
||||||
case GL_TESS_CONTROL_PROGRAM_NV:
|
case GL_TESS_CONTROL_PROGRAM_NV:
|
||||||
case GL_TESS_EVALUATION_PROGRAM_NV:
|
case GL_TESS_EVALUATION_PROGRAM_NV:
|
||||||
case GL_GEOMETRY_PROGRAM_NV:
|
case GL_GEOMETRY_PROGRAM_NV:
|
||||||
case GL_FRAGMENT_PROGRAM_ARB:
|
case GL_FRAGMENT_PROGRAM_ARB:
|
||||||
case GL_COMPUTE_PROGRAM_NV: {
|
case GL_COMPUTE_PROGRAM_NV: {
|
||||||
struct st_program *prog = rzalloc(NULL,
|
struct st_program *prog = rzalloc(NULL, struct st_program);
|
||||||
struct st_program);
|
|
||||||
return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
|
return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -140,7 +140,8 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
|
||||||
struct gl_context *ctx = rs->ctx;
|
struct gl_context *ctx = rs->ctx;
|
||||||
struct st_context *st = st_context(ctx);
|
struct st_context *st = st_context(ctx);
|
||||||
const GLfloat height = (GLfloat) ctx->DrawBuffer->Height;
|
const GLfloat height = (GLfloat) ctx->DrawBuffer->Height;
|
||||||
const ubyte *outputMapping = st->vp->result_to_output;
|
struct st_vertex_program *stvp = (struct st_vertex_program *)st->vp;
|
||||||
|
const ubyte *outputMapping = stvp->result_to_output;
|
||||||
const GLfloat *pos;
|
const GLfloat *pos;
|
||||||
GLuint i;
|
GLuint i;
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
||||||
struct st_context *st = st_context(ctx);
|
struct st_context *st = st_context(ctx);
|
||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
struct draw_context *draw = st_get_draw_context(st);
|
struct draw_context *draw = st_get_draw_context(st);
|
||||||
const struct st_program *vp;
|
const struct st_vertex_program *vp;
|
||||||
struct st_vp_variant *vp_variant;
|
struct st_vp_variant *vp_variant;
|
||||||
struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
|
struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
|
||||||
unsigned num_vbuffers = 0;
|
unsigned num_vbuffers = 0;
|
||||||
|
@ -136,7 +136,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
||||||
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
|
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index, nr_prims);
|
||||||
|
|
||||||
/* must get these after state validation! */
|
/* must get these after state validation! */
|
||||||
vp = st->vp;
|
vp = (struct st_vertex_program *)st->vp;
|
||||||
vp_variant = st->vp_variant;
|
vp_variant = st->vp_variant;
|
||||||
|
|
||||||
struct pipe_shader_state state = {0};
|
struct pipe_shader_state state = {0};
|
||||||
|
|
|
@ -440,8 +440,10 @@ st_translate_prog_to_nir(struct st_context *st, struct gl_program *prog,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
st_prepare_vertex_program(struct st_program *stvp)
|
st_prepare_vertex_program(struct st_program *stp)
|
||||||
{
|
{
|
||||||
|
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
|
||||||
|
|
||||||
stvp->num_inputs = 0;
|
stvp->num_inputs = 0;
|
||||||
memset(stvp->input_to_index, ~0, sizeof(stvp->input_to_index));
|
memset(stvp->input_to_index, ~0, sizeof(stvp->input_to_index));
|
||||||
memset(stvp->result_to_output, ~0, sizeof(stvp->result_to_output));
|
memset(stvp->result_to_output, ~0, sizeof(stvp->result_to_output));
|
||||||
|
@ -450,12 +452,12 @@ st_prepare_vertex_program(struct st_program *stvp)
|
||||||
* and TGSI generic input indexes, plus input attrib semantic info.
|
* and TGSI generic input indexes, plus input attrib semantic info.
|
||||||
*/
|
*/
|
||||||
for (unsigned attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
|
for (unsigned attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
|
||||||
if ((stvp->Base.info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
|
if ((stp->Base.info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
|
||||||
stvp->input_to_index[attr] = stvp->num_inputs;
|
stvp->input_to_index[attr] = stvp->num_inputs;
|
||||||
stvp->index_to_input[stvp->num_inputs] = attr;
|
stvp->index_to_input[stvp->num_inputs] = attr;
|
||||||
stvp->num_inputs++;
|
stvp->num_inputs++;
|
||||||
|
|
||||||
if ((stvp->Base.DualSlotInputs & BITFIELD64_BIT(attr)) != 0) {
|
if ((stp->Base.DualSlotInputs & BITFIELD64_BIT(attr)) != 0) {
|
||||||
/* add placeholder for second part of a double attribute */
|
/* add placeholder for second part of a double attribute */
|
||||||
stvp->index_to_input[stvp->num_inputs] = ST_DOUBLE_ATTRIB_PLACEHOLDER;
|
stvp->index_to_input[stvp->num_inputs] = ST_DOUBLE_ATTRIB_PLACEHOLDER;
|
||||||
stvp->num_inputs++;
|
stvp->num_inputs++;
|
||||||
|
@ -469,7 +471,7 @@ st_prepare_vertex_program(struct st_program *stvp)
|
||||||
/* Compute mapping of vertex program outputs to slots. */
|
/* Compute mapping of vertex program outputs to slots. */
|
||||||
unsigned num_outputs = 0;
|
unsigned num_outputs = 0;
|
||||||
for (unsigned attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
for (unsigned attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
||||||
if (stvp->Base.info.outputs_written & BITFIELD64_BIT(attr))
|
if (stp->Base.info.outputs_written & BITFIELD64_BIT(attr))
|
||||||
stvp->result_to_output[attr] = num_outputs++;
|
stvp->result_to_output[attr] = num_outputs++;
|
||||||
}
|
}
|
||||||
/* pre-setup potentially unused edgeflag output */
|
/* pre-setup potentially unused edgeflag output */
|
||||||
|
@ -518,7 +520,7 @@ st_translate_stream_output_info(struct gl_program *prog)
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
st_translate_vertex_program(struct st_context *st,
|
st_translate_vertex_program(struct st_context *st,
|
||||||
struct st_program *stvp)
|
struct st_program *stp)
|
||||||
{
|
{
|
||||||
struct ureg_program *ureg;
|
struct ureg_program *ureg;
|
||||||
enum pipe_error error;
|
enum pipe_error error;
|
||||||
|
@ -527,31 +529,31 @@ st_translate_vertex_program(struct st_context *st,
|
||||||
ubyte output_semantic_name[VARYING_SLOT_MAX] = {0};
|
ubyte output_semantic_name[VARYING_SLOT_MAX] = {0};
|
||||||
ubyte output_semantic_index[VARYING_SLOT_MAX] = {0};
|
ubyte output_semantic_index[VARYING_SLOT_MAX] = {0};
|
||||||
|
|
||||||
if (stvp->Base.arb.IsPositionInvariant)
|
if (stp->Base.arb.IsPositionInvariant)
|
||||||
_mesa_insert_mvp_code(st->ctx, &stvp->Base);
|
_mesa_insert_mvp_code(st->ctx, &stp->Base);
|
||||||
|
|
||||||
st_prepare_vertex_program(stvp);
|
st_prepare_vertex_program(stp);
|
||||||
|
|
||||||
/* ARB_vp: */
|
/* ARB_vp: */
|
||||||
if (!stvp->glsl_to_tgsi) {
|
if (!stp->glsl_to_tgsi) {
|
||||||
_mesa_remove_output_reads(&stvp->Base, PROGRAM_OUTPUT);
|
_mesa_remove_output_reads(&stp->Base, PROGRAM_OUTPUT);
|
||||||
|
|
||||||
/* This determines which states will be updated when the assembly
|
/* This determines which states will be updated when the assembly
|
||||||
* shader is bound.
|
* shader is bound.
|
||||||
*/
|
*/
|
||||||
stvp->affected_states = ST_NEW_VS_STATE |
|
stp->affected_states = ST_NEW_VS_STATE |
|
||||||
ST_NEW_RASTERIZER |
|
ST_NEW_RASTERIZER |
|
||||||
ST_NEW_VERTEX_ARRAYS;
|
ST_NEW_VERTEX_ARRAYS;
|
||||||
|
|
||||||
if (stvp->Base.Parameters->NumParameters)
|
if (stp->Base.Parameters->NumParameters)
|
||||||
stvp->affected_states |= ST_NEW_VS_CONSTANTS;
|
stp->affected_states |= ST_NEW_VS_CONSTANTS;
|
||||||
|
|
||||||
/* No samplers are allowed in ARB_vp. */
|
/* No samplers are allowed in ARB_vp. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get semantic names and indices. */
|
/* Get semantic names and indices. */
|
||||||
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
|
||||||
if (stvp->Base.info.outputs_written & BITFIELD64_BIT(attr)) {
|
if (stp->Base.info.outputs_written & BITFIELD64_BIT(attr)) {
|
||||||
unsigned slot = num_outputs++;
|
unsigned slot = num_outputs++;
|
||||||
unsigned semantic_name, semantic_index;
|
unsigned semantic_name, semantic_index;
|
||||||
tgsi_get_gl_varying_semantic(attr, st->needs_texcoord_semantic,
|
tgsi_get_gl_varying_semantic(attr, st->needs_texcoord_semantic,
|
||||||
|
@ -568,25 +570,27 @@ st_translate_vertex_program(struct st_context *st,
|
||||||
if (ureg == NULL)
|
if (ureg == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (stvp->Base.info.clip_distance_array_size)
|
if (stp->Base.info.clip_distance_array_size)
|
||||||
ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED,
|
ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED,
|
||||||
stvp->Base.info.clip_distance_array_size);
|
stp->Base.info.clip_distance_array_size);
|
||||||
if (stvp->Base.info.cull_distance_array_size)
|
if (stp->Base.info.cull_distance_array_size)
|
||||||
ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED,
|
ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED,
|
||||||
stvp->Base.info.cull_distance_array_size);
|
stp->Base.info.cull_distance_array_size);
|
||||||
|
|
||||||
if (ST_DEBUG & DEBUG_MESA) {
|
if (ST_DEBUG & DEBUG_MESA) {
|
||||||
_mesa_print_program(&stvp->Base);
|
_mesa_print_program(&stp->Base);
|
||||||
_mesa_print_program_parameters(st->ctx, &stvp->Base);
|
_mesa_print_program_parameters(st->ctx, &stp->Base);
|
||||||
debug_printf("\n");
|
debug_printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stvp->glsl_to_tgsi) {
|
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
|
||||||
|
|
||||||
|
if (stp->glsl_to_tgsi) {
|
||||||
error = st_translate_program(st->ctx,
|
error = st_translate_program(st->ctx,
|
||||||
PIPE_SHADER_VERTEX,
|
PIPE_SHADER_VERTEX,
|
||||||
ureg,
|
ureg,
|
||||||
stvp->glsl_to_tgsi,
|
stp->glsl_to_tgsi,
|
||||||
&stvp->Base,
|
&stp->Base,
|
||||||
/* inputs */
|
/* inputs */
|
||||||
stvp->num_inputs,
|
stvp->num_inputs,
|
||||||
stvp->input_to_index,
|
stvp->input_to_index,
|
||||||
|
@ -600,14 +604,14 @@ st_translate_vertex_program(struct st_context *st,
|
||||||
output_semantic_name,
|
output_semantic_name,
|
||||||
output_semantic_index);
|
output_semantic_index);
|
||||||
|
|
||||||
st_translate_stream_output_info(&stvp->Base);
|
st_translate_stream_output_info(&stp->Base);
|
||||||
|
|
||||||
free_glsl_to_tgsi_visitor(stvp->glsl_to_tgsi);
|
free_glsl_to_tgsi_visitor(stp->glsl_to_tgsi);
|
||||||
} else
|
} else
|
||||||
error = st_translate_mesa_program(st->ctx,
|
error = st_translate_mesa_program(st->ctx,
|
||||||
PIPE_SHADER_VERTEX,
|
PIPE_SHADER_VERTEX,
|
||||||
ureg,
|
ureg,
|
||||||
&stvp->Base,
|
&stp->Base,
|
||||||
/* inputs */
|
/* inputs */
|
||||||
stvp->num_inputs,
|
stvp->num_inputs,
|
||||||
stvp->input_to_index,
|
stvp->input_to_index,
|
||||||
|
@ -622,17 +626,17 @@ st_translate_vertex_program(struct st_context *st,
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
debug_printf("%s: failed to translate Mesa program:\n", __func__);
|
debug_printf("%s: failed to translate Mesa program:\n", __func__);
|
||||||
_mesa_print_program(&stvp->Base);
|
_mesa_print_program(&stp->Base);
|
||||||
debug_assert(0);
|
debug_assert(0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
stvp->state.tokens = ureg_get_tokens(ureg, NULL);
|
stp->state.tokens = ureg_get_tokens(ureg, NULL);
|
||||||
ureg_destroy(ureg);
|
ureg_destroy(ureg);
|
||||||
|
|
||||||
if (stvp->glsl_to_tgsi) {
|
if (stp->glsl_to_tgsi) {
|
||||||
stvp->glsl_to_tgsi = NULL;
|
stp->glsl_to_tgsi = NULL;
|
||||||
st_store_ir_in_disk_cache(st, &stvp->Base, false);
|
st_store_ir_in_disk_cache(st, &stp->Base, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Translate to NIR.
|
/* Translate to NIR.
|
||||||
|
@ -644,20 +648,20 @@ st_translate_vertex_program(struct st_context *st,
|
||||||
if (st->pipe->screen->get_shader_param(st->pipe->screen,
|
if (st->pipe->screen->get_shader_param(st->pipe->screen,
|
||||||
PIPE_SHADER_VERTEX,
|
PIPE_SHADER_VERTEX,
|
||||||
PIPE_SHADER_CAP_PREFERRED_IR)) {
|
PIPE_SHADER_CAP_PREFERRED_IR)) {
|
||||||
assert(!stvp->glsl_to_tgsi);
|
assert(!stp->glsl_to_tgsi);
|
||||||
|
|
||||||
nir_shader *nir =
|
nir_shader *nir =
|
||||||
st_translate_prog_to_nir(st, &stvp->Base, MESA_SHADER_VERTEX);
|
st_translate_prog_to_nir(st, &stp->Base, MESA_SHADER_VERTEX);
|
||||||
|
|
||||||
if (stvp->state.ir.nir)
|
if (stp->state.ir.nir)
|
||||||
ralloc_free(stvp->state.ir.nir);
|
ralloc_free(stp->state.ir.nir);
|
||||||
stvp->state.type = PIPE_SHADER_IR_NIR;
|
stp->state.type = PIPE_SHADER_IR_NIR;
|
||||||
stvp->state.ir.nir = nir;
|
stp->state.ir.nir = nir;
|
||||||
stvp->Base.nir = nir;
|
stp->Base.nir = nir;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stvp->state.tokens != NULL;
|
return stp->state.tokens != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gl_state_index16 depth_range_state[STATE_LENGTH] =
|
static const gl_state_index16 depth_range_state[STATE_LENGTH] =
|
||||||
|
@ -678,7 +682,7 @@ st_create_vp_variant(struct st_context *st,
|
||||||
struct gl_program_parameter_list *params = stvp->Base.Parameters;
|
struct gl_program_parameter_list *params = stvp->Base.Parameters;
|
||||||
|
|
||||||
vpv->key = *key;
|
vpv->key = *key;
|
||||||
vpv->num_inputs = stvp->num_inputs;
|
vpv->num_inputs = ((struct st_vertex_program*)stvp)->num_inputs;
|
||||||
|
|
||||||
state.stream_output = stvp->state.stream_output;
|
state.stream_output = stvp->state.stream_output;
|
||||||
|
|
||||||
|
@ -807,13 +811,14 @@ st_create_vp_variant(struct st_context *st,
|
||||||
*/
|
*/
|
||||||
struct st_vp_variant *
|
struct st_vp_variant *
|
||||||
st_get_vp_variant(struct st_context *st,
|
st_get_vp_variant(struct st_context *st,
|
||||||
struct st_program *stvp,
|
struct st_program *stp,
|
||||||
const struct st_common_variant_key *key)
|
const struct st_common_variant_key *key)
|
||||||
{
|
{
|
||||||
|
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
|
||||||
struct st_vp_variant *vpv;
|
struct st_vp_variant *vpv;
|
||||||
|
|
||||||
/* Search for existing variant */
|
/* Search for existing variant */
|
||||||
for (vpv = stvp->vp_variants; vpv; vpv = vpv->next) {
|
for (vpv = stp->vp_variants; vpv; vpv = vpv->next) {
|
||||||
if (memcmp(&vpv->key, key, sizeof(*key)) == 0) {
|
if (memcmp(&vpv->key, key, sizeof(*key)) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -821,7 +826,7 @@ st_get_vp_variant(struct st_context *st,
|
||||||
|
|
||||||
if (!vpv) {
|
if (!vpv) {
|
||||||
/* create now */
|
/* create now */
|
||||||
vpv = st_create_vp_variant(st, stvp, key);
|
vpv = st_create_vp_variant(st, stp, key);
|
||||||
if (vpv) {
|
if (vpv) {
|
||||||
for (unsigned index = 0; index < vpv->num_inputs; ++index) {
|
for (unsigned index = 0; index < vpv->num_inputs; ++index) {
|
||||||
unsigned attr = stvp->index_to_input[index];
|
unsigned attr = stvp->index_to_input[index];
|
||||||
|
@ -831,8 +836,8 @@ st_get_vp_variant(struct st_context *st,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* insert into list */
|
/* insert into list */
|
||||||
vpv->next = stvp->vp_variants;
|
vpv->next = stp->vp_variants;
|
||||||
stvp->vp_variants = vpv;
|
stp->vp_variants = vpv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -251,6 +251,12 @@ struct st_program
|
||||||
struct st_vp_variant *vp_variants;
|
struct st_vp_variant *vp_variants;
|
||||||
struct st_fp_variant *fp_variants;
|
struct st_fp_variant *fp_variants;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct st_vertex_program
|
||||||
|
{
|
||||||
|
struct st_program Base;
|
||||||
|
|
||||||
/** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
|
/** maps a TGSI input index back to a Mesa VERT_ATTRIB_x */
|
||||||
ubyte index_to_input[PIPE_MAX_ATTRIBS];
|
ubyte index_to_input[PIPE_MAX_ATTRIBS];
|
||||||
|
|
|
@ -86,13 +86,15 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog,
|
||||||
blob_init(&blob);
|
blob_init(&blob);
|
||||||
|
|
||||||
if (prog->info.stage == MESA_SHADER_VERTEX) {
|
if (prog->info.stage == MESA_SHADER_VERTEX) {
|
||||||
blob_write_uint32(&blob, stp->num_inputs);
|
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
|
||||||
blob_write_bytes(&blob, stp->index_to_input,
|
|
||||||
sizeof(stp->index_to_input));
|
blob_write_uint32(&blob, stvp->num_inputs);
|
||||||
blob_write_bytes(&blob, stp->input_to_index,
|
blob_write_bytes(&blob, stvp->index_to_input,
|
||||||
sizeof(stp->input_to_index));
|
sizeof(stvp->index_to_input));
|
||||||
blob_write_bytes(&blob, stp->result_to_output,
|
blob_write_bytes(&blob, stvp->input_to_index,
|
||||||
sizeof(stp->result_to_output));
|
sizeof(stvp->input_to_index));
|
||||||
|
blob_write_bytes(&blob, stvp->result_to_output,
|
||||||
|
sizeof(stvp->result_to_output));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prog->info.stage == MESA_SHADER_VERTEX ||
|
if (prog->info.stage == MESA_SHADER_VERTEX ||
|
||||||
|
@ -174,13 +176,14 @@ st_deserialise_ir_program(struct gl_context *ctx,
|
||||||
if (prog->info.stage == MESA_SHADER_VERTEX) {
|
if (prog->info.stage == MESA_SHADER_VERTEX) {
|
||||||
st_release_vp_variants(st, stp);
|
st_release_vp_variants(st, stp);
|
||||||
|
|
||||||
stp->num_inputs = blob_read_uint32(&blob_reader);
|
struct st_vertex_program *stvp = (struct st_vertex_program *)stp;
|
||||||
blob_copy_bytes(&blob_reader, (uint8_t *) stp->index_to_input,
|
stvp->num_inputs = blob_read_uint32(&blob_reader);
|
||||||
sizeof(stp->index_to_input));
|
blob_copy_bytes(&blob_reader, (uint8_t *) stvp->index_to_input,
|
||||||
blob_copy_bytes(&blob_reader, (uint8_t *) stp->input_to_index,
|
sizeof(stvp->index_to_input));
|
||||||
sizeof(stp->input_to_index));
|
blob_copy_bytes(&blob_reader, (uint8_t *) stvp->input_to_index,
|
||||||
blob_copy_bytes(&blob_reader, (uint8_t *) stp->result_to_output,
|
sizeof(stvp->input_to_index));
|
||||||
sizeof(stp->result_to_output));
|
blob_copy_bytes(&blob_reader, (uint8_t *) stvp->result_to_output,
|
||||||
|
sizeof(stvp->result_to_output));
|
||||||
} else if (prog->info.stage == MESA_SHADER_FRAGMENT) {
|
} else if (prog->info.stage == MESA_SHADER_FRAGMENT) {
|
||||||
st_release_fp_variants(st, stp);
|
st_release_fp_variants(st, stp);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue