}
- pipe_get_tile_swizzle(struct pipe_transfer *pt,
+void
- pipe_get_tile_raw(pt, x, y, w, h, packed, 0);
++pipe_get_tile_swizzle(struct pipe_context *pipe,
++ struct pipe_transfer *pt,
+ uint x,
+ uint y,
+ uint w,
+ uint h,
+ uint swizzle_r,
+ uint swizzle_g,
+ uint swizzle_b,
+ uint swizzle_a,
+ enum pipe_format format,
+ float *p)
+{
+ unsigned dst_stride = w * 4;
+ void *packed;
+ uint i;
+ float rgba01[6];
+
+ if (pipe_clip_tile(x, y, &w, &h, pt)) {
+ return;
+ }
+
+ packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
+ if (!packed) {
+ return;
+ }
+
+ if (format == PIPE_FORMAT_UYVY || format == PIPE_FORMAT_YUYV) {
+ assert((x & 1) == 0);
+ }
+
++ pipe_get_tile_raw(pipe, pt, x, y, w, h, packed, 0);
+
+ pipe_tile_raw_to_rgba(format, packed, w, h, p, dst_stride);
+
+ FREE(packed);
+
+ if (swizzle_r == PIPE_SWIZZLE_RED &&
+ swizzle_g == PIPE_SWIZZLE_GREEN &&
+ swizzle_b == PIPE_SWIZZLE_BLUE &&
+ swizzle_a == PIPE_SWIZZLE_ALPHA) {
+ /* no-op, skip */
+ return;
+ }
+
+ rgba01[PIPE_SWIZZLE_ZERO] = 0.0f;
+ rgba01[PIPE_SWIZZLE_ONE] = 1.0f;
+
+ for (i = 0; i < w * h; i++) {
+ rgba01[PIPE_SWIZZLE_RED] = p[0];
+ rgba01[PIPE_SWIZZLE_GREEN] = p[1];
+ rgba01[PIPE_SWIZZLE_BLUE] = p[2];
+ rgba01[PIPE_SWIZZLE_ALPHA] = p[3];
+
+ *p++ = rgba01[swizzle_r];
+ *p++ = rgba01[swizzle_g];
+ *p++ = rgba01[swizzle_b];
+ *p++ = rgba01[swizzle_a];
+ }
+}
+
+
void
- pipe_put_tile_rgba(struct pipe_transfer *pt,
+ pipe_put_tile_rgba(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const float *p)
{
uint x, uint y, uint w, uint h,
float *p);
- pipe_get_tile_swizzle(struct pipe_transfer *pt,
+void
++pipe_get_tile_swizzle(struct pipe_context *pipe,
++ struct pipe_transfer *pt,
+ uint x,
+ uint y,
+ uint w,
+ uint h,
+ uint swizzle_r,
+ uint swizzle_g,
+ uint swizzle_b,
+ uint swizzle_a,
+ enum pipe_format format,
+ float *p);
+
void
- pipe_put_tile_rgba(struct pipe_transfer *pt,
+ pipe_put_tile_rgba(struct pipe_context *pipe,
+ struct pipe_transfer *pt,
uint x, uint y, uint w, uint h,
const float *p);
buffer);
}
+static struct pipe_sampler_view *
+identity_create_sampler_view(struct pipe_context *pipe,
+ struct pipe_texture *texture,
+ const struct pipe_sampler_view *templ)
+{
+ struct identity_context *id_pipe = identity_context(pipe);
+ struct identity_texture *id_texture = identity_texture(texture);
+ struct pipe_context *pipe_unwrapped = id_pipe->pipe;
+ struct pipe_texture *texture_unwrapped = id_texture->texture;
+ struct identity_sampler_view *view = malloc(sizeof(struct identity_sampler_view));
+
+ view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped,
+ texture_unwrapped,
+ templ);
+
+ view->base = *templ;
+ view->base.reference.count = 1;
+ view->base.texture = NULL;
+ pipe_texture_reference(&view->base.texture, texture);
+ view->base.context = pipe;
+
+ return &view->base;
+}
+
+static void
+identity_sampler_view_destroy(struct pipe_context *pipe,
+ struct pipe_sampler_view *view)
+{
+ struct identity_context *id_pipe = identity_context(pipe);
+ struct identity_sampler_view *id_view = identity_sampler_view(view);
+ struct pipe_context *pipe_unwrapped = id_pipe->pipe;
+ struct pipe_sampler_view *view_unwrapped = id_view->sampler_view;
+
+ pipe_unwrapped->sampler_view_destroy(pipe_unwrapped,
+ view_unwrapped);
+
+ pipe_texture_reference(&view->texture, NULL);
+ free(view);
+}
+
+ static struct pipe_transfer *
+ identity_context_get_tex_transfer(struct pipe_context *_context,
+ struct pipe_texture *_texture,
+ unsigned face,
+ unsigned level,
+ unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x,
+ unsigned y,
+ unsigned w,
+ unsigned h)
+ {
+ struct identity_context *id_context = identity_context(_context);
+ struct identity_texture *id_texture = identity_texture(_texture);
+ struct pipe_context *context = id_context->pipe;
+ struct pipe_texture *texture = id_texture->texture;
+ struct pipe_transfer *result;
+
+ result = context->get_tex_transfer(context,
+ texture,
+ face,
+ level,
+ zslice,
+ usage,
+ x,
+ y,
+ w,
+ h);
+
+ if (result)
+ return identity_transfer_create(id_context, id_texture, result);
+ return NULL;
+ }
+
+ static void
+ identity_context_tex_transfer_destroy(struct pipe_context *_pipe,
+ struct pipe_transfer *_transfer)
+ {
+ identity_transfer_destroy(identity_context(_pipe),
+ identity_transfer(_transfer));
+ }
+
+ static void *
+ identity_context_transfer_map(struct pipe_context *_context,
+ struct pipe_transfer *_transfer)
+ {
+ struct identity_context *id_context = identity_context(_context);
+ struct identity_transfer *id_transfer = identity_transfer(_transfer);
+ struct pipe_context *context = id_context->pipe;
+ struct pipe_transfer *transfer = id_transfer->transfer;
+
+ return context->transfer_map(context,
+ transfer);
+ }
+
+ static void
+ identity_context_transfer_unmap(struct pipe_context *_context,
+ struct pipe_transfer *_transfer)
+ {
+ struct identity_context *id_context = identity_context(_context);
+ struct identity_transfer *id_transfer = identity_transfer(_transfer);
+ struct pipe_context *context = id_context->pipe;
+ struct pipe_transfer *transfer = id_transfer->transfer;
+
+ context->transfer_unmap(context,
+ transfer);
+ }
+
struct pipe_context *
identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
{
id_pipe->base.flush = identity_flush;
id_pipe->base.is_texture_referenced = identity_is_texture_referenced;
id_pipe->base.is_buffer_referenced = identity_is_buffer_referenced;
+ id_pipe->base.create_sampler_view = identity_create_sampler_view;
+ id_pipe->base.sampler_view_destroy = identity_sampler_view_destroy;
+ id_pipe->base.get_tex_transfer = identity_context_get_tex_transfer;
+ id_pipe->base.tex_transfer_destroy = identity_context_tex_transfer_destroy;
+ id_pipe->base.transfer_map = identity_context_transfer_map;
+ id_pipe->base.transfer_unmap = identity_context_transfer_unmap;
id_pipe->pipe = pipe;
/**
- * Called during state validation when LP_NEW_TEXTURE is set.
+ * Called during state validation when LP_NEW_SAMPLER_VIEW is set.
*/
void
- lp_setup_set_fragment_sampler_views(struct setup_context *setup,
-lp_setup_set_sampler_textures( struct lp_setup_context *setup,
- unsigned num, struct pipe_texture **texture)
++lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
+ unsigned num,
+ struct pipe_sampler_view **views)
{
unsigned i;
const struct pipe_scissor_state *scissor );
void
- lp_setup_set_fragment_sampler_views(struct setup_context *setup,
-lp_setup_set_sampler_textures( struct lp_setup_context *setup,
- unsigned num, struct pipe_texture **texture);
++lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
+ unsigned num,
+ struct pipe_sampler_view **views);
unsigned
- lp_setup_is_texture_referenced( const struct setup_context *setup,
+ lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
const struct pipe_texture *texture );
void
}
/* get tile from the transfer (view into texture) */
- pipe_get_tile_swizzle(tc->tex_trans,
- pipe_get_tile_rgba(tc->pipe,
- tc->tex_trans,
- addr.bits.x * TILE_SIZE,
- addr.bits.y * TILE_SIZE,
- TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
++ pipe_get_tile_swizzle(tc->pipe,
++ tc->tex_trans,
+ addr.bits.x * TILE_SIZE,
+ addr.bits.y * TILE_SIZE,
+ TILE_SIZE,
+ TILE_SIZE,
+ tc->swizzle_r,
+ tc->swizzle_g,
+ tc->swizzle_b,
+ tc->swizzle_a,
+ tc->format,
+ (float *) tile->data.color);
tile->addr = addr;
}
*
**************************************************************************/
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
+ #include "util/u_format.h"
+ #include "pipe/p_format.h"
#include "pipe/p_screen.h"
#include "tr_dump.h"
unsigned int (*is_buffer_referenced)(struct pipe_context *pipe,
struct pipe_buffer *buf);
+ /**
+ * Create a view on a texture to be used by a shader stage.
+ */
+ struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx,
+ struct pipe_texture *texture,
+ const struct pipe_sampler_view *templat);
+
+ void (*sampler_view_destroy)(struct pipe_context *ctx,
+ struct pipe_sampler_view *view);
+
+
+ /**
+ * Get a transfer object for transferring data to/from a texture.
+ *
+ * Transfers are (by default) context-private and allow uploads to be
+ * interleaved with
+ */
+ struct pipe_transfer *(*get_tex_transfer)(struct pipe_context *,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level,
+ unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h);
+
+ void (*tex_transfer_destroy)(struct pipe_context *,
+ struct pipe_transfer *);
+
+ void *(*transfer_map)( struct pipe_context *,
+ struct pipe_transfer *transfer );
+
+ void (*transfer_unmap)( struct pipe_context *,
+ struct pipe_transfer *transfer );
+
+
};
if (st->ctx->DrawBuffer) {
struct pipe_context *pipe = st->pipe;
- struct pipe_screen *screen = pipe->screen;
+ struct pipe_sampler_view *sv;
assert(cache->xmin <= cache->xmax);
/* texture state: */
if (st->pixel_xfer.pixelmap_enabled) {
- struct pipe_texture *textures[2];
- textures[0] = pt;
- textures[1] = st->pixel_xfer.pixelmap_texture;
- pipe->set_fragment_sampler_textures(pipe, 2, textures);
+ struct pipe_sampler_view *sampler_views[2];
+ sampler_views[0] = sv;
+ sampler_views[1] = st->pixel_xfer.pixelmap_sampler_view;
+ cso_set_fragment_sampler_views(cso, 2, sampler_views);
}
else {
- pipe->set_fragment_sampler_textures(pipe, 1, &pt);
+ cso_set_fragment_sampler_views(cso, 1, &sv);
}
- /* Compute window coords (y=0=bottom) with pixel zoom.
+ /* Compute Gallium window coords (y=0=top) with pixel zoom.
* Recall that these coords are transformed by the current
* vertex shader and viewport transformation.
*/
struct st_renderbuffer *rbRead;
void *driver_vp, *driver_fp;
struct pipe_texture *pt;
+ struct pipe_sampler_view *sv;
GLfloat *color;
enum pipe_format srcFormat, texFormat;
- int ptw, pth;
+ GLboolean invertTex = GL_FALSE;
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
if (!pt)
return;
+ sv = st_sampler_view_from_texture(st->pipe, pt);
+ if (!sv) {
+ pipe_texture_reference(&pt, NULL);
+ return;
+ }
+
+ /* Make temporary texture which is a copy of the src region.
+ * We'll draw a quad with this texture to draw the dest image.
+ */
if (srcFormat == texFormat) {
/* copy source framebuffer surface into mipmap/texture */
struct pipe_surface *psRead = screen->get_tex_surface(screen,
/* draw textured quad */
draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
- pt,
+ sv,
driver_vp,
driver_fp,
- color, GL_TRUE);
+ color, invertTex);
pipe_texture_reference(&pt, NULL);
+ pipe_sampler_view_reference(&sv, NULL);
}