projects
/
mesa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
freedreno/a6xx: Convert gmem blits to OUT_REG()
[mesa.git]
/
src
/
gallium
/
drivers
/
svga
/
svga_sampler_view.c
diff --git
a/src/gallium/drivers/svga/svga_sampler_view.c
b/src/gallium/drivers/svga/svga_sampler_view.c
index 6911f13f778b0e1095cc32fc427c91739a7e7f62..d382071fc4938102c21b27ae96050d7af9d78df2 100644
(file)
--- a/
src/gallium/drivers/svga/svga_sampler_view.c
+++ b/
src/gallium/drivers/svga/svga_sampler_view.c
@@
-29,10
+29,12
@@
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "os/os_thread.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "os/os_thread.h"
-#include "util/u_format.h"
+#include "util/
format/
u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#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"
#include "svga_screen.h"
#include "svga_context.h"
#include "svga_resource_texture.h"
@@
-41,22
+43,34
@@
#include "svga_surface.h"
#include "svga_surface.h"
+void
+svga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv)
+{
+ char res[128];
+ debug_describe_resource(res, sv->texture);
+ sprintf(buf, "svga_sampler_view<%s,[%u,%u]>",
+ res, sv->min_lod, sv->max_lod);
+}
+
+
struct svga_sampler_view *
svga_get_tex_sampler_view(struct pipe_context *pipe,
struct pipe_resource *pt,
unsigned min_lod, unsigned max_lod)
{
struct svga_sampler_view *
svga_get_tex_sampler_view(struct pipe_context *pipe,
struct pipe_resource *pt,
unsigned min_lod, unsigned max_lod)
{
- struct svga_screen *ss = svga_screen(pt->screen);
- struct svga_texture *tex = svga_texture(pt);
+ struct svga_context *svga = svga_context(pipe);
+ struct svga_screen *ss = svga_screen(pipe->screen);
+ struct svga_texture *tex = svga_texture(pt);
struct svga_sampler_view *sv = NULL;
struct svga_sampler_view *sv = NULL;
- SVGA3dSurfaceFormat format = svga_translate_format(pt->format);
+ SVGA3dSurface1Flags flags = SVGA3D_SURFACE_HINT_TEXTURE;
+ SVGA3dSurfaceFormat format = svga_translate_format(ss, pt->format,
+ PIPE_BIND_SAMPLER_VIEW);
boolean view = TRUE;
assert(pt);
boolean view = TRUE;
assert(pt);
- assert(min_lod >= 0);
assert(min_lod <= max_lod);
assert(max_lod <= pt->last_level);
assert(min_lod <= max_lod);
assert(max_lod <= pt->last_level);
-
+ assert(!svga_have_vgpu10(svga));
/* Is a view needed */
{
/* Is a view needed */
{
@@
-68,10
+82,6
@@
svga_get_tex_sampler_view(struct pipe_context *pipe,
if (min_lod == 0 && max_lod >= pt->last_level)
view = FALSE;
if (min_lod == 0 && max_lod >= pt->last_level)
view = FALSE;
- if (util_format_is_s3tc(pt->format) && view) {
- format = svga_translate_format_render(pt->format);
- }
-
if (ss->debug.no_sampler_view)
view = FALSE;
if (ss->debug.no_sampler_view)
view = FALSE;
@@
-81,23
+91,31
@@
svga_get_tex_sampler_view(struct pipe_context *pipe,
/* First try the cache */
if (view) {
/* First try the cache */
if (view) {
-
pipe_mutex_lock(
ss->tex_mutex);
+
mtx_lock(&
ss->tex_mutex);
if (tex->cached_view &&
tex->cached_view->min_lod == min_lod &&
tex->cached_view->max_lod == max_lod) {
svga_sampler_view_reference(&sv, tex->cached_view);
if (tex->cached_view &&
tex->cached_view->min_lod == min_lod &&
tex->cached_view->max_lod == max_lod) {
svga_sampler_view_reference(&sv, tex->cached_view);
-
pipe_mutex_unlock(
ss->tex_mutex);
+
mtx_unlock(&
ss->tex_mutex);
SVGA_DBG(DEBUG_VIEWS, "svga: Sampler view: reuse %p, %u %u, last %u\n",
pt, min_lod, max_lod, pt->last_level);
svga_validate_sampler_view(svga_context(pipe), sv);
return sv;
}
SVGA_DBG(DEBUG_VIEWS, "svga: Sampler view: reuse %p, %u %u, last %u\n",
pt, min_lod, max_lod, pt->last_level);
svga_validate_sampler_view(svga_context(pipe), sv);
return sv;
}
-
pipe_mutex_unlock(
ss->tex_mutex);
+
mtx_unlock(&
ss->tex_mutex);
}
sv = CALLOC_STRUCT(svga_sampler_view);
}
sv = CALLOC_STRUCT(svga_sampler_view);
+ if (!sv)
+ return NULL;
+
pipe_reference_init(&sv->reference, 1);
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->min_lod = min_lod;
sv->max_lod = max_lod;
@@
-113,6
+131,8
@@
svga_get_tex_sampler_view(struct pipe_context *pipe,
pt->last_level);
sv->key.cachable = 0;
sv->handle = tex->handle;
pt->last_level);
sv->key.cachable = 0;
sv->handle = tex->handle;
+ debug_reference(&sv->reference,
+ (debug_reference_descriptor)svga_debug_describe_sampler_view, 0);
return sv;
}
return sv;
}
@@
-126,48
+146,61
@@
svga_get_tex_sampler_view(struct pipe_context *pipe,
pt->last_level);
sv->age = tex->age;
pt->last_level);
sv->age = tex->age;
- sv->handle = svga_texture_view_surface(pipe, tex, format,
+ sv->handle = svga_texture_view_surface(svga, tex,
+ PIPE_BIND_SAMPLER_VIEW,
+ flags, format,
min_lod,
max_lod - min_lod + 1,
min_lod,
max_lod - min_lod + 1,
- -1,
-1
,
+ -1,
1, -1, FALSE
,
&sv->key);
if (!sv->handle) {
&sv->key);
if (!sv->handle) {
- assert(0);
sv->key.cachable = 0;
sv->handle = tex->handle;
sv->key.cachable = 0;
sv->handle = tex->handle;
+ debug_reference(&sv->reference,
+ (debug_reference_descriptor)
+ svga_debug_describe_sampler_view, 0);
return sv;
}
return sv;
}
-
pipe_mutex_lock(
ss->tex_mutex);
+
mtx_lock(&
ss->tex_mutex);
svga_sampler_view_reference(&tex->cached_view, sv);
svga_sampler_view_reference(&tex->cached_view, sv);
- pipe_mutex_unlock(ss->tex_mutex);
+ mtx_unlock(&ss->tex_mutex);
+
+ debug_reference(&sv->reference,
+ (debug_reference_descriptor)
+ svga_debug_describe_sampler_view, 0);
return sv;
}
return sv;
}
+
void
void
-svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v)
+svga_validate_sampler_view(struct svga_context *svga,
+ struct svga_sampler_view *v)
{
struct svga_texture *tex = svga_texture(v->texture);
unsigned numFaces;
unsigned age = 0;
{
struct svga_texture *tex = svga_texture(v->texture);
unsigned numFaces;
unsigned age = 0;
- int i, k;
+ int i;
+ unsigned k;
assert(svga);
assert(svga);
+ assert(!svga_have_vgpu10(svga));
if (v->handle == tex->handle)
return;
age = tex->age;
if (v->handle == tex->handle)
return;
age = tex->age;
- if(tex->b.b.target == PIPE_TEXTURE_CUBE)
+ if
(tex->b.b.target == PIPE_TEXTURE_CUBE)
numFaces = 6;
else
numFaces = 1;
for (i = v->min_lod; i <= v->max_lod; i++) {
for (k = 0; k < numFaces; k++) {
numFaces = 6;
else
numFaces = 1;
for (i = v->min_lod; i <= v->max_lod; i++) {
for (k = 0; k < numFaces; k++) {
+ assert(i < ARRAY_SIZE(tex->view_age));
if (v->age < tex->view_age[i])
svga_texture_copy_handle(svga,
tex->handle, 0, 0, 0, i, k,
if (v->age < tex->view_age[i])
svga_texture_copy_handle(svga,
tex->handle, 0, 0, 0, i, k,
@@
-181,16
+214,22
@@
svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *
v->age = age;
}
v->age = age;
}
+
void
svga_destroy_sampler_view_priv(struct svga_sampler_view *v)
{
struct svga_texture *tex = svga_texture(v->texture);
void
svga_destroy_sampler_view_priv(struct svga_sampler_view *v)
{
struct svga_texture *tex = svga_texture(v->texture);
- if(v->handle != tex->handle) {
+ 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);
}
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_resource_reference(&v->texture, NULL);
+
+ /* Note: we're not refcounting the texture resource here to avoid
+ * a circular dependency.
+ */
+ v->texture = NULL;
+
FREE(v);
}
FREE(v);
}