#include "main/bufferobj.h"
#include "main/macros.h"
#include "main/texformat.h"
+#include "main/state.h"
#include "shader/program.h"
#include "shader/prog_parameter.h"
#include "shader/prog_print.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
#include "util/u_draw_quad.h"
#include "shader/prog_instruction.h"
#include "cso_cache/cso_context.h"
}
stvp = (struct st_vertex_program *) p;
- st_translate_vertex_program(st, stvp, NULL);
+ st_translate_vertex_program(st, stvp, NULL, NULL, NULL);
st->drawpix.vert_shaders[passColor] = stvp;
mformat, /* gl_texture_format */
dest, /* dest */
0, 0, 0, /* dstX/Y/Zoffset */
- surface->pitch * cpp, /* dstRowStride, bytes */
+ surface->stride, /* dstRowStride, bytes */
&dstImageOffsets, /* dstImageOffsets */
width, height, 1, /* size */
format, type, /* src format/type */
/* setup vertex data */
{
const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- const GLfloat fb_width = fb->Width;
- const GLfloat fb_height = fb->Height;
- const GLfloat clip_x0 = x0 / fb_width * 2.0 - 1.0;
- const GLfloat clip_y0 = y0 / fb_height * 2.0 - 1.0;
- const GLfloat clip_x1 = x1 / fb_width * 2.0 - 1.0;
- const GLfloat clip_y1 = y1 / fb_height * 2.0 - 1.0;
- const GLfloat sLeft = 0.0F, sRight = 1.0F;
- const GLfloat tTop = invertTex, tBot = 1.0 - tTop;
+ const GLfloat fb_width = (GLfloat) fb->Width;
+ const GLfloat fb_height = (GLfloat) fb->Height;
+ const GLfloat clip_x0 = x0 / fb_width * 2.0f - 1.0f;
+ const GLfloat clip_y0 = y0 / fb_height * 2.0f - 1.0f;
+ const GLfloat clip_x1 = x1 / fb_width * 2.0f - 1.0f;
+ const GLfloat clip_y1 = y1 / fb_height * 2.0f - 1.0f;
+ const GLfloat sLeft = 0.0f, sRight = 1.0f;
+ const GLfloat tTop = invertTex, tBot = 1.0f - tTop;
GLuint tex, i;
/* upper-left */
if (color) {
for (i = 0; i < 4; i++) {
verts[i][0][2] = z; /*Z*/
- verts[i][0][3] = 1.0; /*W*/
+ verts[i][0][3] = 1.0f; /*W*/
verts[i][1][0] = color[0];
verts[i][1][1] = color[1];
verts[i][1][2] = color[2];
verts[i][1][3] = color[3];
- verts[i][2][2] = 0.0; /*R*/
- verts[i][2][3] = 1.0; /*Q*/
+ verts[i][2][2] = 0.0f; /*R*/
+ verts[i][2][3] = 1.0f; /*Q*/
}
}
else {
for (i = 0; i < 4; i++) {
verts[i][0][2] = z; /*Z*/
- verts[i][0][3] = 1.0; /*W*/
- verts[i][1][2] = 0.0; /*R*/
- verts[i][1][3] = 1.0; /*Q*/
+ verts[i][0][3] = 1.0f; /*W*/
+ verts[i][1][2] = 0.0f; /*R*/
+ verts[i][1][3] = 1.0f; /*Q*/
}
}
}
ubyte *map;
/* allocate/load buffer object with vertex data */
- buf = pipe_buffer_create(pipe, 32, PIPE_BUFFER_USAGE_VERTEX,
+ buf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
sizeof(verts));
- map = pipe_buffer_map(pipe, buf, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pipe_buffer_map(pipe->screen, buf, PIPE_BUFFER_USAGE_CPU_WRITE);
memcpy(map, verts, sizeof(verts));
- pipe_buffer_unmap(pipe, buf);
+ pipe_buffer_unmap(pipe->screen, buf);
util_draw_vertex_buffer(pipe, buf,
PIPE_PRIM_QUADS,
4, /* verts */
3); /* attribs/vert */
- pipe_buffer_reference(pipe->winsys, &buf, NULL);
+ pipe_buffer_reference(pipe->screen, &buf, NULL);
}
}
struct pipe_context *pipe = ctx->st->pipe;
struct cso_context *cso = ctx->st->cso_context;
GLfloat x0, y0, x1, y1;
- GLuint maxSize;
+ GLsizei maxSize;
/* limit checks */
/* XXX if DrawPixels image is larger than max texture size, break
/* viewport state: viewport matching window dims */
{
- const float width = ctx->DrawBuffer->Width;
- const float height = ctx->DrawBuffer->Height;
+ const float width = (float) ctx->DrawBuffer->Width;
+ const float height = (float) ctx->DrawBuffer->Height;
struct pipe_viewport_state vp;
- vp.scale[0] = 0.5 * width;
- vp.scale[1] = -0.5 * height;
- vp.scale[2] = 1.0;
- vp.scale[3] = 1.0;
- vp.translate[0] = 0.5 * width;
- vp.translate[1] = 0.5 * height;
- vp.translate[2] = 0.0;
- vp.translate[3] = 0.0;
+ vp.scale[0] = 0.5f * width;
+ vp.scale[1] = -0.5f * height;
+ vp.scale[2] = 1.0f;
+ vp.scale[3] = 1.0f;
+ vp.translate[0] = 0.5f * width;
+ vp.translate[1] = 0.5f * height;
+ vp.translate[2] = 0.0f;
+ vp.translate[3] = 0.0f;
cso_set_viewport(cso, &vp);
}
* Recall that these coords are transformed by the current
* vertex shader and viewport transformation.
*/
- x0 = x;
+ x0 = (GLfloat) x;
x1 = x + width * ctx->Pixel.ZoomX;
- y0 = y;
+ y0 = (GLfloat) y;
y1 = y + height * ctx->Pixel.ZoomY;
//if(!color)
draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex);
switch (ps->format) {
case PIPE_FORMAT_S8_UNORM:
{
- ubyte *dest = stmap + spanY * ps->pitch + spanX;
+ ubyte *dest = stmap + spanY * ps->stride + spanX;
memcpy(dest, values, spanWidth);
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
{
- uint *dest = (uint *) stmap + spanY * ps->pitch + spanX;
+ uint *dest = (uint *) (stmap + spanY * ps->stride + spanX*4);
GLint k;
for (k = 0; k < spanWidth; k++) {
uint p = dest[k];
return;
}
+ _mesa_set_vp_override( ctx, TRUE );
+ _mesa_update_state( ctx );
+
st_validate_state(st);
if (format == GL_DEPTH_COMPONENT) {
/* blit */
draw_blit(st, width, height, format, type, pixels);
}
+
+ _mesa_set_vp_override( ctx, FALSE );
}
psDraw = screen->get_tex_surface(screen, rbDraw->texture, 0, 0, 0,
PIPE_BUFFER_USAGE_CPU_WRITE);
+ assert(psDraw->block.width == 1);
+ assert(psDraw->block.height == 1);
+
/* map the stencil buffer */
drawMap = screen->surface_map(screen, psDraw, PIPE_BUFFER_USAGE_CPU_WRITE);
y = ctx->DrawBuffer->Height - y - 1;
}
- dst = drawMap + (y * psDraw->pitch + dstx) * psDraw->cpp;
+ dst = drawMap + y * psDraw->stride + dstx * psDraw->block.size;
src = buffer + i * width;
switch (psDraw->format) {
srcFormat = rbRead->texture->format;
- if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE)) {
+ if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
texFormat = srcFormat;
}
else {
/* srcFormat can't be used as a texture format */
if (type == GL_DEPTH) {
- texFormat = st_choose_format(pipe, GL_DEPTH_COMPONENT, PIPE_TEXTURE);
+ texFormat = st_choose_format(pipe, GL_DEPTH_COMPONENT, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL);
assert(texFormat != PIPE_FORMAT_NONE); /* XXX no depth texture formats??? */
}
else {
/* default color format */
- texFormat = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE);
+ texFormat = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER);
assert(texFormat != PIPE_FORMAT_NONE);
}
}
/* alternate path using get/put_tile() */
GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(pipe, psRead, srcx, srcy, width, height, buf);
- pipe_put_tile_rgba(pipe, psTex, 0, 0, width, height, buf);
+ pipe_get_tile_rgba(psRead, srcx, srcy, width, height, buf);
+ pipe_put_tile_rgba(psTex, 0, 0, width, height, buf);
free(buf);
}
else {
/* GL_DEPTH */
GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint));
- pipe_get_tile_z(pipe, psRead, srcx, srcy, width, height, buf);
- pipe_put_tile_z(pipe, psTex, 0, 0, width, height, buf);
+ pipe_get_tile_z(psRead, srcx, srcy, width, height, buf);
+ pipe_put_tile_z(psTex, 0, 0, width, height, buf);
free(buf);
}
pipe_surface_reference(&psRead, NULL);