add support for sprite texcoord modes
This commit is contained in:
@@ -40,7 +40,8 @@ struct wide_stage {
|
||||
float half_line_width;
|
||||
float half_point_size;
|
||||
|
||||
uint texcoord[PIPE_MAX_SHADER_OUTPUTS];
|
||||
uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS];
|
||||
uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS];
|
||||
uint num_texcoords;
|
||||
};
|
||||
|
||||
@@ -123,17 +124,27 @@ static void wide_line( struct draw_stage *stage,
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the vertex texcoords for sprite mode.
|
||||
* Coords may be left untouched or set to a right-side-up or upside-down
|
||||
* orientation.
|
||||
*/
|
||||
static void set_texcoords(const struct wide_stage *wide,
|
||||
struct vertex_header *v, const float tc[4])
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < wide->num_texcoords; i++) {
|
||||
uint j = wide->texcoord[i];
|
||||
if (wide->texcoord_mode[i] != PIPE_SPRITE_COORD_NONE) {
|
||||
uint j = wide->texcoord_slot[i];
|
||||
v->data[j][0] = tc[0];
|
||||
if (wide->texcoord_mode[i] == PIPE_SPRITE_COORD_LOWER_LEFT)
|
||||
v->data[j][1] = 1.0 - tc[1];
|
||||
else
|
||||
v->data[j][1] = tc[1];
|
||||
v->data[j][2] = tc[2];
|
||||
v->data[j][3] = tc[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +241,9 @@ static void wide_begin( struct draw_stage *stage )
|
||||
uint i, j = 0;
|
||||
for (i = 0; i < vs->state->num_outputs; i++) {
|
||||
if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
|
||||
wide->texcoord[j++] = i;
|
||||
wide->texcoord_slot[j] = i;
|
||||
wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
wide->num_texcoords = j;
|
||||
|
@@ -308,4 +308,11 @@
|
||||
#define PIPE_QUERY_TYPES 3
|
||||
|
||||
|
||||
/**
|
||||
* Point sprite coord modes
|
||||
*/
|
||||
#define PIPE_SPRITE_COORD_NONE 0
|
||||
#define PIPE_SPRITE_COORD_UPPER_LEFT 1
|
||||
#define PIPE_SPRITE_COORD_LOWER_LEFT 2
|
||||
|
||||
#endif
|
||||
|
@@ -96,6 +96,7 @@ struct pipe_rasterizer_state
|
||||
float point_size; /**< used when no per-vertex size */
|
||||
float offset_units;
|
||||
float offset_scale;
|
||||
ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */
|
||||
};
|
||||
|
||||
|
||||
|
@@ -74,6 +74,7 @@ static void update_raster_state( struct st_context *st )
|
||||
GLcontext *ctx = st->ctx;
|
||||
struct pipe_rasterizer_state raster;
|
||||
const struct cso_rasterizer *cso;
|
||||
uint i;
|
||||
|
||||
memset(&raster, 0, sizeof(raster));
|
||||
|
||||
@@ -189,6 +190,17 @@ static void update_raster_state( struct st_context *st )
|
||||
raster.point_size = ctx->Point.Size;
|
||||
raster.point_smooth = ctx->Point.SmoothFlag;
|
||||
raster.point_sprite = ctx->Point.PointSprite;
|
||||
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
|
||||
if (ctx->Point.CoordReplace[i]) {
|
||||
if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT)
|
||||
raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_UPPER_LEFT;
|
||||
else
|
||||
raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_LOWER_LEFT;
|
||||
}
|
||||
else {
|
||||
raster.sprite_coord_mode[i] = PIPE_SPRITE_COORD_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
/* _NEW_LINE
|
||||
*/
|
||||
|
Reference in New Issue
Block a user