key->cachable = 1;
key->arraySize = 1;
key->numFaces = 1;
- key->sampleCount = tex->b.b.nr_samples;
+
+ /* single sample surface can be treated as non-multisamples surface */
+ key->sampleCount = tex->b.b.nr_samples > 1 ? tex->b.b.nr_samples : 0;
if (key->sampleCount > 1) {
key->flags |= SVGA3D_SURFACE_MASKABLE_ANTIALIAS;
{
enum pipe_error ret = PIPE_OK;
enum pipe_shader_type shader;
- struct pipe_surface *surf = NULL;
assert(svga_have_vgpu10(svga));
+ assert(s);
SVGA_STATS_TIME_PUSH(svga_sws(svga),
SVGA_STATS_TIME_VALIDATESURFACEVIEW);
"same resource used in shaderResource and renderTarget 0x%x\n",
s->handle);
s = create_backed_surface_view(svga, s);
- if (!s)
- goto done;
-
+ /* s may be null here if the function failed */
break;
}
}
- if (s->view_id == SVGA3D_INVALID_ID) {
+ if (s && s->view_id == SVGA3D_INVALID_ID) {
SVGA3dResourceType resType;
SVGA3dRenderTargetViewDesc desc;
s->view_id = util_bitmask_add(svga->surface_view_id_bm);
- switch (s->base.texture->target) {
- case PIPE_TEXTURE_1D:
- case PIPE_TEXTURE_1D_ARRAY:
- resType = SVGA3D_RESOURCE_TEXTURE1D;
- break;
- case PIPE_TEXTURE_RECT:
- case PIPE_TEXTURE_2D:
- case PIPE_TEXTURE_2D_ARRAY:
- case PIPE_TEXTURE_CUBE:
- /* drawing to cube map is treated as drawing to 2D array */
- resType = SVGA3D_RESOURCE_TEXTURE2D;
- break;
- case PIPE_TEXTURE_3D:
- resType = SVGA3D_RESOURCE_TEXTURE3D;
- break;
- default:
- assert(!"Unexpected texture target");
- resType = SVGA3D_RESOURCE_TEXTURE2D;
- }
+ resType = svga_resource_type(s->base.texture->target);
if (util_format_is_depth_or_stencil(s->base.format)) {
ret = SVGA3D_vgpu10_DefineDepthStencilView(svga->swc,
if (ret != PIPE_OK) {
util_bitmask_clear(svga->surface_view_id_bm, s->view_id);
s->view_id = SVGA3D_INVALID_ID;
- goto done;
+ s = NULL;
}
}
- surf = &s->base;
-done:
SVGA_STATS_TIME_POP(svga_sws(svga));
- return surf;
+ return s ? &s->base : NULL;
}
}
+/**
+ * If any of the render targets are in backing texture views, propagate any
+ * changes to them back to the original texture.
+ */
+void
+svga_propagate_rendertargets(struct svga_context *svga)
+{
+ unsigned i;
+
+ /* Note that we examine the svga->state.hw_draw.framebuffer surfaces,
+ * not the svga->curr.framebuffer surfaces, because it's the former
+ * surfaces which may be backing surface views (the actual render targets).
+ */
+ for (i = 0; i < svga->state.hw_draw.num_rendertargets; i++) {
+ struct pipe_surface *s = svga->state.hw_draw.rtv[i];
+ if (s) {
+ svga_propagate_surface(svga, s);
+ }
+ }
+
+ if (svga->state.hw_draw.dsv) {
+ svga_propagate_surface(svga, svga->state.hw_draw.dsv);
+ }
+}
+
+
/**
* Check if we should call svga_propagate_surface on the surface.
*/