summaryrefslogtreecommitdiff
path: root/src/mesa/es/state_tracker/st_cb_drawtex.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/es/state_tracker/st_cb_drawtex.c')
-rw-r--r--src/mesa/es/state_tracker/st_cb_drawtex.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/mesa/es/state_tracker/st_cb_drawtex.c b/src/mesa/es/state_tracker/st_cb_drawtex.c
index 0a5cba9d92..6d387d5ccf 100644
--- a/src/mesa/es/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/es/state_tracker/st_cb_drawtex.c
@@ -115,13 +115,17 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
struct cso_context *cso = ctx->st->cso_context;
- struct pipe_buffer *vbuffer;
+ struct pipe_resource *vbuffer;
+ struct pipe_transfer *vbuffer_transfer;
GLuint i, numTexCoords, numAttribs;
GLboolean emitColor;
uint semantic_names[2 + MAX_TEXTURE_UNITS];
uint semantic_indexes[2 + MAX_TEXTURE_UNITS];
+ struct pipe_vertex_element velements[2 + MAX_TEXTURE_UNITS];
GLbitfield inputs = VERT_BIT_POS;
+ st_validate_state(st);
+
/* determine if we need vertex color */
if (ctx->FragmentProgram._Current->Base.InputsRead & FRAG_BIT_COL0)
emitColor = GL_TRUE;
@@ -142,7 +146,7 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
/* create the vertex buffer */
- vbuffer = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
+ vbuffer = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER,
numAttribs * 4 * 4 * sizeof(GLfloat));
/* load vertex buffer */
@@ -158,8 +162,9 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
} while (0)
const GLfloat x0 = x, y0 = y, x1 = x + width, y1 = y + height;
- GLfloat *vbuf = (GLfloat *) pipe_buffer_map(pipe->screen, vbuffer,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ GLfloat *vbuf = (GLfloat *) pipe_buffer_map(pipe, vbuffer,
+ PIPE_TRANSFER_WRITE,
+ &vbuffer_transfer);
GLuint attr;
z = CLAMP(z, 0.0f, 1.0f);
@@ -224,7 +229,7 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
}
}
- pipe_buffer_unmap(pipe->screen, vbuffer);
+ pipe_buffer_unmap(pipe, vbuffer, vbuffer_transfer);
#undef SET_ATTRIB
}
@@ -232,6 +237,7 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
cso_save_viewport(cso);
cso_save_vertex_shader(cso);
+ cso_save_vertex_elements(cso);
{
void *vs = lookup_shader(pipe, numAttribs,
@@ -239,6 +245,14 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
cso_set_vertex_shader_handle(cso, vs);
}
+ for (i = 0; i < numAttribs; i++) {
+ velements[i].src_offset = i * 4 * sizeof(float);
+ velements[i].instance_divisor = 0;
+ velements[i].vertex_buffer_index = 0;
+ velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
+ }
+ cso_set_vertex_elements(cso, numAttribs, velements);
+
/* viewport state: viewport matching window dims */
{
const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
@@ -265,11 +279,12 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
numAttribs); /* attribs/vert */
- pipe_buffer_reference(&vbuffer, NULL);
+ pipe_resource_reference(&vbuffer, NULL);
/* restore state */
cso_restore_viewport(cso);
cso_restore_vertex_shader(cso);
+ cso_restore_vertex_elements(cso);
}