Commit
b9ba8492 removes an unneeded pipe_surface_release() from
st_render_texture() and exposes a bug in the backed surface view
creation. Currently a backed surface view for a conflicted surface view
is created at framebuffer emit time. But if shader sampler views are changed
but framebuffer surface views remain unchanged, emit_framebuffer() will not
be called and conflicted surface views will not be detected.
To fix this, also check for conflicted surface views when setting sampler
views. If there is any conflicted surface views, enable the
framebuffer dirty bit so that the framebuffer emit code has a chance to
create a backed surface view for the conflicted surface view.
Fix cinebench-r11-test regression.
Reviewed-by: Brian Paul <brianp@vmware.com>
#include "svga_cmd.h"
#include "svga_debug.h"
#include "svga_resource_texture.h"
+#include "svga_surface.h"
+#include "svga_sampler_view.h"
static inline unsigned
svga->dirty |= SVGA_NEW_TEXTURE_FLAGS;
svga->curr.tex_flags.flag_1d = flag_1d;
svga->curr.tex_flags.flag_srgb = flag_srgb;
- }
+ }
+
+ /* Check if any of the sampler view resources collide with the framebuffer
+ * color buffers or depth stencil resource. If so, enable the NEW_FRAME_BUFFER
+ * dirty bit so that emit_framebuffer can be invoked to create backed view
+ * for the conflicted surface view.
+ */
+ for (i = 0; i < svga->curr.framebuffer.nr_cbufs; i++) {
+ struct svga_surface *s = svga_surface(svga->curr.framebuffer.cbufs[i]);
+ if (s) {
+ if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) {
+ svga->dirty |= SVGA_NEW_FRAME_BUFFER;
+ break;
+ }
+ }
+ }
+
+ if (svga->curr.framebuffer.zsbuf) {
+ struct svga_surface *s = svga_surface(svga->curr.framebuffer.zsbuf);
+ if (s) {
+ if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) {
+ svga->dirty |= SVGA_NEW_FRAME_BUFFER;
+ }
+ }
+ }
}
boolean
svga_check_sampler_view_resource_collision(struct svga_context *svga,
- struct svga_winsys_surface *res);
-
+ struct svga_winsys_surface *res,
+ unsigned shader);
#endif
*/
boolean
svga_check_sampler_view_resource_collision(struct svga_context *svga,
- struct svga_winsys_surface *res)
+ struct svga_winsys_surface *res,
+ unsigned shader)
{
struct pipe_screen *screen = svga->pipe.screen;
- unsigned shader, i;
+ unsigned i;
if (svga_screen(screen)->debug.no_surface_view) {
return FALSE;
}
- for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_GEOMETRY; shader++) {
- for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) {
- struct svga_pipe_sampler_view *sv =
- svga_pipe_sampler_view(svga->curr.sampler_views[shader][i]);
+ for (i = 0; i < svga->curr.num_sampler_views[shader]; i++) {
+ struct svga_pipe_sampler_view *sv =
+ svga_pipe_sampler_view(svga->curr.sampler_views[shader][i]);
- if (sv && res == svga_resource_handle(sv->base.texture)) {
- return TRUE;
- }
+ if (sv && res == svga_resource_handle(sv->base.texture)) {
+ return TRUE;
}
}
{
enum pipe_error ret = PIPE_OK;
int try;
+ unsigned shader;
assert(svga_have_vgpu10(svga));
* associated resource. We will then use the cloned surface view for
* render target.
*/
- if (svga_check_sampler_view_resource_collision(svga, s->handle)) {
- SVGA_DBG(DEBUG_VIEWS,
- "same resource used in shaderResource and renderTarget 0x%x\n",
- s->handle);
- s = create_backed_surface_view(svga, s);
+ for (shader = PIPE_SHADER_VERTEX; shader <= PIPE_SHADER_GEOMETRY; shader++) {
+ if (svga_check_sampler_view_resource_collision(svga, s->handle, shader)) {
+ SVGA_DBG(DEBUG_VIEWS,
+ "same resource used in shaderResource and renderTarget 0x%x\n",
+ s->handle);
+ s = create_backed_surface_view(svga, s);
+ break;
+ }
}
if (s->view_id == SVGA3D_INVALID_ID) {