#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_thread.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
+#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "svga_debug.h"
#include "svga_screen_buffer.h"
-#include <util/u_string.h>
-
/* XXX: This isn't a real hardware flag, but just a hack for kernel to
* know about primary surfaces. Find a better way to accomplish this.
{
switch(format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
return SVGA3D_A8R8G8B8;
- case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
return SVGA3D_X8R8G8B8;
/* Required for GL2.1:
*/
- case PIPE_FORMAT_A8R8G8B8_SRGB:
+ case PIPE_FORMAT_B8G8R8A8_SRGB:
return SVGA3D_A8R8G8B8;
- case PIPE_FORMAT_R5G6B5_UNORM:
+ case PIPE_FORMAT_B5G6R5_UNORM:
return SVGA3D_R5G6B5;
- case PIPE_FORMAT_A1R5G5B5_UNORM:
+ case PIPE_FORMAT_B5G5R5A1_UNORM:
return SVGA3D_A1R5G5B5;
- case PIPE_FORMAT_A4R4G4B4_UNORM:
+ case PIPE_FORMAT_B4G4R4A4_UNORM:
return SVGA3D_A4R4G4B4;
*/
case PIPE_FORMAT_Z16_UNORM:
return SVGA3D_Z_D16;
- case PIPE_FORMAT_Z24S8_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
return SVGA3D_Z_D24S8;
- case PIPE_FORMAT_Z24X8_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
return SVGA3D_Z_D24X8;
case PIPE_FORMAT_A8_UNORM:
svga_translate_format_render(enum pipe_format format)
{
switch(format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- case PIPE_FORMAT_A1R5G5B5_UNORM:
- case PIPE_FORMAT_A4R4G4B4_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_Z24S8_UNORM:
- case PIPE_FORMAT_Z24X8_UNORM:
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_B5G5R5A1_UNORM:
+ case PIPE_FORMAT_B4G4R4A4_UNORM:
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
case PIPE_FORMAT_Z32_UNORM:
case PIPE_FORMAT_Z16_UNORM:
case PIPE_FORMAT_L8_UNORM:
st->base.x + st->base.width,
y + h,
st->base.zslice + 1,
- pf_get_blocksize(texture->base.format)*8/
- (pf_get_blockwidth(texture->base.format)*pf_get_blockheight(texture->base.format)));
+ util_format_get_blocksize(texture->base.format)*8/
+ (util_format_get_blockwidth(texture->base.format)*util_format_get_blockheight(texture->base.format)));
box.x = st->base.x;
box.y = y;
if(transfer == SVGA3D_READ_HOST_VRAM) {
svga_screen_flush(screen, &fence);
sws->fence_finish(sws, fence, 0);
- //sws->fence_reference(sws, &fence, NULL);
+ sws->fence_reference(sws, &fence, NULL);
}
}
else {
unsigned y, h, srcy;
- unsigned blockheight = pf_get_blockheight(st->base.texture->format);
+ unsigned blockheight = util_format_get_blockheight(st->base.texture->format);
h = st->hw_nblocksy * blockheight;
srcy = 0;
for(y = 0; y < st->base.height; y += h) {
if(y) {
svga_screen_flush(screen, &fence);
sws->fence_finish(sws, fence, 0);
- //sws->fence_reference(sws, &fence, NULL);
+ sws->fence_reference(sws, &fence, NULL);
}
hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
const struct pipe_texture *templat)
{
struct svga_screen *svgascreen = svga_screen(screen);
- struct svga_winsys_screen *sws = svgascreen->sws;
struct svga_texture *tex = CALLOC_STRUCT(svga_texture);
unsigned width, height, depth;
- SVGA3dSurfaceFlags flags = 0;
- SVGA3dSurfaceFormat format;
- SVGA3dSize size;
- uint32 numFaces;
- uint32 numMipLevels;
unsigned level;
if (!tex)
depth = u_minify(depth, 1);
}
- size.width = templat->width0;
- size.height = templat->height0;
- size.depth = templat->depth0;
+ tex->key.flags = 0;
+ tex->key.size.width = templat->width0;
+ tex->key.size.height = templat->height0;
+ tex->key.size.depth = templat->depth0;
if(templat->target == PIPE_TEXTURE_CUBE) {
- flags |= SVGA3D_SURFACE_CUBEMAP;
- numFaces = 6;
+ tex->key.flags |= SVGA3D_SURFACE_CUBEMAP;
+ tex->key.numFaces = 6;
}
else {
- numFaces = 1;
+ tex->key.numFaces = 1;
}
+ tex->key.cachable = 1;
+
if(templat->tex_usage & PIPE_TEXTURE_USAGE_SAMPLER)
- flags |= SVGA3D_SURFACE_HINT_TEXTURE;
+ tex->key.flags |= SVGA3D_SURFACE_HINT_TEXTURE;
+
+ if(templat->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
+ tex->key.cachable = 0;
+ }
+
+ if(templat->tex_usage & PIPE_TEXTURE_USAGE_SHARED) {
+ tex->key.cachable = 0;
+ }
- if(templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY)
- flags |= SVGA3D_SURFACE_HINT_SCANOUT;
+ if(templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) {
+ tex->key.flags |= SVGA3D_SURFACE_HINT_SCANOUT;
+ tex->key.cachable = 0;
+ }
/*
* XXX: Never pass the SVGA3D_SURFACE_HINT_RENDERTARGET hint. Mesa cannot
*/
#if 0
if((templat->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) &&
- !pf_is_compressed(templat->format))
- flags |= SVGA3D_SURFACE_HINT_RENDERTARGET;
+ !util_format_is_s3tc(templat->format))
+ tex->key.flags |= SVGA3D_SURFACE_HINT_RENDERTARGET;
#endif
if(templat->tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
- flags |= SVGA3D_SURFACE_HINT_DEPTHSTENCIL;
+ tex->key.flags |= SVGA3D_SURFACE_HINT_DEPTHSTENCIL;
- numMipLevels = templat->last_level + 1;
+ tex->key.numMipLevels = templat->last_level + 1;
- format = svga_translate_format(templat->format);
- if(format == SVGA3D_FORMAT_INVALID)
+ tex->key.format = svga_translate_format(templat->format);
+ if(tex->key.format == SVGA3D_FORMAT_INVALID)
goto error2;
-
- tex->handle = sws->surface_create(sws, flags, format, size, numFaces, numMipLevels);
+
+ SVGA_DBG(DEBUG_DMA, "surface_create for texture\n", tex->handle);
+ tex->handle = svga_screen_surface_create(svgascreen, &tex->key);
if (tex->handle)
- SVGA_DBG(DEBUG_DMA, "create sid %p (texture)\n", tex->handle);
+ SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture)\n", tex->handle);
return &tex->base;
}
+
+
+
static struct pipe_texture *
-svga_texture_blanket(struct pipe_screen * screen,
- const struct pipe_texture *base,
- const unsigned *stride,
- struct pipe_buffer *buffer)
+svga_screen_texture_from_handle(struct pipe_screen *screen,
+ const struct pipe_texture *base,
+ struct winsys_handle *whandle)
{
- struct svga_texture *tex;
- struct svga_buffer *sbuf = svga_buffer(buffer);
struct svga_winsys_screen *sws = svga_winsys_screen(screen);
+ struct svga_winsys_surface *srf;
+ struct svga_texture *tex;
+ enum SVGA3dSurfaceFormat format = 0;
assert(screen);
/* Only supports one type */
return NULL;
}
- /**
- * We currently can't do texture blanket on
- * SVGA3D_BUFFER. Need to blit to a temporary surface?
- */
+ srf = sws->surface_from_handle(sws, whandle, &format);
- assert(sbuf->handle);
- if (!sbuf->handle)
+ if (!srf)
return NULL;
- if (svga_translate_format(base->format) != sbuf->key.format) {
+ if (svga_translate_format(base->format) != format) {
unsigned f1 = svga_translate_format(base->format);
- unsigned f2 = sbuf->key.format;
+ unsigned f2 = format;
/* It's okay for XRGB and ARGB or depth with/out stencil to get mixed up */
if ( !( (f1 == SVGA3D_X8R8G8B8 && f2 == SVGA3D_A8R8G8B8) ||
return NULL;
tex->base = *base;
+
- if (sbuf->key.format == 1)
- tex->base.format = PIPE_FORMAT_X8R8G8B8_UNORM;
- else if (sbuf->key.format == 2)
- tex->base.format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ if (format == 1)
+ tex->base.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+ else if (format == 2)
+ tex->base.format = PIPE_FORMAT_B8G8R8A8_UNORM;
pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
- sws->surface_reference(sws, &tex->handle, sbuf->handle);
+ SVGA_DBG(DEBUG_DMA, "wrap surface sid %p\n", srf);
+
+ tex->key.cachable = 0;
+ tex->handle = srf;
return &tex->base;
}
+static boolean
+svga_screen_texture_get_handle(struct pipe_screen *screen,
+ struct pipe_texture *texture,
+ struct winsys_handle *whandle)
+{
+ struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen);
+ unsigned stride;
+
+ assert(svga_texture(texture)->key.cachable == 0);
+ svga_texture(texture)->key.cachable = 0;
+ stride = util_format_get_nblocksx(texture->format, texture->width0) *
+ util_format_get_blocksize(texture->format);
+ return sws->surface_get_handle(sws, svga_texture(texture)->handle, stride, whandle);
+}
+
+
static void
svga_texture_destroy(struct pipe_texture *pt)
{
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
SVGA_DBG(DEBUG_DMA, "unref sid %p (texture)\n", tex->handle);
- ss->sws->surface_reference(ss->sws, &tex->handle, NULL);
+ svga_screen_surface_destroy(ss, &tex->key, &tex->handle);
FREE(tex);
}
unsigned start_mip,
unsigned num_mip,
int face_pick,
- int zslice_pick)
+ int zslice_pick,
+ struct svga_host_surface_cache_key *key) /* OUT */
{
struct svga_screen *ss = svga_screen(tex->base.screen);
- struct svga_winsys_screen *sws = ss->sws;
struct svga_winsys_surface *handle;
- int i, j;
- SVGA3dSurfaceFlags flags = 0;
- SVGA3dSize size;
- uint32 numFaces;
- uint32 numMipLevels = num_mip;
+ uint32_t i, j;
unsigned z_offset = 0;
SVGA_DBG(DEBUG_PERF,
"svga: Create surface view: face %d zslice %d mips %d..%d\n",
face_pick, zslice_pick, start_mip, start_mip+num_mip-1);
- size.width = u_minify(tex->base.width0, start_mip);
- size.height = u_minify(tex->base.height0, start_mip);
- size.depth = zslice_pick < 0 ? u_minify(tex->base.depth0, start_mip) : 1;
- assert(size.depth == 1);
+ key->flags = 0;
+ key->format = format;
+ key->numMipLevels = num_mip;
+ key->size.width = u_minify(tex->base.width0, start_mip);
+ key->size.height = u_minify(tex->base.height0, start_mip);
+ key->size.depth = zslice_pick < 0 ? u_minify(tex->base.depth0, start_mip) : 1;
+ key->cachable = 1;
+ assert(key->size.depth == 1);
if(tex->base.target == PIPE_TEXTURE_CUBE && face_pick < 0) {
- flags |= SVGA3D_SURFACE_CUBEMAP;
- numFaces = 6;
+ key->flags |= SVGA3D_SURFACE_CUBEMAP;
+ key->numFaces = 6;
} else {
- numFaces = 1;
+ key->numFaces = 1;
}
- if(format == SVGA3D_FORMAT_INVALID)
+ if(key->format == SVGA3D_FORMAT_INVALID) {
+ key->cachable = 0;
return NULL;
+ }
- handle = sws->surface_create(sws, flags, format, size, numFaces, numMipLevels);
-
- if (!handle)
+ SVGA_DBG(DEBUG_DMA, "surface_create for texture view\n");
+ handle = svga_screen_surface_create(ss, key);
+ if (!handle) {
+ key->cachable = 0;
return NULL;
+ }
- SVGA_DBG(DEBUG_DMA, "create sid %p (texture view)\n", handle);
+ SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture view)\n", handle);
if (face_pick < 0)
face_pick = 0;
if (zslice_pick >= 0)
z_offset = zslice_pick;
- for (i = 0; i < num_mip; i++) {
- for (j = 0; j < numFaces; j++) {
+ for (i = 0; i < key->numMipLevels; i++) {
+ for (j = 0; j < key->numFaces; j++) {
if(tex->defined[j + face_pick][i + start_mip]) {
- unsigned depth = zslice_pick < 0 ? u_minify(tex->base.depth0, i + start_mip) : 1;
- svga_texture_copy_handle(svga_context(pipe), ss,
- tex->handle, 0, 0, z_offset, i + start_mip, j + face_pick,
+ unsigned depth = (zslice_pick < 0 ?
+ u_minify(tex->base.depth0, i + start_mip) :
+ 1);
+
+ svga_texture_copy_handle(svga_context(pipe),
+ ss,
+ tex->handle,
+ 0, 0, z_offset,
+ i + start_mip,
+ j + face_pick,
handle, 0, 0, 0, i, j,
u_minify(tex->base.width0, i + start_mip),
- u_minify(tex->base.height0, i + start_mip), depth);
+ u_minify(tex->base.height0, i + start_mip),
+ depth);
}
}
}
{
struct svga_texture *tex = svga_texture(pt);
struct svga_surface *s;
- struct pipe_surface *ps;
boolean render = flags & PIPE_BUFFER_USAGE_GPU_WRITE ? TRUE : FALSE;
boolean view = FALSE;
SVGA3dSurfaceFormat format;
s = CALLOC_STRUCT(svga_surface);
- ps = &s->base;
- if (!ps)
+ if (!s)
return NULL;
- pipe_reference_init(&ps->reference, 1);
- pipe_texture_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = u_minify(pt->width0, level);
- ps->height = u_minify(pt->height0, level);
- ps->usage = flags;
- ps->level = level;
- ps->face = face;
- ps->zslice = zslice;
+ pipe_reference_init(&s->base.reference, 1);
+ pipe_texture_reference(&s->base.texture, pt);
+ s->base.format = pt->format;
+ s->base.width = u_minify(pt->width0, level);
+ s->base.height = u_minify(pt->height0, level);
+ s->base.usage = flags;
+ s->base.level = level;
+ s->base.face = face;
+ s->base.zslice = zslice;
if (!render)
format = svga_translate_format(pt->format);
view = TRUE;
/* Currently only used for compressed textures */
- if (render && (format != svga_translate_format(pt->format))) {
+ if (render &&
+ format != svga_translate_format(pt->format)) {
view = TRUE;
}
- if (level != 0 && svga_screen(screen)->debug.force_level_surface_view)
+ if (level != 0 &&
+ svga_screen(screen)->debug.force_level_surface_view)
view = TRUE;
if (pt->target == PIPE_TEXTURE_3D)
if (view) {
SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: yes %p, level %u face %u z %u, %p\n",
- pt, level, face, zslice, ps);
+ pt, level, face, zslice, s);
- s->handle = svga_texture_view_surface(NULL, tex, format, level, 1, face, zslice);
+ s->handle = svga_texture_view_surface(NULL, tex, format, level, 1, face, zslice,
+ &s->key);
s->real_face = 0;
s->real_level = 0;
s->real_zslice = 0;
} else {
- struct svga_winsys_screen *sws = svga_winsys_screen(screen);
-
SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: no %p, level %u, face %u, z %u, %p\n",
- pt, level, face, zslice, ps);
+ pt, level, face, zslice, s);
- sws->surface_reference(sws, &s->handle, tex->handle);
+ memset(&s->key, 0, sizeof s->key);
+ s->handle = tex->handle;
s->real_face = face;
s->real_level = level;
s->real_zslice = zslice;
}
- return ps;
+ return &s->base;
}
svga_tex_surface_destroy(struct pipe_surface *surf)
{
struct svga_surface *s = svga_surface(surf);
+ struct svga_texture *t = svga_texture(surf->texture);
struct svga_screen *ss = svga_screen(surf->texture->screen);
- SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
- ss->sws->surface_reference(ss->sws, &s->handle, NULL);
+ if(s->handle != t->handle) {
+ SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
+ svga_screen_surface_destroy(ss, &s->key, &s->handle);
+ }
+
pipe_texture_reference(&surf->texture, NULL);
FREE(surf);
}
return s->dirty && s->handle != tex->handle;
}
-
+/* XXX: Still implementing this as if it was a screen function, but
+ * can now modify it to queue transfers on the context.
+ */
static struct pipe_transfer *
-svga_get_tex_transfer(struct pipe_screen *screen,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage, unsigned x, unsigned y,
- unsigned w, unsigned h)
+svga_get_tex_transfer(struct pipe_context *pipe,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level, unsigned zslice,
+ enum pipe_transfer_usage usage, unsigned x, unsigned y,
+ unsigned w, unsigned h)
{
- struct svga_screen *ss = svga_screen(screen);
+ struct svga_screen *ss = svga_screen(pipe->screen);
struct svga_winsys_screen *sws = ss->sws;
struct svga_transfer *st;
- unsigned nblocksx = pf_get_nblocksx(texture->format, w);
- unsigned nblocksy = pf_get_nblocksy(texture->format, h);
+ unsigned nblocksx = util_format_get_nblocksx(texture->format, w);
+ unsigned nblocksy = util_format_get_nblocksy(texture->format, h);
/* We can't map texture storage directly */
if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
st->base.y = y;
st->base.width = w;
st->base.height = h;
- st->base.stride = nblocksx*pf_get_blocksize(texture->format);
+ st->base.stride = nblocksx*util_format_get_blocksize(texture->format);
st->base.usage = usage;
st->base.face = face;
st->base.level = level;
}
+/* XXX: Still implementing this as if it was a screen function, but
+ * can now modify it to queue transfers on the context.
+ */
static void *
-svga_transfer_map( struct pipe_screen *screen,
+svga_transfer_map( struct pipe_context *pipe,
struct pipe_transfer *transfer )
{
- struct svga_screen *ss = svga_screen(screen);
+ struct svga_screen *ss = svga_screen(pipe->screen);
struct svga_winsys_screen *sws = ss->sws;
struct svga_transfer *st = svga_transfer(transfer);
}
+/* XXX: Still implementing this as if it was a screen function, but
+ * can now modify it to queue transfers on the context.
+ */
static void
-svga_transfer_unmap(struct pipe_screen *screen,
+svga_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
- struct svga_screen *ss = svga_screen(screen);
+ struct svga_screen *ss = svga_screen(pipe->screen);
struct svga_winsys_screen *sws = ss->sws;
struct svga_transfer *st = svga_transfer(transfer);
static void
-svga_tex_transfer_destroy(struct pipe_transfer *transfer)
+svga_tex_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
{
struct svga_texture *tex = svga_texture(transfer->texture);
- struct svga_screen *ss = svga_screen(transfer->texture->screen);
+ struct svga_screen *ss = svga_screen(pipe->screen);
struct svga_winsys_screen *sws = ss->sws;
struct svga_transfer *st = svga_transfer(transfer);
FREE(st);
}
+
+void
+svga_init_texture_functions(struct pipe_context *pipe)
+{
+ pipe->get_tex_transfer = svga_get_tex_transfer;
+ pipe->transfer_map = svga_transfer_map;
+ pipe->transfer_unmap = svga_transfer_unmap;
+ pipe->tex_transfer_destroy = svga_tex_transfer_destroy;
+}
+
+
void
svga_screen_init_texture_functions(struct pipe_screen *screen)
{
screen->texture_create = svga_texture_create;
+ screen->texture_from_handle = svga_screen_texture_from_handle;
+ screen->texture_get_handle = svga_screen_texture_get_handle;
screen->texture_destroy = svga_texture_destroy;
screen->get_tex_surface = svga_get_tex_surface;
screen->tex_surface_destroy = svga_tex_surface_destroy;
- screen->texture_blanket = svga_texture_blanket;
- screen->get_tex_transfer = svga_get_tex_transfer;
- screen->transfer_map = svga_transfer_map;
- screen->transfer_unmap = svga_transfer_unmap;
- screen->tex_transfer_destroy = svga_tex_transfer_destroy;
}
/***********************************************************************
unsigned min_lod, unsigned max_lod)
{
struct svga_screen *ss = svga_screen(pt->screen);
- struct svga_winsys_screen *sws = ss->sws;
struct svga_texture *tex = svga_texture(pt);
struct svga_sampler_view *sv = NULL;
SVGA3dSurfaceFormat format = svga_translate_format(pt->format);
if (min_lod == 0 && max_lod >= pt->last_level)
view = FALSE;
- if (pf_is_compressed(pt->format) && view) {
+ if (util_format_is_s3tc(pt->format) && view) {
format = svga_translate_format_render(pt->format);
}
sv = CALLOC_STRUCT(svga_sampler_view);
pipe_reference_init(&sv->reference, 1);
- sv->texture = tex;
+ pipe_texture_reference(&sv->texture, pt);
sv->min_lod = min_lod;
sv->max_lod = max_lod;
pt->height0,
pt->depth0,
pt->last_level);
- sws->surface_reference(sws, &sv->handle, tex->handle);
+ sv->key.cachable = 0;
+ sv->handle = tex->handle;
return sv;
}
sv->handle = svga_texture_view_surface(pipe, tex, format,
min_lod,
max_lod - min_lod + 1,
- -1, -1);
+ -1, -1,
+ &sv->key);
if (!sv->handle) {
assert(0);
- sws->surface_reference(sws, &sv->handle, tex->handle);
+ sv->key.cachable = 0;
+ sv->handle = tex->handle;
return sv;
}
void
svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v)
{
- struct svga_texture *tex = v->texture;
+ struct svga_texture *tex = svga_texture(v->texture);
unsigned numFaces;
unsigned age = 0;
int i, k;
assert(svga);
- if (v->handle == v->texture->handle)
+ if (v->handle == tex->handle)
return;
age = tex->age;
void
svga_destroy_sampler_view_priv(struct svga_sampler_view *v)
{
- struct svga_screen *ss = svga_screen(v->texture->base.screen);
-
- SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
- ss->sws->surface_reference(ss->sws, &v->handle, NULL);
+ struct svga_texture *tex = svga_texture(v->texture);
+ if(v->handle != tex->handle) {
+ struct svga_screen *ss = svga_screen(v->texture->screen);
+ SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
+ svga_screen_surface_destroy(ss, &v->key, &v->handle);
+ }
+ pipe_texture_reference(&v->texture, NULL);
FREE(v);
}
-
-boolean
-svga_screen_buffer_from_texture(struct pipe_texture *texture,
- struct pipe_buffer **buffer,
- unsigned *stride)
-{
- struct svga_texture *stex = svga_texture(texture);
-
- *buffer = svga_screen_buffer_wrap_surface
- (texture->screen,
- svga_translate_format(texture->format),
- stex->handle);
-
- *stride = pf_get_stride(texture->format, texture->width0);
-
- return *buffer != NULL;
-}
-
-
-struct svga_winsys_surface *
-svga_screen_texture_get_winsys_surface(struct pipe_texture *texture)
-{
- struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen);
- struct svga_winsys_surface *vsurf = NULL;
-
- sws->surface_reference(sws, &vsurf, svga_texture(texture)->handle);
- return vsurf;
-}