#include "util/u_memory.h"
#include "util/u_string.h"
+#include "svga_format.h"
#include "svga_screen.h"
#include "svga_context.h"
#include "svga_resource_texture.h"
struct svga_texture *tex = svga_texture(pt);
struct svga_sampler_view *sv = NULL;
SVGA3dSurfaceFlags flags = SVGA3D_SURFACE_HINT_TEXTURE;
- SVGA3dSurfaceFormat format = svga_translate_format(ss, pt->format);
+ SVGA3dSurfaceFormat format = svga_translate_format(ss, pt->format, PIPE_BIND_SAMPLER_VIEW);
boolean view = TRUE;
assert(pt);
- assert(min_lod >= 0);
assert(min_lod <= max_lod);
assert(max_lod <= pt->last_level);
}
sv = CALLOC_STRUCT(svga_sampler_view);
+ if (!sv)
+ return NULL;
+
pipe_reference_init(&sv->reference, 1);
- pipe_resource_reference(&sv->texture, pt);
+
+ /* Note: we're not refcounting the texture resource here to avoid
+ * a circular dependency.
+ */
+ sv->texture = pt;
+
sv->min_lod = min_lod;
sv->max_lod = max_lod;
&sv->key);
if (!sv->handle) {
- assert(0);
sv->key.cachable = 0;
sv->handle = tex->handle;
debug_reference(&sv->reference,
struct svga_texture *tex = svga_texture(v->texture);
unsigned numFaces;
unsigned age = 0;
- int i, k;
+ int i;
+ unsigned k;
assert(svga);
for (i = v->min_lod; i <= v->max_lod; i++) {
for (k = 0; k < numFaces; k++) {
+ assert(i < Elements(tex->view_age));
if (v->age < tex->view_age[i])
svga_texture_copy_handle(svga,
tex->handle, 0, 0, 0, i, k,
SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
svga_screen_surface_destroy(ss, &v->key, &v->handle);
}
- pipe_resource_reference(&v->texture, NULL);
+
+ /* Note: we're not refcounting the texture resource here to avoid
+ * a circular dependency.
+ */
+ v->texture = NULL;
+
FREE(v);
}