gallium: added inClipCoords param to st_draw_vertices() to indicate coord system of vertices
Also, export st_make_passthrough_vertex_shader() from st_cb_drawpixels.c
This commit is contained in:
@@ -251,7 +251,7 @@ draw_quad(GLcontext *ctx,
|
||||
verts[i][1][3] = color[3];
|
||||
}
|
||||
|
||||
st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2);
|
||||
st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -355,8 +355,8 @@ make_fragment_shader_z(struct st_context *st)
|
||||
* Create a simple vertex shader that just passes through the
|
||||
* vertex position and texcoord (and optionally, color).
|
||||
*/
|
||||
static struct st_vertex_program *
|
||||
make_vertex_shader(struct st_context *st, GLboolean passColor)
|
||||
struct st_vertex_program *
|
||||
st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor)
|
||||
{
|
||||
/* only make programs once and re-use */
|
||||
static struct st_vertex_program *progs[2] = { NULL, NULL };
|
||||
@@ -572,7 +572,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
|
||||
verts[i][1][3] = 1.0; /*Q*/
|
||||
}
|
||||
|
||||
st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2);
|
||||
st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -625,7 +625,7 @@ draw_quad_colored(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
|
||||
verts[i][2][3] = 1.0; /*Q*/
|
||||
}
|
||||
|
||||
st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3);
|
||||
st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 3, GL_FALSE);
|
||||
}
|
||||
|
||||
|
||||
@@ -945,7 +945,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
if (format == GL_DEPTH_COMPONENT) {
|
||||
ps = st->state.framebuffer.zsbuf;
|
||||
stfp = make_fragment_shader_z(ctx->st);
|
||||
stvp = make_vertex_shader(ctx->st, GL_TRUE);
|
||||
stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE);
|
||||
color = ctx->Current.RasterColor;
|
||||
}
|
||||
else if (format == GL_STENCIL_INDEX) {
|
||||
@@ -956,7 +956,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
else {
|
||||
ps = st->state.framebuffer.cbufs[0];
|
||||
stfp = combined_drawpix_fragment_program(ctx);
|
||||
stvp = make_vertex_shader(ctx->st, GL_FALSE);
|
||||
stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE);
|
||||
color = NULL;
|
||||
}
|
||||
|
||||
@@ -1111,7 +1111,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
|
||||
struct st_context *st = ctx->st;
|
||||
struct pipe_texture *pt;
|
||||
|
||||
stvp = make_vertex_shader(ctx->st, GL_TRUE);
|
||||
stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE);
|
||||
stfp = combined_bitmap_fragment_program(ctx);
|
||||
|
||||
st_validate_state(st);
|
||||
@@ -1229,13 +1229,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
|
||||
rbRead = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
|
||||
color = NULL;
|
||||
stfp = combined_drawpix_fragment_program(ctx);
|
||||
stvp = make_vertex_shader(ctx->st, GL_FALSE);
|
||||
stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE);
|
||||
}
|
||||
else {
|
||||
rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer);
|
||||
color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
|
||||
stfp = make_fragment_shader_z(ctx->st);
|
||||
stvp = make_vertex_shader(ctx->st, GL_TRUE);
|
||||
stvp = st_make_passthrough_vertex_shader(ctx->st, GL_TRUE);
|
||||
}
|
||||
|
||||
psRead = rbRead->surface;
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#define ST_CB_DRAWPIXELS_H
|
||||
|
||||
|
||||
extern struct st_vertex_program *
|
||||
st_make_passthrough_vertex_shader(struct st_context *st, GLboolean passColor);
|
||||
|
||||
|
||||
extern void st_init_drawpixels_functions(struct dd_function_table *functions);
|
||||
|
||||
|
||||
|
||||
@@ -354,7 +354,8 @@ st_draw_vbo(GLcontext *ctx,
|
||||
void
|
||||
st_draw_vertices(GLcontext *ctx, unsigned prim,
|
||||
unsigned numVertex, float *verts,
|
||||
unsigned numAttribs)
|
||||
unsigned numAttribs,
|
||||
GLboolean inClipCoords)
|
||||
{
|
||||
const float width = ctx->DrawBuffer->Width;
|
||||
const float height = ctx->DrawBuffer->Height;
|
||||
@@ -367,14 +368,16 @@ st_draw_vertices(GLcontext *ctx, unsigned prim,
|
||||
|
||||
assert(numAttribs > 0);
|
||||
|
||||
/* convert to clip coords */
|
||||
for (i = 0; i < numVertex; i++) {
|
||||
float x = verts[i * numAttribs * 4 + 0];
|
||||
float y = verts[i * numAttribs * 4 + 1];
|
||||
x = x / width * 2.0 - 1.0;
|
||||
y = y / height * 2.0 - 1.0;
|
||||
verts[i * numAttribs * 4 + 0] = x;
|
||||
verts[i * numAttribs * 4 + 1] = y;
|
||||
if (!inClipCoords) {
|
||||
/* convert to clip coords */
|
||||
for (i = 0; i < numVertex; i++) {
|
||||
float x = verts[i * numAttribs * 4 + 0];
|
||||
float y = verts[i * numAttribs * 4 + 1];
|
||||
x = x / width * 2.0 - 1.0;
|
||||
y = y / height * 2.0 - 1.0;
|
||||
verts[i * numAttribs * 4 + 0] = x;
|
||||
verts[i * numAttribs * 4 + 1] = y;
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX create one-time */
|
||||
|
||||
@@ -62,7 +62,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
|
||||
void
|
||||
st_draw_vertices(GLcontext *ctx, unsigned prim,
|
||||
unsigned numVertex, float *verts,
|
||||
unsigned numAttribs);
|
||||
unsigned numAttribs,
|
||||
GLboolean inClipCoords);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user