}
static void
-identity_draw_arrays(struct pipe_context *_pipe,
- unsigned prim,
- unsigned start,
- unsigned count)
+identity_draw_vbo(struct pipe_context *_pipe,
+ const struct pipe_draw_info *info)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct pipe_context *pipe = id_pipe->pipe;
- pipe->draw_arrays(pipe,
- prim,
- start,
- count);
-}
-
-static void
-identity_draw_elements(struct pipe_context *_pipe,
- struct pipe_resource *_indexResource,
- unsigned indexSize,
- int indexBias,
- unsigned prim,
- unsigned start,
- unsigned count)
-{
- struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_resource *id_resource = identity_resource(_indexResource);
- struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_resource *indexResource = id_resource->resource;
-
- pipe->draw_elements(pipe,
- indexResource,
- indexSize,
- indexBias,
- prim,
- start,
- count);
-}
-
-static void
-identity_draw_range_elements(struct pipe_context *_pipe,
- struct pipe_resource *_indexResource,
- unsigned indexSize,
- int indexBias,
- unsigned minIndex,
- unsigned maxIndex,
- unsigned mode,
- unsigned start,
- unsigned count)
-{
- struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_resource *id_resource = identity_resource(_indexResource);
- struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_resource *indexResource = id_resource->resource;
-
- pipe->draw_range_elements(pipe,
- indexResource,
- indexSize,
- indexBias,
- minIndex,
- maxIndex,
- mode,
- start,
- count);
+ pipe->draw_vbo(pipe, info);
}
static struct pipe_query *
identity_get_query_result(struct pipe_context *_pipe,
struct pipe_query *query,
boolean wait,
- uint64_t *result)
+ union pipe_query_result *result)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct pipe_context *pipe = id_pipe->pipe;
}
static void
-identity_bind_fragment_sampler_states(struct pipe_context *_pipe,
- unsigned num_samplers,
- void **samplers)
+identity_bind_sampler_states(struct pipe_context *_pipe,
+ unsigned shader,
+ unsigned start,
+ unsigned num_samplers,
+ void **samplers)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct pipe_context *pipe = id_pipe->pipe;
- pipe->bind_fragment_sampler_states(pipe,
- num_samplers,
- samplers);
+ /* remove this when we have pipe->bind_sampler_states(..., start, ...) */
+ assert(start == 0);
+
+ switch (shader) {
+ case PIPE_SHADER_VERTEX:
+ pipe->bind_vertex_sampler_states(pipe, num_samplers, samplers);
+ break;
+ case PIPE_SHADER_GEOMETRY:
+ pipe->bind_geometry_sampler_states(pipe, num_samplers, samplers);
+ break;
+ case PIPE_SHADER_FRAGMENT:
+ pipe->bind_fragment_sampler_states(pipe, num_samplers, samplers);
+ break;
+ default:
+ debug_error("Unexpected shader in identity_bind_sampler_states()");
+ }
+}
+
+static void
+identity_bind_fragment_sampler_states(struct pipe_context *_pipe,
+ unsigned num_samplers,
+ void **samplers)
+{
+ identity_bind_sampler_states(_pipe, PIPE_SHADER_FRAGMENT,
+ 0, num_samplers, samplers);
}
static void
unsigned num_samplers,
void **samplers)
{
- struct identity_context *id_pipe = identity_context(_pipe);
- struct pipe_context *pipe = id_pipe->pipe;
-
- pipe->bind_vertex_sampler_states(pipe,
- num_samplers,
- samplers);
+ identity_bind_sampler_states(_pipe, PIPE_SHADER_VERTEX,
+ 0, num_samplers, samplers);
}
static void
identity_set_constant_buffer(struct pipe_context *_pipe,
uint shader,
uint index,
- struct pipe_resource *_resource)
+ struct pipe_constant_buffer *_cb)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_resource *unwrapped_resource;
- struct pipe_resource *resource = NULL;
+ struct pipe_constant_buffer cb;
/* XXX hmm? unwrap the input state */
- if (_resource) {
- unwrapped_resource = identity_resource_unwrap(_resource);
- resource = unwrapped_resource;
+ if (_cb) {
+ cb = *_cb;
+ cb.buffer = identity_resource_unwrap(_cb->buffer);
}
pipe->set_constant_buffer(pipe,
shader,
index,
- resource);
+ _cb ? &cb : NULL);
}
static void
}
static void
-identity_set_fragment_sampler_views(struct pipe_context *_pipe,
- unsigned num,
- struct pipe_sampler_view **_views)
+identity_set_sampler_views(struct pipe_context *_pipe,
+ unsigned shader,
+ unsigned start,
+ unsigned num,
+ struct pipe_sampler_view **_views)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct pipe_context *pipe = id_pipe->pipe;
struct pipe_sampler_view **views = NULL;
unsigned i;
+ /* remove this when we have pipe->set_sampler_views(..., start, ...) */
+ assert(start == 0);
+
if (_views) {
for (i = 0; i < num; i++)
unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]);
views = unwrapped_views;
}
- pipe->set_fragment_sampler_views(pipe, num, views);
+ switch (shader) {
+ case PIPE_SHADER_VERTEX:
+ pipe->set_vertex_sampler_views(pipe, num, views);
+ break;
+ case PIPE_SHADER_GEOMETRY:
+ pipe->set_geometry_sampler_views(pipe, num, views);
+ break;
+ case PIPE_SHADER_FRAGMENT:
+ pipe->set_fragment_sampler_views(pipe, num, views);
+ break;
+ default:
+ debug_error("Unexpected shader in identity_set_sampler_views()");
+ }
+}
+
+static void
+identity_set_fragment_sampler_views(struct pipe_context *_pipe,
+ unsigned num,
+ struct pipe_sampler_view **_views)
+{
+ identity_set_sampler_views(_pipe, PIPE_SHADER_FRAGMENT, 0, num, _views);
}
static void
unsigned num,
struct pipe_sampler_view **_views)
{
- struct identity_context *id_pipe = identity_context(_pipe);
- struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_sampler_view *unwrapped_views[PIPE_MAX_VERTEX_SAMPLERS];
- struct pipe_sampler_view **views = NULL;
- unsigned i;
-
- if (_views) {
- for (i = 0; i < num; i++)
- unwrapped_views[i] = identity_sampler_view_unwrap(_views[i]);
- for (; i < PIPE_MAX_VERTEX_SAMPLERS; i++)
- unwrapped_views[i] = NULL;
-
- views = unwrapped_views;
- }
-
- pipe->set_vertex_sampler_views(pipe, num, views);
+ identity_set_sampler_views(_pipe, PIPE_SHADER_VERTEX, 0, num, _views);
}
static void
identity_set_vertex_buffers(struct pipe_context *_pipe,
- unsigned num_buffers,
+ unsigned start_slot, unsigned num_buffers,
const struct pipe_vertex_buffer *_buffers)
{
struct identity_context *id_pipe = identity_context(_pipe);
}
pipe->set_vertex_buffers(pipe,
- num_buffers,
+ start_slot, num_buffers,
buffers);
}
+
+static void
+identity_set_index_buffer(struct pipe_context *_pipe,
+ const struct pipe_index_buffer *_ib)
+{
+ struct identity_context *id_pipe = identity_context(_pipe);
+ struct pipe_context *pipe = id_pipe->pipe;
+ struct pipe_index_buffer unwrapped_ib, *ib = NULL;
+
+ if (_ib) {
+ unwrapped_ib = *_ib;
+ unwrapped_ib.buffer = identity_resource_unwrap(_ib->buffer);
+ ib = &unwrapped_ib;
+ }
+
+ pipe->set_index_buffer(pipe, ib);
+}
+
static void
identity_resource_copy_region(struct pipe_context *_pipe,
struct pipe_resource *_dst,
- struct pipe_subresource subdst,
+ unsigned dst_level,
unsigned dstx,
unsigned dsty,
unsigned dstz,
struct pipe_resource *_src,
- struct pipe_subresource subsrc,
- unsigned srcx,
- unsigned srcy,
- unsigned srcz,
- unsigned width,
- unsigned height)
+ unsigned src_level,
+ const struct pipe_box *src_box)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct identity_resource *id_resource_dst = identity_resource(_dst);
pipe->resource_copy_region(pipe,
dst,
- subdst,
+ dst_level,
dstx,
dsty,
dstz,
src,
- subsrc,
- srcx,
- srcy,
- srcz,
- width,
- height);
+ src_level,
+ src_box);
}
static void
-identity_resource_fill_region(struct pipe_context *_pipe,
- struct pipe_resource *_dst,
- struct pipe_subresource subdst,
- unsigned dstx,
- unsigned dsty,
- unsigned dstz,
- unsigned width,
- unsigned height,
- unsigned value)
+identity_blit(struct pipe_context *_pipe,
+ const struct pipe_blit_info *info)
{
struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_resource *id_resource_dst = identity_resource(_dst);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_resource *dst = id_resource_dst->resource;
+ struct pipe_blit_info blit = *info;
- pipe->resource_fill_region(pipe,
- dst,
- subdst,
- dstx,
- dsty,
- dstz,
- width,
- height,
- value);
+ blit.src.resource = identity_resource(blit.src.resource)->resource;
+ blit.dst.resource = identity_resource(blit.dst.resource)->resource;
+
+ pipe->blit(pipe, &blit);
}
static void
identity_clear(struct pipe_context *_pipe,
unsigned buffers,
- const float *rgba,
+ const union pipe_color_union *color,
double depth,
unsigned stencil)
{
pipe->clear(pipe,
buffers,
- rgba,
+ color,
depth,
stencil);
}
static void
-identity_flush(struct pipe_context *_pipe,
- unsigned flags,
- struct pipe_fence_handle **fence)
+identity_clear_render_target(struct pipe_context *_pipe,
+ struct pipe_surface *_dst,
+ const union pipe_color_union *color,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height)
+{
+ struct identity_context *id_pipe = identity_context(_pipe);
+ struct identity_surface *id_surface_dst = identity_surface(_dst);
+ struct pipe_context *pipe = id_pipe->pipe;
+ struct pipe_surface *dst = id_surface_dst->surface;
+
+ pipe->clear_render_target(pipe,
+ dst,
+ color,
+ dstx,
+ dsty,
+ width,
+ height);
+}
+static void
+identity_clear_depth_stencil(struct pipe_context *_pipe,
+ struct pipe_surface *_dst,
+ unsigned clear_flags,
+ double depth,
+ unsigned stencil,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height)
{
struct identity_context *id_pipe = identity_context(_pipe);
+ struct identity_surface *id_surface_dst = identity_surface(_dst);
struct pipe_context *pipe = id_pipe->pipe;
+ struct pipe_surface *dst = id_surface_dst->surface;
+
+ pipe->clear_depth_stencil(pipe,
+ dst,
+ clear_flags,
+ depth,
+ stencil,
+ dstx,
+ dsty,
+ width,
+ height);
- pipe->flush(pipe,
- flags,
- fence);
}
-static unsigned int
-identity_is_resource_referenced(struct pipe_context *_pipe,
- struct pipe_resource *_resource,
- unsigned face,
- unsigned level)
+static void
+identity_flush(struct pipe_context *_pipe,
+ struct pipe_fence_handle **fence,
+ enum pipe_flush_flags flags)
{
struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_resource *id_resource = identity_resource(_resource);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_resource *resource = id_resource->resource;
- return pipe->is_resource_referenced(pipe,
- resource,
- face,
- level);
+ pipe->flush(pipe, fence, flags);
}
static struct pipe_sampler_view *
identity_sampler_view(_view));
}
-static struct pipe_transfer *
-identity_context_get_transfer(struct pipe_context *_context,
- struct pipe_resource *_resource,
- struct pipe_subresource sr,
- unsigned usage,
- const struct pipe_box *box)
+static struct pipe_surface *
+identity_context_create_surface(struct pipe_context *_pipe,
+ struct pipe_resource *_resource,
+ const struct pipe_surface *templ)
{
- struct identity_context *id_context = identity_context(_context);
+ struct identity_context *id_context = identity_context(_pipe);
struct identity_resource *id_resource = identity_resource(_resource);
- struct pipe_context *context = id_context->pipe;
+ struct pipe_context *pipe = id_context->pipe;
struct pipe_resource *resource = id_resource->resource;
- struct pipe_transfer *result;
+ struct pipe_surface *result;
- result = context->get_transfer(context,
- resource,
- sr,
- usage,
- box);
+ result = pipe->create_surface(pipe,
+ resource,
+ templ);
if (result)
- return identity_transfer_create(id_context, id_resource, result);
+ return identity_surface_create(id_context, id_resource, result);
return NULL;
}
static void
-identity_context_transfer_destroy(struct pipe_context *_pipe,
- struct pipe_transfer *_transfer)
+identity_context_surface_destroy(struct pipe_context *_pipe,
+ struct pipe_surface *_surf)
{
- identity_transfer_destroy(identity_context(_pipe),
- identity_transfer(_transfer));
+ identity_surface_destroy(identity_context(_pipe),
+ identity_surface(_surf));
}
static void *
identity_context_transfer_map(struct pipe_context *_context,
- struct pipe_transfer *_transfer)
+ struct pipe_resource *_resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ struct pipe_transfer **transfer)
{
struct identity_context *id_context = identity_context(_context);
- struct identity_transfer *id_transfer = identity_transfer(_transfer);
+ struct identity_resource *id_resource = identity_resource(_resource);
struct pipe_context *context = id_context->pipe;
- struct pipe_transfer *transfer = id_transfer->transfer;
+ struct pipe_resource *resource = id_resource->resource;
+ struct pipe_transfer *result;
+ void *map;
- return context->transfer_map(context,
- transfer);
-}
+ map = context->transfer_map(context,
+ resource,
+ level,
+ usage,
+ box, &result);
+ if (!map)
+ return NULL;
+ *transfer = identity_transfer_map(id_context, id_resource, result);
+ return *transfer ? map : NULL;
+}
static void
identity_context_transfer_flush_region(struct pipe_context *_context,
context->transfer_unmap(context,
transfer);
+
+ identity_transfer_destroy(identity_context(_context),
+ identity_transfer(_transfer));
}
static void
identity_context_transfer_inline_write(struct pipe_context *_context,
struct pipe_resource *_resource,
- struct pipe_subresource sr,
+ unsigned level,
unsigned usage,
const struct pipe_box *box,
const void *data,
unsigned stride,
- unsigned slice_stride)
+ unsigned layer_stride)
{
struct identity_context *id_context = identity_context(_context);
struct identity_resource *id_resource = identity_resource(_resource);
context->transfer_inline_write(context,
resource,
- sr,
+ level,
usage,
box,
data,
stride,
- slice_stride);
+ layer_stride);
}
return NULL;
}
- id_pipe->base.winsys = NULL;
id_pipe->base.screen = _screen;
id_pipe->base.priv = pipe->priv; /* expose wrapped data */
id_pipe->base.draw = NULL;
id_pipe->base.destroy = identity_destroy;
- id_pipe->base.draw_arrays = identity_draw_arrays;
- id_pipe->base.draw_elements = identity_draw_elements;
- id_pipe->base.draw_range_elements = identity_draw_range_elements;
+ id_pipe->base.draw_vbo = identity_draw_vbo;
id_pipe->base.create_query = identity_create_query;
id_pipe->base.destroy_query = identity_destroy_query;
id_pipe->base.begin_query = identity_begin_query;
id_pipe->base.set_fragment_sampler_views = identity_set_fragment_sampler_views;
id_pipe->base.set_vertex_sampler_views = identity_set_vertex_sampler_views;
id_pipe->base.set_vertex_buffers = identity_set_vertex_buffers;
+ id_pipe->base.set_index_buffer = identity_set_index_buffer;
id_pipe->base.resource_copy_region = identity_resource_copy_region;
- id_pipe->base.resource_fill_region = identity_resource_fill_region;
id_pipe->base.clear = identity_clear;
+ id_pipe->base.clear_render_target = identity_clear_render_target;
+ id_pipe->base.clear_depth_stencil = identity_clear_depth_stencil;
id_pipe->base.flush = identity_flush;
- id_pipe->base.is_resource_referenced = identity_is_resource_referenced;
+ id_pipe->base.create_surface = identity_context_create_surface;
+ id_pipe->base.surface_destroy = identity_context_surface_destroy;
id_pipe->base.create_sampler_view = identity_context_create_sampler_view;
id_pipe->base.sampler_view_destroy = identity_context_sampler_view_destroy;
- id_pipe->base.get_transfer = identity_context_get_transfer;
- id_pipe->base.transfer_destroy = identity_context_transfer_destroy;
id_pipe->base.transfer_map = identity_context_transfer_map;
id_pipe->base.transfer_unmap = identity_context_transfer_unmap;
id_pipe->base.transfer_flush_region = identity_context_transfer_flush_region;
id_pipe->base.transfer_inline_write = identity_context_transfer_inline_write;
+ id_pipe->base.blit = identity_blit;
id_pipe->pipe = pipe;