Commit a23985c2 authored by Keith Whitwell's avatar Keith Whitwell

identity: compiles with pipe_resources

parent d0d63094
......@@ -61,7 +61,7 @@ identity_draw_arrays(struct pipe_context *_pipe,
static void
identity_draw_elements(struct pipe_context *_pipe,
struct pipe_buffer *_indexResource,
struct pipe_resource *_indexResource,
unsigned indexSize,
unsigned prim,
unsigned start,
......@@ -587,7 +587,7 @@ identity_set_vertex_buffers(struct pipe_context *_pipe,
if (num_buffers) {
memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers));
for (i = 0; i < num_buffers; i++)
unwrapped_buffers[i].resource = identity_resource_unwrap(_resources[i].resource);
unwrapped_buffers[i].buffer = identity_resource_unwrap(_buffers[i].buffer);
buffers = unwrapped_buffers;
}
......@@ -678,44 +678,31 @@ identity_flush(struct pipe_context *_pipe,
}
static unsigned int
identity_is_texture_referenced(struct pipe_context *_pipe,
struct pipe_texture *_texture,
identity_is_resource_referenced(struct pipe_context *_pipe,
struct pipe_resource *_texture,
unsigned face,
unsigned level)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct identity_texture *id_texture = identity_texture(_texture);
struct identity_resource *id_resource = identity_resource(_texture);
struct pipe_context *pipe = id_pipe->pipe;
struct pipe_texture *texture = id_texture->texture;
struct pipe_resource *texture = id_resource->resource;
return pipe->is_texture_referenced(pipe,
return pipe->is_resource_referenced(pipe,
texture,
face,
level);
}
static unsigned int
identity_is_resource_referenced(struct pipe_context *_pipe,
struct pipe_resource *_resource)
{
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);
}
static struct pipe_sampler_view *
identity_create_sampler_view(struct pipe_context *pipe,
struct pipe_texture *texture,
struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct identity_context *id_pipe = identity_context(pipe);
struct identity_texture *id_texture = identity_texture(texture);
struct identity_resource *id_resource = identity_resource(texture);
struct pipe_context *pipe_unwrapped = id_pipe->pipe;
struct pipe_texture *texture_unwrapped = id_texture->texture;
struct pipe_resource *texture_unwrapped = id_resource->resource;
struct identity_sampler_view *view = malloc(sizeof(struct identity_sampler_view));
view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped,
......@@ -725,7 +712,7 @@ identity_create_sampler_view(struct pipe_context *pipe,
view->base = *templ;
view->base.reference.count = 1;
view->base.texture = NULL;
pipe_texture_reference(&view->base.texture, texture);
pipe_resource_reference(&view->base.texture, texture);
view->base.context = pipe;
return &view->base;
......@@ -743,42 +730,31 @@ identity_sampler_view_destroy(struct pipe_context *pipe,
pipe_unwrapped->sampler_view_destroy(pipe_unwrapped,
view_unwrapped);
pipe_texture_reference(&view->texture, NULL);
pipe_resource_reference(&view->texture, NULL);
free(view);
}
static struct pipe_transfer *
identity_context_get_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 pipe_resource *_texture,
struct pipe_subresource sr,
enum pipe_transfer_usage usage,
const struct pipe_box *box)
{
struct identity_context *id_context = identity_context(_context);
struct identity_texture *id_texture = identity_texture(_texture);
struct identity_resource *id_resource = identity_resource(_texture);
struct pipe_context *context = id_context->pipe;
struct pipe_texture *texture = id_texture->texture;
struct pipe_resource *texture = id_resource->resource;
struct pipe_transfer *result;
result = context->tex_transfer(context,
texture,
face,
level,
zslice,
usage,
x,
y,
w,
h);
result = context->get_transfer(context,
texture,
sr,
usage,
box);
if (result)
return identity_transfer_create(id_context, id_texture, result);
return identity_transfer_create(id_context, id_resource, result);
return NULL;
}
......@@ -878,11 +854,11 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
id_pipe->base.surface_fill = identity_surface_fill;
id_pipe->base.clear = identity_clear;
id_pipe->base.flush = identity_flush;
id_pipe->base.is_texture_referenced = identity_is_texture_referenced;
id_pipe->base.is_resource_referenced = identity_is_resource_referenced;
id_pipe->base.is_resource_referenced = identity_is_resource_referenced;
id_pipe->base.create_sampler_view = identity_create_sampler_view;
id_pipe->base.sampler_view_destroy = identity_sampler_view_destroy;
id_pipe->base.tex_transfer = identity_context_get_transfer;
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;
......
......@@ -79,7 +79,7 @@ identity_surface_create(struct identity_resource *id_resource,
if(!surface)
goto error;
assert(surface->resource == id_resource->resource);
assert(surface->texture == id_resource->resource);
id_surface = CALLOC_STRUCT(identity_surface);
if(!id_surface)
......@@ -88,8 +88,8 @@ identity_surface_create(struct identity_resource *id_resource,
memcpy(&id_surface->base, surface, sizeof(struct pipe_surface));
pipe_reference_init(&id_surface->base.reference, 1);
id_surface->base.resource = NULL;
pipe_resource_reference(&id_surface->base.resource, &id_resource->base);
id_surface->base.texture = NULL;
pipe_resource_reference(&id_surface->base.texture, &id_resource->base);
id_surface->surface = surface;
return &id_surface->base;
......@@ -102,7 +102,7 @@ error:
void
identity_surface_destroy(struct identity_surface *id_surface)
{
pipe_resource_reference(&id_surface->base.resource, NULL);
pipe_resource_reference(&id_surface->base.texture, NULL);
pipe_surface_reference(&id_surface->surface, NULL);
FREE(id_surface);
}
......
......@@ -103,7 +103,7 @@ identity_surface(struct pipe_surface *_surface)
{
if(!_surface)
return NULL;
(void)identity_resource(_surface->resource);
(void)identity_resource(_surface->texture);
return (struct identity_surface *)_surface;
}
......
......@@ -118,75 +118,76 @@ identity_screen_context_create(struct pipe_screen *_screen,
return NULL;
}
static struct pipe_texture *
identity_screen_texture_create(struct pipe_screen *_screen,
const struct pipe_texture *templat)
static struct pipe_resource *
identity_screen_resource_create(struct pipe_screen *_screen,
const struct pipe_resource *templat)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
struct pipe_texture *result;
struct pipe_resource *result;
result = screen->texture_create(screen,
result = screen->resource_create(screen,
templat);
if (result)
return identity_texture_create(id_screen, result);
return identity_resource_create(id_screen, result);
return NULL;
}
static struct pipe_texture *
identity_screen_texture_from_handle(struct pipe_screen *_screen,
const struct pipe_texture *templ,
static struct pipe_resource *
identity_screen_resource_from_handle(struct pipe_screen *_screen,
const struct pipe_resource *templ,
struct winsys_handle *handle)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
struct pipe_texture *result;
struct pipe_resource *result;
/* TODO trace call */
result = screen->texture_from_handle(screen, templ, handle);
result = screen->resource_from_handle(screen, templ, handle);
result = identity_texture_create(identity_screen(_screen), result);
result = identity_resource_create(identity_screen(_screen), result);
return result;
}
static boolean
identity_screen_texture_get_handle(struct pipe_screen *_screen,
struct pipe_texture *_texture,
identity_screen_resource_get_handle(struct pipe_screen *_screen,
struct pipe_resource *_texture,
struct winsys_handle *handle)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct identity_texture *id_texture = identity_texture(_texture);
struct identity_resource *id_resource = identity_resource(_texture);
struct pipe_screen *screen = id_screen->screen;
struct pipe_texture *texture = id_texture->texture;
struct pipe_resource *texture = id_resource->resource;
/* TODO trace call */
return screen->texture_get_handle(screen, texture, handle);
return screen->resource_get_handle(screen, texture, handle);
}
static void
identity_screen_texture_destroy(struct pipe_texture *_texture)
identity_screen_resource_destroy(struct pipe_screen *screen,
struct pipe_resource *_texture)
{
identity_texture_destroy(identity_texture(_texture));
identity_resource_destroy(identity_resource(_texture));
}
static struct pipe_surface *
identity_screen_get_tex_surface(struct pipe_screen *_screen,
struct pipe_texture *_texture,
struct pipe_resource *_texture,
unsigned face,
unsigned level,
unsigned zslice,
unsigned usage)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct identity_texture *id_texture = identity_texture(_texture);
struct identity_resource *id_resource = identity_resource(_texture);
struct pipe_screen *screen = id_screen->screen;
struct pipe_texture *texture = id_texture->texture;
struct pipe_resource *texture = id_resource->resource;
struct pipe_surface *result;
result = screen->get_tex_surface(screen,
......@@ -197,7 +198,7 @@ identity_screen_get_tex_surface(struct pipe_screen *_screen,
usage);
if (result)
return identity_surface_create(id_texture, result);
return identity_surface_create(id_resource, result);
return NULL;
}
......@@ -209,53 +210,28 @@ identity_screen_tex_surface_destroy(struct pipe_surface *_surface)
static struct pipe_buffer *
static struct pipe_resource *
identity_screen_user_buffer_create(struct pipe_screen *_screen,
void *ptr,
unsigned bytes)
unsigned bytes,
unsigned usage)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
struct pipe_buffer *result;
struct pipe_resource *result;
result = screen->user_buffer_create(screen,
ptr,
bytes);
bytes,
usage);
if (result)
return identity_buffer_create(id_screen, result);
return identity_resource_create(id_screen, result);
return NULL;
}
static struct pipe_video_surface *
identity_screen_video_surface_create(struct pipe_screen *_screen,
enum pipe_video_chroma_format chroma_format,
unsigned width,
unsigned height)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
struct pipe_video_surface *result;
result = screen->video_surface_create(screen,
chroma_format,
width,
height);
if (result) {
return identity_video_surface_create(id_screen, result);
}
return NULL;
}
static void
identity_screen_video_surface_destroy(struct pipe_video_surface *_vsfc)
{
identity_video_surface_destroy(identity_video_surface(_vsfc));
}
static void
identity_screen_flush_frontbuffer(struct pipe_screen *_screen,
struct pipe_surface *_surface,
......@@ -329,29 +305,13 @@ identity_screen_create(struct pipe_screen *screen)
id_screen->base.get_paramf = identity_screen_get_paramf;
id_screen->base.is_format_supported = identity_screen_is_format_supported;
id_screen->base.context_create = identity_screen_context_create;
id_screen->base.texture_create = identity_screen_texture_create;
id_screen->base.texture_from_handle = identity_screen_texture_from_handle;
id_screen->base.texture_get_handle = identity_screen_texture_get_handle;
id_screen->base.texture_destroy = identity_screen_texture_destroy;
id_screen->base.resource_create = identity_screen_resource_create;
id_screen->base.resource_from_handle = identity_screen_resource_from_handle;
id_screen->base.resource_get_handle = identity_screen_resource_get_handle;
id_screen->base.resource_destroy = identity_screen_resource_destroy;
id_screen->base.get_tex_surface = identity_screen_get_tex_surface;
id_screen->base.tex_surface_destroy = identity_screen_tex_surface_destroy;
id_screen->base.buffer_create = identity_screen_buffer_create;
id_screen->base.user_buffer_create = identity_screen_user_buffer_create;
if (screen->buffer_map)
id_screen->base.buffer_map = identity_screen_buffer_map;
if (screen->buffer_map_range)
id_screen->base.buffer_map_range = identity_screen_buffer_map_range;
if (screen->buffer_flush_mapped_range)
id_screen->base.buffer_flush_mapped_range = identity_screen_buffer_flush_mapped_range;
if (screen->buffer_unmap)
id_screen->base.buffer_unmap = identity_screen_buffer_unmap;
id_screen->base.buffer_destroy = identity_screen_buffer_destroy;
if (screen->video_surface_create) {
id_screen->base.video_surface_create = identity_screen_video_surface_create;
}
if (screen->video_surface_destroy) {
id_screen->base.video_surface_destroy = identity_screen_video_surface_destroy;
}
id_screen->base.flush_frontbuffer = identity_screen_flush_frontbuffer;
id_screen->base.fence_reference = identity_screen_fence_reference;
id_screen->base.fence_signalled = identity_screen_fence_signalled;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment