diff options
Diffstat (limited to 'src/gallium/state_trackers/d3d1x')
3 files changed, 104 insertions, 86 deletions
diff --git a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp index c246fc5..a54324a 100644 --- a/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp +++ b/src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp @@ -1159,8 +1159,15 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX unsigned blit_x, blit_y, blit_w, blit_h; float black[4] = {0, 0, 0, 0}; - if(!formats_compatible || src->width0 != dst_w || src->height0 != dst_h) - dst_surface = pipe->screen->get_tex_surface(pipe->screen, dst, 0, 0, 0, PIPE_BIND_RENDER_TARGET); + if(!formats_compatible || src->width0 != dst_w || src->height0 != dst_h) { + struct pipe_surface templat; + templat.usage = PIPE_BIND_RENDER_TARGET; + templat.format = dst->format; + templat.u.tex.level = 0; + templat.u.tex.first_layer = 0; + templat.u.tex.last_layer = 0; + dst_surface = pipe->create_surface(pipe, dst, &templat); + } if(preserve_aspect_ratio) { @@ -1199,10 +1206,12 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX if(formats_compatible && blit_w == src->width0 && blit_h == src->height0) { - pipe_subresource sr; - sr.face = 0; - sr.level = 0; - pipe->resource_copy_region(pipe, dst, sr, rect.left, rect.top, 0, src, sr, 0, 0, 0, blit_w, blit_h); + pipe_box box; + box.x = box.y = box.z; + box.width = blit_w; + box.height = blit_h; + box.z = 1; + pipe->resource_copy_region(pipe, dst, 0, rect.left, rect.top, 0, src, 0, &box); } else { @@ -1218,7 +1227,7 @@ struct GalliumDXGISwapChain : public GalliumDXGIObject<IDXGISwapChain, GalliumDX } if(dst_surface) - pipe->screen->tex_surface_destroy(dst_surface); + pipe->surface_destroy(pipe, dst_surface); pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, 0); diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h index 3611059..e1ba6c1 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h @@ -1416,23 +1416,33 @@ changed: *out_predicate_value = render_predicate_value; } - static pipe_subresource d3d11_to_pipe_subresource(struct pipe_resource* resource, unsigned subresource) + static unsigned d3d11_subresource_to_level(struct pipe_resource* resource, unsigned subresource) { - pipe_subresource sr; if(subresource <= resource->last_level) { - sr.level = subresource; - sr.face = 0; + return subresource; } else { unsigned levels = resource->last_level + 1; - sr.level = subresource % levels; - sr.face = subresource / levels; + return subresource % levels; } - return sr; } + static unsigned d3d11_subresource_to_face(struct pipe_resource* resource, unsigned subresource) + { + if(subresource <= resource->last_level) + { + return 0; + } + else + { + unsigned levels = resource->last_level + 1; + return subresource / levels; + } + } + + /* TODO: deferred contexts will need a different implementation of this, * because we can't put the transfer info into the resource itself. * Also, there are very different restrictions, for obvious reasons. @@ -1448,8 +1458,10 @@ changed: GalliumD3D11Resource<>* resource = (GalliumD3D11Resource<>*)iresource; if(resource->transfers.count(subresource)) return E_FAIL; - pipe_subresource sr = d3d11_to_pipe_subresource(resource->resource, subresource); - pipe_box box = d3d11_to_pipe_box(resource->resource, sr.level, 0); + unsigned level = d3d11_subresource_to_level(resource->resource, subresource); + unsigned face = d3d11_subresource_to_face(resource->resource, subresource); + pipe_box box = d3d11_to_pipe_box(resource->resource, level, 0); + /* XXX the translation from subresource to level/face(zslice/array layer) isn't quite right */ unsigned usage = 0; if(map_type == D3D11_MAP_READ) usage = PIPE_TRANSFER_READ; @@ -1465,7 +1477,7 @@ changed: return E_INVALIDARG; if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT) usage |= PIPE_TRANSFER_DONTBLOCK; - struct pipe_transfer* transfer = pipe->get_transfer(pipe, resource->resource, sr, usage, &box); + struct pipe_transfer* transfer = pipe->get_transfer(pipe, resource->resource, level, usage, &box); if(!transfer) { if(map_type & D3D10_MAP_FLAG_DO_NOT_WAIT) return DXGI_ERROR_WAS_STILL_DRAWING; @@ -1475,7 +1487,7 @@ changed: resource->transfers[subresource] = transfer; mapped_resource->pData = pipe->transfer_map(pipe, transfer); mapped_resource->RowPitch = transfer->stride; - mapped_resource->DepthPitch = transfer->slice_stride; + mapped_resource->DepthPitch = transfer->layer_stride; return S_OK; } @@ -1507,15 +1519,16 @@ changed: SYNCHRONIZED; GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource; - pipe_subresource subdst = d3d11_to_pipe_subresource(dst->resource, dst_subresource); - pipe_subresource subsrc = d3d11_to_pipe_subresource(src->resource, src_subresource); - pipe_box box = d3d11_to_pipe_box(src->resource, subsrc.level, src_box); - for(unsigned i = 0; i < box.depth; ++i) + unsigned dst_level = d3d11_subresource_to_level(dst->resource, dst_subresource); + unsigned dst_face = d3d11_subresource_to_face(dst->resource, dst_subresource); + unsigned src_level = d3d11_subresource_to_level(src->resource, src_subresource); + unsigned src_face = d3d11_subresource_to_face(src->resource, src_subresource); + /* XXX the translation from subresource to level/face(zslice/array layer) isn't quite right */ + pipe_box box = d3d11_to_pipe_box(src->resource, src_level, src_box); { pipe->resource_copy_region(pipe, - dst->resource, subdst, dst_x, dst_y, dst_z + i, - src->resource, subsrc, box.x, box.y, box.z + i, - box.width, box.height); + dst->resource, dst_level, dst_x, dst_y, dst_z, + src->resource, src_level, &box); } } @@ -1526,24 +1539,23 @@ changed: SYNCHRONIZED; GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource; - pipe_subresource sr; - unsigned faces = dst->resource->target == PIPE_TEXTURE_CUBE ? 6 : 1; - - for(sr.face = 0; sr.face < faces; ++sr.face) + unsigned level; + for(level = 0; level <= dst->resource->last_level; ++level) { - for(sr.level = 0; sr.level <= dst->resource->last_level; ++sr.level) - { - unsigned w = u_minify(dst->resource->width0, sr.level); - unsigned h = u_minify(dst->resource->height0, sr.level); - unsigned d = u_minify(dst->resource->depth0, sr.level); - for(unsigned i = 0; i < d; ++i) - { - pipe->resource_copy_region(pipe, - dst->resource, sr, 0, 0, i, - src->resource, sr, 0, 0, i, - w, h); - } - } + unsigned layers = 1; + pipe_box box; + if (dst->resource->target == PIPE_TEXTURE_CUBE) + layers = 6; + else if (dst->resource->target == PIPE_TEXTURE_3D) + layers = u_minify(dst->resource->depth0, level); + /* else layers = dst->resource->array_size; */ + box.x = box.y = box.z = 0; + box.width = u_minify(dst->resource->width0, level); + box.height = u_minify(dst->resource->height0, level); + box.depth = layers; + pipe->resource_copy_region(pipe, + dst->resource, level, 0, 0, 0, + src->resource, level, &box); } } @@ -1557,9 +1569,10 @@ changed: { SYNCHRONIZED; GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; - pipe_subresource subdst = d3d11_to_pipe_subresource(dst->resource, dst_subresource); - pipe_box box = d3d11_to_pipe_box(dst->resource, subdst.level, pDstBox); - pipe->transfer_inline_write(pipe, dst->resource, subdst, PIPE_TRANSFER_WRITE, &box, pSrcData, src_row_pitch, src_depth_pitch); + unsigned dst_level = d3d11_subresource_to_level(dst->resource, dst_subresource); + /* XXX the translation from subresource to level/face(zslice/array layer) isn't quite right */ + pipe_box box = d3d11_to_pipe_box(dst->resource, dst_level, pDstBox); + pipe->transfer_inline_write(pipe, dst->resource, dst_level, PIPE_TRANSFER_WRITE, &box, pSrcData, src_row_pitch, src_depth_pitch); } #if API >= 11 @@ -1714,9 +1727,9 @@ changed: SYNCHRONIZED; GalliumD3D11Resource<>* dst = (GalliumD3D11Resource<>*)dst_resource; GalliumD3D11Resource<>* src = (GalliumD3D11Resource<>*)src_resource; - pipe_subresource subdst = d3d11_to_pipe_subresource(dst->resource, dst_subresource); - pipe_subresource subsrc = d3d11_to_pipe_subresource(src->resource, src_subresource); - pipe->resource_resolve(pipe, dst->resource, subdst, src->resource, subsrc); + unsigned dst_layer = d3d11_subresource_to_face(dst->resource, dst_subresource); + unsigned src_layer = d3d11_subresource_to_face(src->resource, src_subresource); + pipe->resource_resolve(pipe, dst->resource, dst_layer, src->resource, src_layer); } #if API >= 11 diff --git a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h index 95ea4e0..9cfdc83 100644 --- a/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h +++ b/src/gallium/state_trackers/d3d1x/gd3d11/d3d11_screen.h @@ -718,15 +718,13 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen { for(unsigned level = 0; level <= templat.last_level; ++level) { - struct pipe_subresource sr; - sr.level = level; - sr.face = slice; struct pipe_box box; - box.x = box.y = box.z = 0; + box.x = box.y = 0; + box.z = slice; box.width = u_minify(width, level); box.height = u_minify(height, level); - box.depth = u_minify(depth, level); - immediate_pipe->transfer_inline_write(immediate_pipe, resource, sr, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD | PIPE_TRANSFER_UNSYNCHRONIZED, &box, initial_data->pSysMem, initial_data->SysMemPitch, initial_data->SysMemSlicePitch); + box.depth = 1; + immediate_pipe->transfer_inline_write(immediate_pipe, resource, level, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD | PIPE_TRANSFER_UNSYNCHRONIZED, &box, initial_data->pSysMem, initial_data->SysMemPitch, initial_data->SysMemSlicePitch); ++initial_data; } } @@ -978,8 +976,8 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen case D3D11_SRV_DIMENSION_TEXTURE1DARRAY: case D3D11_SRV_DIMENSION_TEXTURE2DARRAY: /* yes, this works for all of these types (but TODO: texture arrays) */ - templat.first_level = desc->Texture1D.MostDetailedMip; - templat.last_level = templat.first_level + desc->Texture1D.MipLevels - 1; + templat.u.tex.first_level = desc->Texture1D.MostDetailedMip; + templat.u.tex.last_level = templat.u.tex.first_level + desc->Texture1D.MipLevels - 1; break; case D3D11_SRV_DIMENSION_BUFFER: case D3D11_SRV_DIMENSION_TEXTURE2DMS: @@ -1054,30 +1052,34 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen desc = &def_desc; } - unsigned zslice = 0; - unsigned face = 0; - unsigned level; - enum pipe_format format; + struct pipe_surface templat; + memset(&templat, 0, sizeof(templat)); if(invalid(desc->format >= DXGI_FORMAT_COUNT)) return E_INVALIDARG; - format = dxgi_to_pipe_format[desc->Format]; - if(!format) + templat.format = dxgi_to_pipe_format[desc->Format]; + if(!templat.format) return E_NOTIMPL; + templat.usage = PIPE_BIND_RENDER_TARGET; + templat.texture = ((GalliumD3D11Resource<>*)iresource)->resource; switch(desc->ViewDimension) { case D3D11_RTV_DIMENSION_TEXTURE1D: case D3D11_RTV_DIMENSION_TEXTURE2D: - level = desc->Texture1D.MipSlice; + templat.u.tex.level = desc->Texture1D.MipSlice; break; case D3D11_RTV_DIMENSION_TEXTURE3D: - level = desc->Texture3D.MipSlice; - zslice = desc->Texture3D.FirstWSlice; + templat.u.tex.level = desc->Texture3D.MipSlice; + templat.u.tex.first_layer = desc->Texture3D.FirstWSlice; + /* XXX FIXME */ + templat.u.tex.last_layer = desc->Texture3D.FirstWSlice; break; case D3D11_RTV_DIMENSION_TEXTURE1DARRAY: case D3D11_RTV_DIMENSION_TEXTURE2DARRAY: - level = desc->Texture1DArray.MipSlice; - face = desc->Texture1DArray.FirstArraySlice; + templat.u.tex.level = desc->Texture1DArray.MipSlice; + templat.u.tex.first_layer = desc->Texture1DArray.FirstArraySlice; + /* XXX FIXME */ + templat.u.tex.last_layer = desc->Texture1DArray.FirstArraySlice; break; case D3D11_RTV_DIMENSION_BUFFER: case D3D11_RTV_DIMENSION_TEXTURE2DMS: @@ -1090,13 +1092,9 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen if(!out_rtv) return S_FALSE; - struct pipe_surface* surface = screen->get_tex_surface(screen, - ((GalliumD3D11Resource<>*)iresource)->resource, - face, level, zslice, PIPE_BIND_RENDER_TARGET); + struct pipe_surface* surface = immediate_pipe->create_surface(immediate_pipe, templat.texture, &templat); if(!surface) return E_FAIL; - /* muhahahahaha, let's hope this actually works */ - surface->format = format; *out_rtv = new GalliumD3D11RenderTargetView(this, (GalliumD3D11Resource<>*)iresource, surface, *desc); return S_OK; } @@ -1134,26 +1132,28 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen desc = &def_desc; } - unsigned zslice = 0; - unsigned face = 0; - unsigned level; - enum pipe_format format; + struct pipe_surface templat; + memset(&templat, 0, sizeof(templat)); if(invalid(desc->format >= DXGI_FORMAT_COUNT)) return E_INVALIDARG; - format = dxgi_to_pipe_format[desc->Format]; - if(!format) + templat.format = dxgi_to_pipe_format[desc->Format]; + if(!templat.format) return E_NOTIMPL; + templat.usage = PIPE_BIND_DEPTH_STENCIL; + templat.texture = ((GalliumD3D11Resource<>*)iresource)->resource; switch(desc->ViewDimension) { case D3D11_DSV_DIMENSION_TEXTURE1D: case D3D11_DSV_DIMENSION_TEXTURE2D: - level = desc->Texture1D.MipSlice; + templat.u.tex.level = desc->Texture1D.MipSlice; break; case D3D11_DSV_DIMENSION_TEXTURE1DARRAY: case D3D11_DSV_DIMENSION_TEXTURE2DARRAY: - level = desc->Texture1DArray.MipSlice; - face = desc->Texture1DArray.FirstArraySlice; + templat.u.tex.level = desc->Texture1DArray.MipSlice; + templat.u.tex.first_layer = desc->Texture1DArray.FirstArraySlice; + /* XXX FIXME */ + templat.u.tex.last_layer = desc->Texture1DArray.FirstArraySlice; break; case D3D11_DSV_DIMENSION_TEXTURE2DMS: case D3D11_DSV_DIMENSION_TEXTURE2DMSARRAY: @@ -1165,13 +1165,9 @@ struct GalliumD3D11ScreenImpl : public GalliumD3D11Screen if(!out_depth_stencil_view) return S_FALSE; - struct pipe_surface* surface = screen->get_tex_surface(screen, - ((GalliumD3D11Resource<>*)iresource)->resource, - face, level, zslice, PIPE_BIND_DEPTH_STENCIL); + struct pipe_surface* surface = immediate_pipe->create_surface(immediate_pipe, templat.texture, &templat); if(!surface) return E_FAIL; - /* muhahahahaha, let's hope this actually works */ - surface->format = format; *out_depth_stencil_view = new GalliumD3D11DepthStencilView(this, (GalliumD3D11Resource<>*)iresource, surface, *desc); return S_OK; } |