summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/i915
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2010-12-02 04:33:43 +0100
committerRoland Scheidegger <[email protected]>2010-12-02 04:33:43 +0100
commit4c7001462607e6e99e474d6271dd481d3f8f201c (patch)
treed5fc155ee50d2f41fa9e7d4a253a8f9c51bc9e51 /src/gallium/drivers/i915
parent32e1e591467d9a28c2ac4d2e17af7be2dc429d43 (diff)
gallium: support for array textures and related changes
resources have a array_size parameter now. get_tex_surface and tex_surface_destroy have been renamed to create_surface and surface_destroy and moved to context, similar to sampler views (and create_surface now uses a template just like create_sampler_view). Surfaces now really should only be used for rendering. In particular they shouldn't be used as some kind of 2d abstraction for sharing a texture. offset/layout fields don't make sense any longer and have been removed, width/height should go too. surfaces and sampler views now specify a layer range (for texture resources), layer is either array slice, depth slice or cube face. pipe_subresource is gone array slices (or cube faces) are now treated the same as depth slices in transfers etc. (that is, they use the z coord of the respective functions). Squashed commit of the following: commit a45bd509014743d21a532194d7b658a1aeb00cb7 Merge: 1aeca28 32e1e59 Author: Roland Scheidegger <[email protected]> Date: Thu Dec 2 04:32:06 2010 +0100 Merge remote branch 'origin/master' into gallium-array-textures Conflicts: src/gallium/drivers/i915/i915_resource_texture.c src/gallium/drivers/i915/i915_state_emit.c src/gallium/drivers/i915/i915_surface.c commit 1aeca287a827f29206078fa1204715a477072c08 Merge: 912f042 6f7c8c3 Author: Roland Scheidegger <[email protected]> Date: Thu Dec 2 00:37:11 2010 +0100 Merge remote branch 'origin/master' into gallium-array-textures Conflicts: src/gallium/state_trackers/vega/api_filters.c src/gallium/state_trackers/vega/api_images.c src/gallium/state_trackers/vega/mask.c src/gallium/state_trackers/vega/paint.c src/gallium/state_trackers/vega/renderer.c src/gallium/state_trackers/vega/st_inlines.h src/gallium/state_trackers/vega/vg_context.c src/gallium/state_trackers/vega/vg_manager.c commit 912f042e1d439de17b36be9a740358c876fcd144 Author: Roland Scheidegger <[email protected]> Date: Wed Dec 1 03:01:55 2010 +0100 gallium: even more compile fixes after merge commit 6fc95a58866d2a291def333608ba9c10c3f07e82 Author: Roland Scheidegger <[email protected]> Date: Wed Dec 1 00:22:26 2010 +0100 gallium: some fixes after merge commit a8d5ffaeb5397ffaa12fb422e4e7efdf0494c3e2 Merge: f7a202f 2da02e7 Author: Roland Scheidegger <[email protected]> Date: Tue Nov 30 23:41:26 2010 +0100 Merge remote branch 'origin/master' into gallium-array-textures Conflicts: src/gallium/drivers/i915/i915_state_emit.c src/gallium/state_trackers/vega/api_images.c src/gallium/state_trackers/vega/vg_context.c commit f7a202fde2aea2ec78ef58830f945a5e214e56ab Author: Roland Scheidegger <[email protected]> Date: Wed Nov 24 19:19:32 2010 +0100 gallium: even more fixes/cleanups after merge commit 6895a7f969ed7f9fa8ceb788810df8dbcf04c4c9 Author: Roland Scheidegger <[email protected]> Date: Wed Nov 24 03:07:36 2010 +0100 gallium: more compile fixes after merge commit af0501a5103b9756bc4d79167bd81051ad6e8670 Author: Roland Scheidegger <[email protected]> Date: Tue Nov 23 19:24:45 2010 +0100 gallium: lots of compile fixes after merge commit 0332003c2feb60f2a20e9a40368180c4ecd33e6b Merge: 26c6346 b6b91fa Author: Roland Scheidegger <[email protected]> Date: Tue Nov 23 17:02:26 2010 +0100 Merge remote branch 'origin/master' into gallium-array-textures Conflicts: src/gallium/auxiliary/gallivm/lp_bld_sample.c src/gallium/auxiliary/util/u_blit.c src/gallium/auxiliary/util/u_blitter.c src/gallium/auxiliary/util/u_inlines.h src/gallium/auxiliary/util/u_surface.c src/gallium/auxiliary/util/u_surfaces.c src/gallium/docs/source/context.rst src/gallium/drivers/llvmpipe/lp_rast.c src/gallium/drivers/nv50/nv50_state_validate.c src/gallium/drivers/nvfx/nv04_surface_2d.c src/gallium/drivers/nvfx/nv04_surface_2d.h src/gallium/drivers/nvfx/nvfx_buffer.c src/gallium/drivers/nvfx/nvfx_miptree.c src/gallium/drivers/nvfx/nvfx_resource.c src/gallium/drivers/nvfx/nvfx_resource.h src/gallium/drivers/nvfx/nvfx_state_fb.c src/gallium/drivers/nvfx/nvfx_surface.c src/gallium/drivers/nvfx/nvfx_transfer.c src/gallium/drivers/r300/r300_state_derived.c src/gallium/drivers/r300/r300_texture.c src/gallium/drivers/r600/r600_blit.c src/gallium/drivers/r600/r600_buffer.c src/gallium/drivers/r600/r600_context.h src/gallium/drivers/r600/r600_screen.c src/gallium/drivers/r600/r600_screen.h src/gallium/drivers/r600/r600_state.c src/gallium/drivers/r600/r600_texture.c src/gallium/include/pipe/p_defines.h src/gallium/state_trackers/egl/common/egl_g3d_api.c src/gallium/state_trackers/glx/xlib/xm_st.c src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c src/gallium/targets/libgl-gdi/libgl_gdi.c src/gallium/tests/graw/tri.c src/mesa/state_tracker/st_cb_blit.c src/mesa/state_tracker/st_cb_readpixels.c commit 26c6346b385929fba94775f33838d0cceaaf1127 Author: Roland Scheidegger <[email protected]> Date: Mon Aug 2 19:37:21 2010 +0200 fix more merge breakage commit b30d87c6025eefe7f6979ffa8e369bbe755d5c1d Merge: 9461bf3 1f1928d Author: Roland Scheidegger <[email protected]> Date: Mon Aug 2 19:15:38 2010 +0200 Merge remote branch 'origin/master' into gallium-array-textures Conflicts: src/gallium/drivers/llvmpipe/lp_rast.c src/gallium/drivers/llvmpipe/lp_rast_priv.h src/gallium/drivers/r300/r300_blit.c src/gallium/drivers/r300/r300_screen_buffer.c src/gallium/drivers/r300/r300_state_derived.c src/gallium/drivers/r300/r300_texture.c src/gallium/drivers/r300/r300_texture.h src/gallium/drivers/r300/r300_transfer.c src/gallium/drivers/r600/r600_screen.c src/gallium/drivers/r600/r600_state.c src/gallium/drivers/r600/r600_texture.c src/gallium/drivers/r600/r600_texture.h src/gallium/state_trackers/dri/common/dri1_helper.c src/gallium/state_trackers/dri/sw/drisw.c src/gallium/state_trackers/xorg/xorg_exa.c commit 9461bf3cfb647d2301364ae29fc3084fff52862a Merge: 17492d7 0eaccb3 Author: Roland Scheidegger <[email protected]> Date: Thu Jul 15 20:13:45 2010 +0200 Merge commit 'origin/master' into gallium-array-textures Conflicts: src/gallium/auxiliary/util/u_blitter.c src/gallium/drivers/llvmpipe/lp_rast.c src/gallium/drivers/llvmpipe/lp_surface.c src/gallium/drivers/r300/r300_render.c src/gallium/drivers/r300/r300_state.c src/gallium/drivers/r300/r300_texture.c src/gallium/drivers/r300/r300_transfer.c src/gallium/tests/trivial/quad-tex.c commit 17492d705e7b7f607b71db045c3bf344cb6842b3 Author: Roland Scheidegger <[email protected]> Date: Fri Jun 18 10:58:08 2010 +0100 gallium: rename element_offset/width fields in views to first/last_element This is much more consistent with the other fields used there (first/last level, first/last layer). Actually thinking about removing the ugly union/structs again and rename first/last_layer to something even more generic which could also be used for buffers (like first/last_member) without inducing headaches. commit 1b717a289299f942de834dcccafbab91361e20ab Author: Roland Scheidegger <[email protected]> Date: Thu Jun 17 14:46:09 2010 +0100 gallium: remove PIPE_SURFACE_LAYOUT_LINEAR definition This was only used by the layout field of pipe_surface, but this driver internal stuff is gone so there's no need for this driver independent layout definition neither. commit 10cb644b31b3ef47e6c7b55e514ad24bb891fac4 Merge: 5691db9 c85971d Author: Roland Scheidegger <[email protected]> Date: Thu Jun 17 12:20:41 2010 +0100 Merge commit 'origin/master' into gallium-array-textures Conflicts: src/gallium/docs/source/glossary.rst src/gallium/tests/graw/fs-test.c src/gallium/tests/graw/gs-test.c commit 5691db960ca3d525ce7d6c32d9c7a28f5e907f3b Author: Roland Scheidegger <[email protected]> Date: Thu Jun 17 11:29:03 2010 +0100 st/wgl: fix interface changes bugs commit 2303ec32143d363b46e59e4b7c91b0ebd34a16b2 Author: Roland Scheidegger <[email protected]> Date: Wed Jun 16 19:42:32 2010 +0100 gallium: adapt code to interface changes... commit dcae4f586f0d0885b72674a355e5d56d47afe77d Author: Roland Scheidegger <[email protected]> Date: Wed Jun 16 19:42:05 2010 +0100 gallium: separate depth0 and array_size in the resource itself. These fields are still mutually exclusive (since no 3d array textures exist) but it ultimately seemed to error-prone to adapt all code accept the new meaning of depth0 (drivers stick that into hardware regs, calculate mipmap sizes etc.). And it isn't really cleaner anyway. So, array textures will have depth0 of 1, but instead use array_size, 3D textures will continue to use depth0 (and have array_size of 1). Cube maps also will use array_size to indicate their 6 faces, but since all drivers should just be fine by inferring this themselves from the fact it's a cube map as they always used to nothing should break. commit 621737a638d187d208712250fc19a91978fdea6b Author: Roland Scheidegger <[email protected]> Date: Wed Jun 16 17:47:38 2010 +0100 gallium: adapt code to interface changes There are still usages of pipe_surface where pipe_resource should be used, which should eventually be fixed. commit 2d17f5efe166b2c3d51957c76294165ab30b8ae2 Author: Roland Scheidegger <[email protected]> Date: Wed Jun 16 17:46:14 2010 +0100 gallium: more interface changes In particular to enable usage of buffers in views, and ability to use a different pipe_format in pipe_surface. Get rid of layout and offset parameter in pipe_surface - the former was not used in any (public) code anyway, and the latter should either be computed on-demand or driver can use subclass of pipe_surface. Also make create_surface() use a template to be more consistent with other functions. commit 71f885ee16aa5cf2742c44bfaf0dc5b8734b9901 Merge: 3232d11 8ad410d Author: Roland Scheidegger <[email protected]> Date: Mon Jun 14 14:19:51 2010 +0100 Merge commit 'origin/master' into gallium-array-textures Conflicts: src/gallium/auxiliary/util/u_box.h src/gallium/drivers/nv50/nv50_surface.c src/gallium/drivers/nvfx/nvfx_surface.c src/gallium/drivers/r300/r300_blit.c src/gallium/drivers/r300/r300_texture.c src/gallium/drivers/r300/r300_transfer.c src/gallium/drivers/r600/r600_blit.c src/gallium/drivers/r600/r600_screen.h src/gallium/include/pipe/p_state.h commit 3232d11fe3ebf7686286013c357b404714853984 Author: Roland Scheidegger <[email protected]> Date: Mon Jun 14 11:40:04 2010 +0100 mesa/st: adapt to interface changes still need to fix pipe_surface sharing (as that is now per-context). Also broken is depth0 handling - half the code assumes this is also used for array textures (and hence by extension of that cube maps would have depth 6), half the code does not... commit f433b7f7f552720e5eade0b4078db94590ee85e1 Author: Roland Scheidegger <[email protected]> Date: Mon Jun 14 11:35:52 2010 +0100 gallium: fix a couple of bugs in interface chnage fixes commit 818366b28ea18f514dc791646248ce6f08d9bbcf Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:42:11 2010 +0200 targets: adapt to interface changes Yes even that needs adjustments... commit 66c511ab1682c9918e0200902039247793acb41e Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:41:13 2010 +0200 tests: adapt to interface changes Everything needs to be fixed :-(. commit 6b494635d9dbdaa7605bc87b1ebf682b138c5808 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:39:50 2010 +0200 st: adapt non-rendering state trackers to interface changes might not be quite right in all places, but they really don't want to use pipe_surface. commit 00c4289a35d86e4fe85919ec32aa9f5ffe69d16d Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:38:48 2010 +0200 winsys: adapt to interface changes commit 39d858554dc9ed5dbc795626fec3ef9deae552a0 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:26:54 2010 +0200 st/python: adapt to interface changes don't think that will work, sorry. commit 6e9336bc49b32139cec4e683857d0958000e15e3 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:26:07 2010 +0200 st/vega: adapt to interface changes commit e07f2ae9aaf8842757d5d50865f76f8276245e11 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:25:56 2010 +0200 st/xorg: adapt to interface changes commit 05531c10a74a4358103e30d3b38a5eceb25c947f Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:24:53 2010 +0200 nv50: adapt to interface changes commit 97704f388d7042121c6d496ba8c003afa3ea2bf3 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:24:45 2010 +0200 nvfx: adapt to interface changes commit a8a9c93d703af6e8f5c12e1cea9ec665add1abe0 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:24:01 2010 +0200 i965g: adapt to interface changes commit 0dde209589872d20cc34ed0b237e3ed7ae0e2de3 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:22:38 2010 +0200 i915g: adapt to interface changes commit 5cac9beede69d12f5807ee1a247a4c864652799e Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:20:58 2010 +0200 svga: adapt to interface changes resource_copy_region still looking fishy. Was not very suited to unified zslice/face approach... commit 08b5a6af4b963a3e4c75fc336bf6c0772dce5150 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:20:01 2010 +0200 rbug: adapt to interface changes Not sure if that won't need changes elsewhere? commit c9fd24b1f586bcef2e0a6e76b68e40fca3408964 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:19:31 2010 +0200 trace: adapt to interface changes commit ed84e010afc5635a1a47390b32247a266f65b8d1 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:19:21 2010 +0200 failover: adapt to interface changes commit a1d4b4a293da933276908e3393435ec4b43cf201 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:19:12 2010 +0200 identity: adapt to interface changes commit a8dd73e2c56c7d95ffcf174408f38f4f35fd2f4c Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:18:55 2010 +0200 softpipe: adapt to interface changes commit a886085893e461e8473978e8206ec2312b7077ff Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:18:44 2010 +0200 llvmpipe: adapt to interface changes commit 70523f6d567d8b7cfda682157556370fd3c43460 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:18:14 2010 +0200 r600g: adapt to interface changes commit 3f4bc72bd80994865eb9f6b8dfd11e2b97060d19 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:18:05 2010 +0200 r300g: adapt to interface changes commit 5d353b55ee14db0ac0515b5a3cf9389430832c19 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:17:37 2010 +0200 cell: adapt to interface changes not even compile tested commit cf5d03601322c2dcb12d7a9c2f1745e2b2a35eb4 Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:14:59 2010 +0200 util: adapt to interface changes amazing how much code changes just due to some subtle interface changes? commit dc98d713c6937c0e177fc2caf23020402cc7ea7b Author: Roland Scheidegger <[email protected]> Date: Sat Jun 12 02:12:40 2010 +0200 gallium: more interface fail, docs this also changes flush_frontbuffer to use a pipe_resource instead of a pipe_surface - pipe_surface is not meant to be (or at least no longer) an abstraction for standalone 2d images which get passed around. (This has also implications for the non-rendering state-trackers.) commit 08436d27ddd59857c22827c609b692aa0c407b7b Author: Roland Scheidegger <[email protected]> Date: Thu Jun 10 17:42:52 2010 +0200 gallium: fix array texture interface changes bugs, docs commit 4a4d927609b62b4d7fb9dffa35158afe282f277b Author: Roland Scheidegger <[email protected]> Date: Thu Jun 3 22:02:44 2010 +0200 gallium: interface changes for array textures and related cleanups This patch introduces array textures to gallium (note they are not immediately usable without the associated changes to the shader side). Also, this abandons pipe_subresource in favor of using level and layer parameters since the distinction between several faces (which was part of pipe_subresource for cube textures) and several z slices (which were not part of pipe_subresource but instead part of pipe_box where appropriate for 3d textures) is gone at the resource level. Textures, be it array, cube, or 3d, now use a "unified" set of parameters, there is no distinction between array members, cube faces, or 3d zslices. This is unlike d3d10, whose subresource index includes layer information for array textures, but which considers all z slices of a 3d texture to be part of the same subresource. In contrast to d3d10, OpenGL though reuses old 2d and 3d function entry points for 1d and 2d array textures, respectively, which also implies that for instance it is possible to specify all layers of a 2d array texture at once (note that this is not possible for cube maps, which use the 2d entry points, although it is possible for cube map arrays, which aren't supported yet in gallium). This should possibly make drivers a bit simpler, and also get rid of mutually exclusive parameters in some functions (as z and face were exclusive), one potential downside would be that 3d array textures could not easily be supported without reverting this, but those are nowhere to be seen. Also along with adjusting to new parameters, rename get_tex_surface / tex_surface_destroy to create_surface / surface_destroy and move them from screen to context, which reflects much better what those do (they are analogous to create_sampler_view / sampler_view_destroy). PIPE_CAP_ARRAY_TEXTURES is used to indicate if a driver supports all of this functionality (that is, both sampling from array texture as well as use a range of layers as a render target, with selecting the layer from the geometry shader).
Diffstat (limited to 'src/gallium/drivers/i915')
-rw-r--r--src/gallium/drivers/i915/i915_resource.h2
-rw-r--r--src/gallium/drivers/i915/i915_resource_buffer.c25
-rw-r--r--src/gallium/drivers/i915/i915_resource_texture.c41
-rw-r--r--src/gallium/drivers/i915/i915_screen.c1
-rw-r--r--src/gallium/drivers/i915/i915_state_emit.c14
-rw-r--r--src/gallium/drivers/i915/i915_surface.c101
-rw-r--r--src/gallium/drivers/i915/i915_surface.h1
7 files changed, 77 insertions, 108 deletions
diff --git a/src/gallium/drivers/i915/i915_resource.h b/src/gallium/drivers/i915/i915_resource.h
index 578c6bdb42d..86620e6a123 100644
--- a/src/gallium/drivers/i915/i915_resource.h
+++ b/src/gallium/drivers/i915/i915_resource.h
@@ -78,7 +78,7 @@ struct i915_texture {
};
unsigned i915_texture_offset(struct i915_texture *tex,
- unsigned level, unsigned face);
+ unsigned level, unsigned layer);
void i915_init_screen_resource_functions(struct i915_screen *is);
void i915_init_resource_functions(struct i915_context *i915);
diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c
index 0d379497dfc..450203d60a9 100644
--- a/src/gallium/drivers/i915/i915_resource_buffer.c
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -62,7 +62,7 @@ i915_buffer_destroy(struct pipe_screen *screen,
static void *
i915_buffer_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
+ struct pipe_transfer *transfer )
{
struct i915_buffer *buffer = i915_buffer(transfer->resource);
return buffer->data + transfer->box.x;
@@ -71,19 +71,19 @@ i915_buffer_transfer_map( struct pipe_context *pipe,
static void
i915_buffer_transfer_inline_write( struct pipe_context *rm_ctx,
- struct pipe_resource *resource,
- struct pipe_subresource sr,
- unsigned usage,
- const struct pipe_box *box,
- const void *data,
- unsigned stride,
- unsigned slice_stride)
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned layer_stride)
{
struct i915_buffer *buffer = i915_buffer(resource);
memcpy(buffer->data + box->x,
- data,
- box->width);
+ data,
+ box->width);
}
@@ -115,7 +115,7 @@ i915_buffer_create(struct pipe_screen *screen,
buf->b.vtbl = &i915_buffer_vtbl;
pipe_reference_init(&buf->b.b.reference, 1);
buf->b.b.screen = screen;
-
+
buf->data = MALLOC(template->width0);
buf->free_on_destroy = TRUE;
@@ -135,7 +135,7 @@ struct pipe_resource *
i915_user_buffer_create(struct pipe_screen *screen,
void *ptr,
unsigned bytes,
- unsigned bind)
+ unsigned bind)
{
struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer);
@@ -152,6 +152,7 @@ i915_user_buffer_create(struct pipe_screen *screen,
buf->b.b.width0 = bytes;
buf->b.b.height0 = 1;
buf->b.b.depth0 = 1;
+ buf->b.b.array_size = 1;
buf->data = ptr;
buf->free_on_destroy = FALSE;
diff --git a/src/gallium/drivers/i915/i915_resource_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c
index c80014b69d2..f19106f3414 100644
--- a/src/gallium/drivers/i915/i915_resource_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -142,15 +142,15 @@ i915_texture_set_level_info(struct i915_texture *tex,
tex->image_offset[level][0].nblocksy = 0;
}
-inline unsigned i915_texture_offset(struct i915_texture *tex,
- unsigned level, unsigned face)
+INLINE unsigned i915_texture_offset(struct i915_texture *tex,
+ unsigned level, unsigned layer)
{
- unsigned x, y;
- x = tex->image_offset[level][face].nblocksx
- * util_format_get_blocksize(tex->b.b.format);
- y = tex->image_offset[level][face].nblocksy;
+ unsigned x, y;
+ x = tex->image_offset[level][layer].nblocksx
+ * util_format_get_blocksize(tex->b.b.format);
+ y = tex->image_offset[level][layer].nblocksy;
- return y * tex->stride + x;
+ return y * tex->stride + x;
}
static void
@@ -700,7 +700,7 @@ i915_texture_get_handle(struct pipe_screen * screen,
static void
i915_texture_destroy(struct pipe_screen *screen,
- struct pipe_resource *pt)
+ struct pipe_resource *pt)
{
struct i915_texture *tex = i915_texture(pt);
struct i915_winsys *iws = i915_screen(screen)->iws;
@@ -717,10 +717,10 @@ i915_texture_destroy(struct pipe_screen *screen,
static struct pipe_transfer *
i915_texture_get_transfer(struct pipe_context *context,
- struct pipe_resource *resource,
- struct pipe_subresource sr,
- unsigned usage,
- const struct pipe_box *box)
+ struct pipe_resource *resource,
+ unsigned level,
+ unsigned usage,
+ const struct pipe_box *box)
{
struct i915_texture *tex = i915_texture(resource);
struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
@@ -728,36 +728,31 @@ i915_texture_get_transfer(struct pipe_context *context,
return NULL;
transfer->resource = resource;
- transfer->sr = sr;
+ transfer->level = level;
transfer->usage = usage;
transfer->box = *box;
transfer->stride = tex->stride;
+ /* FIXME: layer_stride */
return transfer;
}
static void *
i915_texture_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
+ struct pipe_transfer *transfer)
{
struct pipe_resource *resource = transfer->resource;
struct i915_texture *tex = i915_texture(resource);
struct i915_winsys *iws = i915_screen(pipe->screen)->iws;
- struct pipe_subresource sr = transfer->sr;
struct pipe_box *box = &transfer->box;
enum pipe_format format = resource->format;
unsigned offset;
char *map;
- if (resource->target == PIPE_TEXTURE_CUBE) {
- offset = i915_texture_offset(tex, sr.level, sr.face);
- } else if (resource->target == PIPE_TEXTURE_3D) {
- offset = i915_texture_offset(tex, sr.level, box->z);
- } else {
- offset = i915_texture_offset(tex, sr.level, 0);
- assert(sr.face == 0);
+ if (resource->target != PIPE_TEXTURE_3D &&
+ resource->target != PIPE_TEXTURE_CUBE)
assert(box->z == 0);
- }
+ offset = i915_texture_offset(tex, transfer->level, box->z);
map = iws->buffer_map(iws, tex->buffer,
(transfer->usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
index a3c51138008..f66478e729c 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -387,7 +387,6 @@ i915_screen_create(struct i915_winsys *iws)
is->base.fence_finish = i915_fence_finish;
i915_init_screen_resource_functions(is);
- i915_init_screen_surface_functions(is);
i915_debug_init(is);
diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c
index 49d1fa69a80..c48d53ffbb2 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -237,7 +237,6 @@ i915_emit_hardware_state(struct i915_context *i915 )
if (cbuf_surface) {
struct i915_texture *tex = i915_texture(cbuf_surface->texture);
- uint32_t tiling_bits = 0;
assert(tex);
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
@@ -255,8 +254,10 @@ i915_emit_hardware_state(struct i915_context *i915 )
*/
if (depth_surface) {
struct i915_texture *tex = i915_texture(depth_surface->texture);
+ unsigned offset = i915_texture_offset(tex, depth_surface->u.tex.level,
+ depth_surface->u.tex.first_layer);
assert(tex);
- assert(depth_surface->offset == 0);
+ assert(offset == 0);
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
@@ -412,18 +413,17 @@ i915_emit_hardware_state(struct i915_context *i915 )
struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
struct i915_texture *tex = i915_texture(cbuf_surface->texture);
unsigned x, y;
- int face;
+ int layer;
uint32_t draw_offset;
boolean ret;
ret = framebuffer_size(&i915->framebuffer, &w, &h);
assert(ret);
- face = tex->b.b.target == PIPE_TEXTURE_CUBE ?
- cbuf_surface->face : cbuf_surface->zslice;
+ layer = cbuf_surface->u.tex.first_layer;
- x = tex->image_offset[cbuf_surface->level][face].nblocksx;
- y = tex->image_offset[cbuf_surface->level][face].nblocksy;
+ x = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksx;
+ y = tex->image_offset[cbuf_surface->u.tex.level][layer].nblocksy;
draw_offset = x | (y << 16);
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index 8a09f930a0c..becc6e93c2d 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -43,11 +43,10 @@
*/
static void
i915_surface_copy(struct pipe_context *pipe,
- struct pipe_resource *dst, struct pipe_subresource subdst,
+ struct pipe_resource *dst, unsigned dst_level,
unsigned dstx, unsigned dsty, unsigned dstz,
- struct pipe_resource *src, struct pipe_subresource subsrc,
- unsigned srcx, unsigned srcy, unsigned srcz,
- unsigned width, unsigned height)
+ struct pipe_resource *src, unsigned src_level,
+ const struct pipe_box *src_box)
{
struct i915_texture *dst_tex = i915_texture(dst);
struct i915_texture *src_tex = i915_texture(src);
@@ -55,29 +54,17 @@ i915_surface_copy(struct pipe_context *pipe,
struct pipe_resource *spt = &src_tex->b.b;
unsigned dst_offset, src_offset; /* in bytes */
- if (dst->target == PIPE_TEXTURE_CUBE) {
- dst_offset = i915_texture_offset(dst_tex, subdst.level, subdst.face);
- }
- else if (dst->target == PIPE_TEXTURE_3D) {
- dst_offset = i915_texture_offset(dst_tex, subdst.level, dstz);
- }
- else {
- dst_offset = i915_texture_offset(dst_tex, subdst.level, 0);
- assert(subdst.face == 0);
+ /* XXX cannot copy 3d regions at this time */
+ assert(src_box->depth == 1);
+ if (dst->target != PIPE_TEXTURE_CUBE &&
+ dst->target != PIPE_TEXTURE_3D)
assert(dstz == 0);
- }
- if (src->target == PIPE_TEXTURE_CUBE) {
- src_offset = i915_texture_offset(src_tex, subsrc.level, subsrc.face);
- }
- else if (src->target == PIPE_TEXTURE_3D) {
- src_offset = i915_texture_offset(src_tex, subsrc.level, srcz);
- }
- else {
- src_offset = i915_texture_offset(src_tex, subsrc.level, 0);
- assert(subsrc.face == 0);
- assert(srcz == 0);
- }
+ dst_offset = i915_texture_offset(dst_tex, dst_level, dstz);
+ if (src->target != PIPE_TEXTURE_CUBE &&
+ src->target != PIPE_TEXTURE_3D)
+ assert(src_box->z == 0);
+ src_offset = i915_texture_offset(src_tex, src_level, src_box->z);
assert( dst != src );
assert( util_format_get_blocksize(dpt->format) == util_format_get_blocksize(spt->format) );
@@ -90,7 +77,8 @@ i915_surface_copy(struct pipe_context *pipe,
util_format_get_blocksize(dpt->format),
(unsigned short) src_tex->stride, src_tex->buffer, src_offset,
(unsigned short) dst_tex->stride, dst_tex->buffer, dst_offset,
- (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
+ (short) src_box->x, (short) src_box->y, (short) dstx, (short) dsty,
+ (short) src_box->width, (short) src_box->height );
}
@@ -104,6 +92,7 @@ i915_clear_render_target(struct pipe_context *pipe,
struct i915_texture *tex = i915_texture(dst->texture);
struct pipe_resource *pt = &tex->b.b;
union util_color uc;
+ unsigned offset = i915_texture_offset(tex, dst->u.tex.level, dst->u.tex.first_layer);
assert(util_format_get_blockwidth(pt->format) == 1);
assert(util_format_get_blockheight(pt->format) == 1);
@@ -113,7 +102,7 @@ i915_clear_render_target(struct pipe_context *pipe,
util_format_get_blocksize(pt->format),
XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB,
(unsigned short) tex->stride,
- tex->buffer, dst->offset,
+ tex->buffer, offset,
(short) dstx, (short) dsty,
(short) width, (short) height,
uc.ui );
@@ -132,6 +121,7 @@ i915_clear_depth_stencil(struct pipe_context *pipe,
struct pipe_resource *pt = &tex->b.b;
unsigned packedds;
unsigned mask = 0;
+ unsigned offset = i915_texture_offset(tex, dst->u.tex.level, dst->u.tex.first_layer);
assert(util_format_get_blockwidth(pt->format) == 1);
assert(util_format_get_blockheight(pt->format) == 1);
@@ -151,7 +141,7 @@ i915_clear_depth_stencil(struct pipe_context *pipe,
util_format_get_blocksize(pt->format),
mask,
(unsigned short) tex->stride,
- tex->buffer, dst->offset,
+ tex->buffer, offset,
(short) dstx, (short) dsty,
(short) width, (short) height,
packedds );
@@ -163,45 +153,37 @@ i915_clear_depth_stencil(struct pipe_context *pipe,
static struct pipe_surface *
-i915_get_tex_surface(struct pipe_screen *screen,
- struct pipe_resource *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
+i915_create_surface(struct pipe_context *ctx,
+ struct pipe_resource *pt,
+ const struct pipe_surface *surf_tmpl)
{
- struct i915_texture *tex = i915_texture(pt);
struct pipe_surface *ps;
- unsigned offset; /* in bytes */
- if (pt->target == PIPE_TEXTURE_CUBE) {
- offset = i915_texture_offset(tex, level, face);
- }
- else if (pt->target == PIPE_TEXTURE_3D) {
- offset = i915_texture_offset(tex, level, zslice);
- }
- else {
- offset = i915_texture_offset(tex, level, 0);
- assert(face == 0);
- assert(zslice == 0);
- }
+ assert(surf_tmpl->u.tex.first_layer == surf_tmpl->u.tex.last_layer);
+ if (pt->target != PIPE_TEXTURE_CUBE &&
+ pt->target != PIPE_TEXTURE_3D)
+ assert(surf_tmpl->u.tex.first_layer == 0);
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
+ /* could subclass pipe_surface and store offset as it used to do */
pipe_reference_init(&ps->reference, 1);
pipe_resource_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = u_minify(pt->width0, level);
- ps->height = u_minify(pt->height0, level);
- ps->offset = offset;
- ps->usage = flags;
- ps->zslice = zslice;
- ps->level = level;
- ps->face = face;
+ ps->format = surf_tmpl->format;
+ ps->width = u_minify(pt->width0, surf_tmpl->u.tex.level);
+ ps->height = u_minify(pt->height0, surf_tmpl->u.tex.level);
+ ps->u.tex.level = surf_tmpl->u.tex.level;
+ ps->u.tex.first_layer = surf_tmpl->u.tex.first_layer;
+ ps->u.tex.last_layer = surf_tmpl->u.tex.last_layer;
+ ps->usage = surf_tmpl->usage;
+ ps->context = ctx;
}
return ps;
}
static void
-i915_tex_surface_destroy(struct pipe_surface *surf)
+i915_surface_destroy(struct pipe_context *ctx,
+ struct pipe_surface *surf)
{
pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
@@ -214,13 +196,6 @@ i915_init_surface_functions(struct i915_context *i915)
i915->base.resource_copy_region = i915_surface_copy;
i915->base.clear_render_target = i915_clear_render_target;
i915->base.clear_depth_stencil = i915_clear_depth_stencil;
-}
-
-/* No good reason for these to be in the screen.
- */
-void
-i915_init_screen_surface_functions(struct i915_screen *is)
-{
- is->base.get_tex_surface = i915_get_tex_surface;
- is->base.tex_surface_destroy = i915_tex_surface_destroy;
+ i915->base.create_surface = i915_create_surface;
+ i915->base.surface_destroy = i915_surface_destroy;
}
diff --git a/src/gallium/drivers/i915/i915_surface.h b/src/gallium/drivers/i915/i915_surface.h
index 448106d5662..70b61de80f2 100644
--- a/src/gallium/drivers/i915/i915_surface.h
+++ b/src/gallium/drivers/i915/i915_surface.h
@@ -32,7 +32,6 @@ struct i915_context;
struct i915_screen;
void i915_init_surface_functions( struct i915_context *i915 );
-void i915_init_screen_surface_functions( struct i915_screen *is );
#endif /* I915_SCREEN_H */