summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/softpipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c10
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_tile_cache.c14
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c140
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.h8
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c14
8 files changed, 70 insertions, 124 deletions
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index d62bfa3d63..20368eadca 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -206,7 +206,7 @@ softpipe_flush_frontbuffer(struct pipe_screen *_screen,
{
struct softpipe_screen *screen = softpipe_screen(_screen);
struct sw_winsys *winsys = screen->winsys;
- struct softpipe_texture *texture = softpipe_texture(surface->texture);
+ struct softpipe_resource *texture = softpipe_resource(surface->texture);
assert(texture->dt);
if (texture->dt)
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index d2eda7324c..4c6d4909f5 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -202,7 +202,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe )
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
struct softpipe_tex_tile_cache *tc = softpipe->tex_cache[i];
if (tc->texture) {
- struct softpipe_texture *spt = softpipe_texture(tc->texture);
+ struct softpipe_resource *spt = softpipe_resource(tc->texture);
if (spt->timestamp != tc->timestamp) {
sp_tex_tile_cache_validate_texture( tc );
/*
@@ -217,7 +217,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe )
struct softpipe_tex_tile_cache *tc = softpipe->vertex_tex_cache[i];
if (tc->texture) {
- struct softpipe_texture *spt = softpipe_texture(tc->texture);
+ struct softpipe_resource *spt = softpipe_resource(tc->texture);
if (spt->timestamp != tc->timestamp) {
sp_tex_tile_cache_validate_texture(tc);
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index 9bd9c514f1..b422d2794f 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -179,7 +179,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
draw_flush(softpipe->draw);
/* note: reference counting */
- pipe_buffer_reference(&softpipe->constants[shader][index], constants);
+ pipe_resource_reference(&softpipe->constants[shader][index], constants);
if(shader == PIPE_SHADER_VERTEX) {
draw_set_mapped_constant_buffer(softpipe->draw, PIPE_SHADER_VERTEX, index,
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index d501952bba..925b55c089 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -123,7 +123,7 @@ softpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
struct pipe_sampler_view *
softpipe_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *resource,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -132,7 +132,7 @@ softpipe_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->resource, resource);
view->context = pipe;
}
@@ -223,10 +223,10 @@ softpipe_set_vertex_sampler_views(struct pipe_context *pipe,
static struct sp_sampler_varient *
get_sampler_varient( unsigned unit,
struct sp_sampler *sampler,
- struct pipe_texture *texture,
+ struct pipe_resource *resource,
unsigned processor )
{
- struct softpipe_texture *sp_texture = softpipe_texture(texture);
+ struct softpipe_texture *sp_texture = softpipe_resource(resource);
struct sp_sampler_varient *v = NULL;
union sp_sampler_key key;
@@ -274,7 +274,7 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe)
*/
for (i = 0; i <= softpipe->vs->max_sampler; i++) {
if (softpipe->vertex_samplers[i]) {
- struct pipe_texture *texture = NULL;
+ struct pipe_resource *texture = NULL;
if (softpipe->vertex_sampler_views[i]) {
texture = softpipe->vertex_sampler_views[i]->texture;
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
index edd8e5c187..d2f422e000 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
@@ -244,13 +244,13 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
}
tc->tex_trans =
- tc->pipe->get_transfer(tc->pipe, tc->texture,
- addr.bits.face,
- addr.bits.level,
- addr.bits.z,
- PIPE_TRANSFER_READ, 0, 0,
- u_minify(tc->texture->width0, addr.bits.level),
- u_minify(tc->texture->height0, addr.bits.level));
+ pipe_get_transfer(tc->pipe, tc->texture,
+ addr.bits.face,
+ addr.bits.level,
+ addr.bits.z,
+ PIPE_TRANSFER_READ, 0, 0,
+ u_minify(tc->texture->width0, addr.bits.level),
+ u_minify(tc->texture->height0, addr.bits.level));
tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index d108bef002..2e8871b820 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -257,49 +257,52 @@ softpipe_tex_surface_destroy(struct pipe_surface *surf)
*/
static struct pipe_transfer *
softpipe_get_transfer(struct pipe_context *pipe,
- struct pipe_resource *resource,
- struct pipe_subresource subresource,
- enum pipe_transfer_usage usage,
- const struct pipe_box *box)
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ enum pipe_transfer_usage usage,
+ const struct pipe_box *box)
{
- struct softpipe_texture *sptex = softpipe_texture(texture);
+ struct softpipe_texture *sptex = softpipe_texture(resource);
struct softpipe_transfer *spt;
- assert(texture);
- assert(level <= texture->last_level);
+ assert(resource);
+ assert(sr.level <= resource->last_level);
/* make sure the requested region is in the image bounds */
- assert(x + w <= u_minify(texture->width0, level));
- assert(y + h <= u_minify(texture->height0, level));
+ assert(box->x + box->width <= u_minify(resource->width0, sr.level));
+ assert(box->y + box->height <= u_minify(resource->height0, sr.level));
+ assert(box->z + box->depth <= u_minify(resource->depth0, sr.level));
spt = CALLOC_STRUCT(softpipe_transfer);
if (spt) {
struct pipe_transfer *pt = &spt->base;
- int nblocksy = util_format_get_nblocksy(texture->format,
- u_minify(texture->height0, level));
- pipe_texture_reference(&resource, texture);
- pt->x = x;
- pt->y = y;
- pt->width = w;
- pt->height = h;
- pt->stride = sptex->stride[level];
- pt->usage = usage;
- pt->face = face;
- pt->level = level;
- pt->zslice = zslice;
-
- spt->offset = sptex->level_offset[level];
-
- if (texture->target == PIPE_TEXTURE_CUBE) {
- spt->offset += face * nblocksy * pt->stride;
+ enum pipe_format format = resource->format;
+ int nblocksy = util_format_get_nblocksy(resource->format,
+ u_minify(resource->height0, sr.level));
+ pipe_resource_reference(&resource, resource);
+ pt->box = *box;
+ pt->stride = sptex->stride[sr.level];
+ //pt->usage = usage;
+ //pt->face = face;
+ //pt->level = level;
+
+ spt->offset = sptex->level_offset[sr.level];
+
+ if (resource->target == PIPE_TEXTURE_CUBE) {
+ spt->offset += sr.face * nblocksy * pt->stride;
}
- else if (texture->target == PIPE_TEXTURE_3D) {
- spt->offset += zslice * nblocksy * pt->stride;
+ else if (resource->target == PIPE_TEXTURE_3D) {
+ spt->offset += box->z * nblocksy * pt->stride;
}
else {
- assert(face == 0);
- assert(zslice == 0);
+ assert(sr.face == 0);
+ assert(box->z == 0);
}
+
+ spt->offset +=
+ box->y / util_format_get_blockheight(format) * spt->base.stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+
return pt;
}
return NULL;
@@ -318,8 +321,8 @@ softpipe_transfer_destroy(struct pipe_context *pipe,
* needed post-processing to put them into hardware layout, this is
* where it would happen. For softpipe, nothing to do.
*/
- assert (transfer->texture);
- pipe_texture_reference(&transfer->texture, NULL);
+ assert (transfer->resource);
+ pipe_resource_reference(&transfer->resource, NULL);
FREE(transfer);
}
@@ -333,11 +336,9 @@ softpipe_transfer_map( struct pipe_context *pipe,
{
ubyte *map, *xfer_map;
struct softpipe_texture *spt;
- enum pipe_format format;
- assert(transfer->texture);
- spt = softpipe_texture(transfer->texture);
- format = transfer->texture->format;
+ assert(transfer->resource);
+ spt = softpipe_texture(transfer->resource);
if (spt->dt) {
/* display target */
@@ -357,16 +358,14 @@ softpipe_transfer_map( struct pipe_context *pipe,
/* May want to different things here depending on read/write nature
* of the map:
*/
- if (transfer->texture && (transfer->usage & PIPE_TRANSFER_WRITE)) {
+ if (transfer->resource && (transfer->usage & PIPE_TRANSFER_WRITE)) {
/* Do something to notify sharing contexts of a texture change.
* In softpipe, that would mean flushing the texture cache.
*/
softpipe_screen(pipe->screen)->timestamp++;
}
- xfer_map = map + softpipe_transfer(transfer)->offset +
- transfer->y / util_format_get_blockheight(format) * transfer->stride +
- transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ xfer_map = map + softpipe_transfer(transfer)->offset;
/*printf("map = %p xfer map = %p\n", map, xfer_map);*/
return xfer_map;
}
@@ -381,8 +380,8 @@ softpipe_transfer_unmap(struct pipe_context *pipe,
{
struct softpipe_texture *spt;
- assert(transfer->texture);
- spt = softpipe_texture(transfer->texture);
+ assert(transfer->resource);
+ spt = softpipe_texture(transfer->resource);
if (spt->dt) {
/* display target */
@@ -397,56 +396,6 @@ softpipe_transfer_unmap(struct pipe_context *pipe,
}
-static struct pipe_video_surface*
-softpipe_video_surface_create(struct pipe_screen *screen,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
-{
- struct softpipe_video_surface *sp_vsfc;
- struct pipe_texture template;
-
- assert(screen);
- assert(width && height);
-
- sp_vsfc = CALLOC_STRUCT(softpipe_video_surface);
- if (!sp_vsfc)
- return NULL;
-
- pipe_reference_init(&sp_vsfc->base.reference, 1);
- sp_vsfc->base.screen = screen;
- sp_vsfc->base.chroma_format = chroma_format;
- /*sp_vsfc->base.surface_format = PIPE_VIDEO_SURFACE_FORMAT_VUYA;*/
- sp_vsfc->base.width = width;
- sp_vsfc->base.height = height;
-
- memset(&template, 0, sizeof(struct pipe_texture));
- template.target = PIPE_TEXTURE_2D;
- template.format = PIPE_FORMAT_B8G8R8X8_UNORM;
- template.last_level = 0;
- /* vl_mpeg12_mc_renderer expects this when it's initialized with pot_buffers=true */
- template.width0 = util_next_power_of_two(width);
- template.height0 = util_next_power_of_two(height);
- template.depth0 = 1;
- template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
-
- sp_vsfc->tex = screen->texture_create(screen, &template);
- if (!sp_vsfc->tex) {
- FREE(sp_vsfc);
- return NULL;
- }
-
- return &sp_vsfc->base;
-}
-
-
-static void
-softpipe_video_surface_destroy(struct pipe_video_surface *vsfc)
-{
- struct softpipe_video_surface *sp_vsfc = softpipe_video_surface(vsfc);
-
- pipe_texture_reference(&sp_vsfc->tex, NULL);
- FREE(sp_vsfc);
-}
void
@@ -461,14 +410,11 @@ softpipe_init_texture_funcs(struct pipe_context *pipe)
void
softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
{
- screen->texture_create = softpipe_texture_create;
- screen->texture_destroy = softpipe_texture_destroy;
+ screen->resource_create = softpipe_texture_create;
+ screen->resource_destroy = softpipe_texture_destroy;
screen->get_tex_surface = softpipe_get_tex_surface;
screen->tex_surface_destroy = softpipe_tex_surface_destroy;
-
- screen->video_surface_create = softpipe_video_surface_create;
- screen->video_surface_destroy = softpipe_video_surface_destroy;
}
diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h
index c0e6ba8a86..5d2e3cea81 100644
--- a/src/gallium/drivers/softpipe/sp_texture.h
+++ b/src/gallium/drivers/softpipe/sp_texture.h
@@ -44,7 +44,7 @@ struct softpipe_context;
struct softpipe_texture
{
- struct pipe_texture base;
+ struct pipe_resource base;
unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS];
unsigned stride[SP_MAX_TEXTURE_2D_LEVELS];
@@ -85,10 +85,10 @@ struct softpipe_video_surface
/** cast wrappers */
-static INLINE struct softpipe_texture *
-softpipe_texture(struct pipe_texture *pt)
+static INLINE struct softpipe_resource *
+softpipe_resource(struct pipe_resource *pt)
{
- return (struct softpipe_texture *) pt;
+ return (struct softpipe_resource *) pt;
}
static INLINE struct softpipe_transfer *
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index cd99a92237..dde9f0e1b9 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -276,14 +276,14 @@ static void
sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
{
struct pipe_transfer *pt = tc->transfer;
- const uint w = tc->transfer->width;
- const uint h = tc->transfer->height;
+ const uint w = tc->transfer->box.width;
+ const uint h = tc->transfer->box.height;
uint x, y;
uint numCleared = 0;
- assert(pt->texture);
+ assert(pt->resource);
/* clear the scratch tile to the clear value */
- clear_tile(&tc->tile, pt->texture->format, tc->clear_val);
+ clear_tile(&tc->tile, pt->resource->format, tc->clear_val);
/* push the tile to all positions marked as clear */
for (y = 0; y < h; y += TILE_SIZE) {
@@ -372,7 +372,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
if (addr.value != tile->addr.value) {
- assert(pt->texture);
+ assert(pt->resource);
if (tile->addr.bits.invalid == 0) {
/* put dirty tile back in framebuffer */
if (tc->depth_stencil) {
@@ -396,10 +396,10 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
if (is_clear_flag_set(tc->clear_flags, addr)) {
/* don't get tile from framebuffer, just clear it */
if (tc->depth_stencil) {
- clear_tile(tile, pt->texture->format, tc->clear_val);
+ clear_tile(tile, pt->resource->format, tc->clear_val);
}
else {
- clear_tile_rgba(tile, pt->texture->format, tc->clear_color);
+ clear_tile_rgba(tile, pt->resource->format, tc->clear_color);
}
clear_clear_flag(tc->clear_flags, addr);
}