#include "main/pack.h"
#include "main/pbo.h"
#include "main/readpix.h"
+#include "main/state.h"
#include "main/texformat.h"
#include "main/teximage.h"
#include "main/texstore.h"
#include "st_draw.h"
#include "st_format.h"
#include "st_program.h"
+#include "st_sampler_view.h"
+#include "st_scissor.h"
#include "st_texture.h"
#include "pipe/p_context.h"
return st->drawpix.zs_shaders[shaderIndex];
}
- ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT);
+ ureg = ureg_create(PIPE_SHADER_FRAGMENT);
if (ureg == NULL)
return NULL;
TGSI_SEMANTIC_TEXCOORD : TGSI_SEMANTIC_GENERIC;
if (!st->drawpix.vert_shaders[passColor]) {
- struct ureg_program *ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
+ struct ureg_program *ureg = ureg_create( PIPE_SHADER_VERTEX );
if (ureg == NULL)
return NULL;
make_texture(struct st_context *st,
GLsizei width, GLsizei height, GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
- const GLvoid *pixels)
+ const void *pixels)
{
struct gl_context *ctx = st->ctx;
struct pipe_context *pipe = st->pipe;
mesa_format mformat;
- struct pipe_resource *pt;
+ struct pipe_resource *pt = NULL;
enum pipe_format pipeFormat;
GLenum baseInternalFormat;
unpack->SkipRows == 0 &&
unpack->SwapBytes == GL_FALSE &&
st->drawpix_cache.image) {
+ assert(st->drawpix_cache.texture);
+
/* check if the pixel data is the same */
if (memcmp(pixels, st->drawpix_cache.image, width * height * bpp) == 0) {
/* OK, re-use the cached texture */
- return st->drawpix_cache.texture;
+ pipe_resource_reference(&pt, st->drawpix_cache.texture);
+ /* refcount of returned texture should be at least two here. One
+ * reference for the cache to hold on to, one for the caller (which
+ * it will release), and possibly more held by the driver.
+ */
+ assert(pt->reference.count >= 2);
+ return pt;
}
}
{
struct pipe_transfer *transfer;
- GLboolean success;
GLubyte *dest;
const GLbitfield imageTransferStateSave = ctx->_ImageTransferState;
format, type, /* src format/type */
pixels, /* data source */
unpack);
- success = GL_TRUE;
}
else {
+ bool MAYBE_UNUSED success;
success = _mesa_texstore(ctx, 2, /* dims */
baseInternalFormat, /* baseInternalFormat */
mformat, /* mesa_format */
format, type, /* src format/type */
pixels, /* data source */
unpack);
+
+ assert(success);
}
/* unmap */
pipe_transfer_unmap(pipe, transfer);
- assert(success);
-
/* restore */
ctx->_ImageTransferState = imageTransferStateSave;
}
st->drawpix_cache.image = malloc(width * height * bpp);
if (st->drawpix_cache.image) {
memcpy(st->drawpix_cache.image, pixels, width * height * bpp);
+ pipe_resource_reference(&st->drawpix_cache.texture, pt);
+ }
+ else {
+ /* out of memory, free/disable cached texture */
+ st->drawpix_cache.width = 0;
+ st->drawpix_cache.height = 0;
+ pipe_resource_reference(&st->drawpix_cache.texture, NULL);
}
- st->drawpix_cache.texture = pt;
}
#endif
const unsigned fb_width = _mesa_geometric_width(ctx->DrawBuffer);
const unsigned fb_height = _mesa_geometric_height(ctx->DrawBuffer);
GLfloat x0, y0, x1, y1;
- GLsizei maxSize;
+ GLsizei MAYBE_UNUSED maxSize;
boolean normalized = sv[0]->texture->target == PIPE_TEXTURE_2D;
unsigned cso_state_mask;
draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
GLsizei width, GLsizei height, GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
- const GLvoid *pixels)
+ const void *pixels)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
for (row = 0; row < height; row++) {
GLfloat *zValuesFloat = (GLfloat*)zValues;
GLenum destType = GL_UNSIGNED_BYTE;
- const GLvoid *source = _mesa_image_address2d(&clippedUnpack, pixels,
+ const void *source = _mesa_image_address2d(&clippedUnpack, pixels,
width, height,
format, type,
row, 0);
/* invert the format's swizzle to setup the sampler's swizzle */
if (format == GL_RGBA) {
- c0 = UTIL_FORMAT_SWIZZLE_X;
- c1 = UTIL_FORMAT_SWIZZLE_Y;
- c2 = UTIL_FORMAT_SWIZZLE_Z;
- c3 = UTIL_FORMAT_SWIZZLE_W;
+ c0 = PIPE_SWIZZLE_X;
+ c1 = PIPE_SWIZZLE_Y;
+ c2 = PIPE_SWIZZLE_Z;
+ c3 = PIPE_SWIZZLE_W;
}
else {
assert(format == GL_BGRA);
- c0 = UTIL_FORMAT_SWIZZLE_Z;
- c1 = UTIL_FORMAT_SWIZZLE_Y;
- c2 = UTIL_FORMAT_SWIZZLE_X;
- c3 = UTIL_FORMAT_SWIZZLE_W;
+ c0 = PIPE_SWIZZLE_Z;
+ c1 = PIPE_SWIZZLE_Y;
+ c2 = PIPE_SWIZZLE_X;
+ c3 = PIPE_SWIZZLE_W;
}
sv->swizzle_r = search_swizzle(desc->swizzle, c0);
sv->swizzle_g = search_swizzle(desc->swizzle, c1);
st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
- const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels)
+ const struct gl_pixelstore_attrib *unpack, const void *pixels)
{
void *driver_vp, *driver_fp;
struct st_context *st = st_context(ctx);
/* Mesa state should be up to date by now */
assert(ctx->NewState == 0x0);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
st_flush_bitmap_cache(st);
+ st_invalidate_readpix_cache(st);
st_validate_state(st, ST_PIPELINE_RENDER);
/* compiling a new fragment shader variant added new state constants
* into the constant buffer, we need to update them
*/
- st_upload_constants(st, st->fp->Base.Base.Parameters,
- PIPE_SHADER_FRAGMENT);
+ st_upload_constants(st, &st->fp->Base);
}
/* Put glDrawPixels image into a texture */
if (num_sampler_view > 1)
pipe_sampler_view_reference(&sv[1], NULL);
-#if !USE_DRAWPIXELS_CACHE
+ /* free the texture (but may persist in the cache) */
pipe_resource_reference(&pt, NULL);
-#endif
}
!ctx->FragmentProgram.Enabled &&
!ctx->VertexProgram.Enabled &&
!ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT] &&
+ !_mesa_ati_fragment_shader_enabled(ctx) &&
ctx->DrawBuffer->_NumColorDrawBuffers == 1 &&
!ctx->Query.CondRenderQuery &&
!ctx->Query.CurrentOcclusionObject) {
blit.mask = PIPE_MASK_RGBA;
blit.filter = PIPE_TEX_FILTER_NEAREST;
+ if (ctx->DrawBuffer != ctx->WinSysDrawBuffer)
+ st_window_rectangles_to_blit(ctx, &blit);
+
if (screen->is_format_supported(screen, blit.src.format,
blit.src.resource->target,
blit.src.resource->nr_samples,
GLint readX, readY, readW, readH;
struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
+
st_flush_bitmap_cache(st);
+ st_invalidate_readpix_cache(st);
st_validate_state(st, ST_PIPELINE_RENDER);
/* compiling a new fragment shader variant added new state constants
* into the constant buffer, we need to update them
*/
- st_upload_constants(st, st->fp->Base.Base.Parameters,
- PIPE_SHADER_FRAGMENT);
+ st_upload_constants(st, &st->fp->Base);
}
else {
assert(type == GL_DEPTH);