#include "pipe/p_defines.h"
#include "util/u_math.h"
+#include "svga_resource_texture.h"
#include "svga_sampler_view.h"
#include "svga_winsys.h"
#include "svga_context.h"
/**
* Called when tearing down a context to free resources and samplers.
*/
-void svga_cleanup_tss_binding(struct svga_context *svga)
+void
+svga_cleanup_tss_binding(struct svga_context *svga)
{
const enum pipe_shader_type shader = PIPE_SHADER_FRAGMENT;
unsigned i;
struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
if (view) {
svga_sampler_view_reference(&view->v, NULL);
- pipe_sampler_view_release(&svga->pipe,
- &svga->curr.sampler_views[shader][i]);
+ pipe_sampler_view_reference(&svga->curr.sampler_views[shader][i],
+ NULL);
pipe_resource_reference(&view->texture, NULL);
view->dirty = TRUE;
}
view->max_lod != max_lod) {
svga_sampler_view_reference(&view->v, NULL);
- pipe_resource_reference( &view->texture, texture );
+ pipe_resource_reference(&view->texture, texture);
view->dirty = TRUE;
view->min_lod = min_lod;
static enum pipe_error
-update_tss_binding(struct svga_context *svga,
- unsigned dirty )
+update_tss_binding(struct svga_context *svga, unsigned dirty)
{
const enum pipe_shader_type shader = PIPE_SHADER_FRAGMENT;
boolean reemit = svga->rebind.flags.texture_samplers;
unsigned i;
- unsigned count = MAX2( svga->curr.num_sampler_views[shader],
- svga->state.hw_draw.num_views );
+ unsigned count = MAX2(svga->curr.num_sampler_views[shader],
+ svga->state.hw_draw.num_views);
struct bind_queue queue;
return PIPE_OK;
queue.bind_count = 0;
-
+
for (i = 0; i < count; i++) {
emit_tex_binding_unit(svga, i,
svga->curr.sampler[shader][i],
&queue);
}
+ svga->state.hw_draw.num_backed_views = 0;
+
if (queue.bind_count) {
SVGA3dTextureState *ts;
- if (SVGA3D_BeginSetTextureState( svga->swc,
- &ts,
- queue.bind_count ) != PIPE_OK)
+ if (SVGA3D_BeginSetTextureState(svga->swc, &ts,
+ queue.bind_count) != PIPE_OK)
goto fail;
for (i = 0; i < queue.bind_count; i++) {
struct svga_winsys_surface *handle;
+ struct svga_hw_view_state *view = queue.bind[i].view;
ts[i].stage = queue.bind[i].unit;
ts[i].name = SVGA3D_TS_BIND_TEXTURE;
- if (queue.bind[i].view->v) {
- handle = queue.bind[i].view->v->handle;
+ if (view->v) {
+ handle = view->v->handle;
+
+ /* Keep track of number of views with a backing copy
+ * of texture.
+ */
+ if (handle != svga_texture(view->texture)->handle)
+ svga->state.hw_draw.num_backed_views++;
}
else {
handle = NULL;
NULL,
handle,
SVGA_RELOC_READ);
-
+
queue.bind[i].view->dirty = FALSE;
}
- SVGA_FIFOCommitAll( svga->swc );
+ SVGA_FIFOCommitAll(svga->swc);
}
svga->rebind.flags.texture_samplers = FALSE;
}
/* Polygon stipple */
- if (svga->curr.rast->templ.poly_stipple_enable) {
+ if (svga->curr.rast && svga->curr.rast->templ.poly_stipple_enable) {
const unsigned unit = svga->state.hw_draw.fs->pstipple_sampler_unit;
struct svga_hw_view_state *view = &svga->state.hw_draw.views[unit];
if (queue.bind_count) {
SVGA3dTextureState *ts;
- ret = SVGA3D_BeginSetTextureState(svga->swc,
- &ts,
- queue.bind_count);
+ ret = SVGA3D_BeginSetTextureState(svga->swc, &ts, queue.bind_count);
if (ret != PIPE_OK) {
return ret;
}
struct svga_tracked_state svga_hw_tss_binding = {
"texture binding emit",
+ SVGA_NEW_FRAME_BUFFER |
SVGA_NEW_TEXTURE_BINDING |
SVGA_NEW_STIPPLE |
SVGA_NEW_SAMPLER,
};
-/***********************************************************************
- */
struct ts_queue {
unsigned ts_count;
static inline void
-svga_queue_tss( struct ts_queue *q,
- unsigned unit,
- unsigned tss,
- unsigned value )
+svga_queue_tss(struct ts_queue *q, unsigned unit, unsigned tss, unsigned value)
{
assert(q->ts_count < ARRAY_SIZE(q->ts));
q->ts[q->ts_count].stage = unit;
assert(unit < ARRAY_SIZE(svga->state.hw_draw.ts)); \
STATIC_ASSERT(SVGA3D_TS_##token < ARRAY_SIZE(svga->state.hw_draw.ts[unit])); \
if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \
- svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \
+ svga_queue_tss(queue, unit, SVGA3D_TS_##token, val); \
svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \
} \
} while (0)
assert(unit < ARRAY_SIZE(svga->state.hw_draw.ts)); \
STATIC_ASSERT(SVGA3D_TS_##token < ARRAY_SIZE(svga->state.hw_draw.ts[unit])); \
if (svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] != val) { \
- svga_queue_tss( queue, unit, SVGA3D_TS_##token, val ); \
+ svga_queue_tss(queue, unit, SVGA3D_TS_##token, val); \
svga->state.hw_draw.ts[unit][SVGA3D_TS_##token] = val; \
} \
} while (0)
}
static enum pipe_error
-update_tss(struct svga_context *svga,
- unsigned dirty )
+update_tss(struct svga_context *svga, unsigned dirty)
{
const enum pipe_shader_type shader = PIPE_SHADER_FRAGMENT;
unsigned i;
svga->polygon_stipple.sampler,
&queue);
}
-
+
if (queue.ts_count) {
SVGA3dTextureState *ts;
- if (SVGA3D_BeginSetTextureState( svga->swc,
- &ts,
- queue.ts_count ) != PIPE_OK)
+ if (SVGA3D_BeginSetTextureState(svga->swc, &ts, queue.ts_count) != PIPE_OK)
goto fail;
- memcpy( ts,
- queue.ts,
- queue.ts_count * sizeof queue.ts[0]);
-
- SVGA_FIFOCommitAll( svga->swc );
+ memcpy(ts, queue.ts, queue.ts_count * sizeof queue.ts[0]);
+
+ SVGA_FIFOCommitAll(svga->swc);
}
return PIPE_OK;