This patch validates those sampler views with backing copy
of texture whose original copy has been updated since the
view is last validated.
This is done here at draw time because the texture binding might not
have modified, hence validation is not triggered at state update time,
and yet the texture might have been updated in another context, so
we need to re-validate the sampler view in order to update the backing
copy of the updated texture.
This fixes a rendering flickering issue with Photoshop running in
Linux VM with HWversion 11. The problem is Photoshop renders to texture A
in context X, and then bind texture A to context Y. The first time
when texture A is bound to context Y, cso calls pipe->set_sampler_views().
Validation of sampler views is done, rendering is fine.
But when texture A is rendered to again in context X, and rebound in
context Y, cso skips pipe->set_sampler_views() because texture A is already
bound in context Y. SVGA driver is not given a chance to re-validate
the texture binding, the backing copy of the texture is not updated,
and hence causes black image.
Tested with Photoshop, MTT glretrace, piglit.
Fixes VMware bug
1769103.
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
memset(svga->state.hw_draw.sampler_views, 0,
sizeof(svga->state.hw_draw.sampler_views));
svga->state.hw_draw.num_views = 0;
+ svga->state.hw_draw.num_backed_views = 0;
svga->state.hw_draw.rasterizer_discard = FALSE;
/* Initialize the shader pointers */
unsigned rs[SVGA3D_RS_MAX];
/** VGPU9 texture sampler and bindings state */
unsigned ts[SVGA3D_PIXEL_SAMPLERREG_MAX][SVGA3D_TS_MAX];
+
/** VGPU9 texture views */
unsigned num_views;
+ unsigned num_backed_views; /* views with backing copy of texture */
struct svga_hw_view_state views[PIPE_MAX_SAMPLERS];
+
/** VGPU9 constant buffer values */
float cb[PIPE_SHADER_TYPES][SVGA3D_CONSTREG_MAX][4];
#include "svga_resource.h"
#include "svga_resource_buffer.h"
#include "svga_resource_texture.h"
+#include "svga_sampler_view.h"
#include "svga_shader.h"
#include "svga_surface.h"
#include "svga_winsys.h"
SVGA3dPrimitiveRange *prim;
unsigned i;
+ /* Re-validate those sampler views with backing copy
+ * of texture whose original copy has been updated.
+ * This is done here at draw time because the texture binding might not
+ * have modified, hence validation is not triggered at state update time,
+ * and yet the texture might have been updated in another context, so
+ * we need to re-validate the sampler view in order to update the backing
+ * copy of the updated texture.
+ */
+ if (svga->state.hw_draw.num_backed_views) {
+ for (i = 0; i < svga->state.hw_draw.num_views; i++) {
+ struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
+ struct svga_texture *tex = svga_texture(view->texture);
+ struct svga_sampler_view *sv = view->v;
+ if (sv && tex && sv->handle != tex->handle && sv->age < tex->age)
+ svga_validate_sampler_view(svga, view->v);
+ }
+ }
+
for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
unsigned j = hwtnl->cmd.vdecl_buffer_index[i];
handle = svga_buffer_handle(svga, hwtnl->cmd.vbufs[j].buffer.resource,
#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"
&queue);
}
+ svga->state.hw_draw.num_backed_views = 0;
+
if (queue.bind_count) {
SVGA3dTextureState *ts;
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;