summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2010-04-10 16:05:54 +0100
committerKeith Whitwell <keithw@vmware.com>2010-04-10 16:05:54 +0100
commit287c94ea4987033f9c99a2f91c5750c9083504ca (patch)
treea3c1d20522d0ba4a259a5c83e2126affd7aba83c
parente7f1e5ca648d6c96d056d3ae8eab65e98f47f311 (diff)
Squashed commit of the following:
commit 0189cb2fde9f5d7326fd4bfbc2e52db4cce73b3e Author: Keith Whitwell <keithw@vmware.com> Date: Sat Apr 10 12:48:43 2010 +0100 gallium: don't use generic get_transfer func for textures It doesn't know and can't fill in the stride value. commit 65bc6f88fd9ce8ff90175b250e580bef2739ea35 Author: Chia-I Wu <olv@lunarg.com> Date: Sat Apr 10 13:49:34 2010 +0800 i915g: Initialize screen surface function. commit eb56e64986790aa2fa35534ce652b78656b0c3c5 Merge: f8b0a7f e7f1e5c Author: Keith Whitwell <keithw@vmware.com> Date: Sat Apr 10 00:38:43 2010 +0100 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/drivers/r300/r300_texture.c commit f8b0a7f6a3a98fd36ce90a81073ec8c8f09b684c Merge: a3c9980 f43c679 Author: Keith Whitwell <keithw@vmware.com> Date: Sat Apr 10 00:35:09 2010 +0100 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/drivers/r300/r300_texture.c commit a3c99807de37dc2c072f1d75ed3a11da333bc9a1 Author: unknown <michal@.(none)> Date: Fri Apr 9 18:51:39 2010 +0200 scons: Add missing sources. commit 927cec79cedb457efa9e6f335727cfcb8e4908e2 Author: Roland Scheidegger <sroland@vmware.com> Date: Fri Apr 9 18:07:56 2010 +0200 gallium: fix another compile warning after merge. Hmpf. commit 52953cd7b0e51deafecb812bdc40f9e45f9ac62a Author: Roland Scheidegger <sroland@vmware.com> Date: Fri Apr 9 18:02:11 2010 +0200 gallium: fix comment commit 7c8763aa6cfc74adf1ea49c2bab25ca17b32575f Author: unknown <michal@.(none)> Date: Fri Apr 9 18:05:20 2010 +0200 util: Fix type cast. commit 9d0086411a104b7cc9297aac0d1f82853118d7bf Author: unknown <michal@.(none)> Date: Fri Apr 9 18:04:33 2010 +0200 libgl-gdi: Use proper unwrap functions for resources. commit 251a5cdd18ba31c690ef61f133dfc65cd4a45cf8 Author: Roland Scheidegger <sroland@vmware.com> Date: Fri Apr 9 17:51:23 2010 +0200 gallium: more comments fixup commit 8f3f9d5e1e9c0de98a3dfb19e81250d2c32ee4e9 Author: Roland Scheidegger <sroland@vmware.com> Date: Fri Apr 9 17:48:18 2010 +0200 gallium: another fix after merge commit 41f00a32ee5be91512c048bacb89ede0e04bc08d Author: Roland Scheidegger <sroland@vmware.com> Date: Fri Apr 9 17:44:30 2010 +0200 gallium: more pipe_texture/resource fixes after merge commit faf53328d1154c51d8a59513f2bfcae62272b0bf Author: Roland Scheidegger <sroland@vmware.com> Date: Fri Apr 9 17:44:24 2010 +0200 gallium: fix comments for changed USAGE flags commit fdcb17bea4b0798d316b56deea69832f41142adf Author: Roland Scheidegger <sroland@vmware.com> Date: Fri Apr 9 16:40:07 2010 +0200 gallium/pb: pb uses PB_USAGE_ flags, not PIPE_TRANSFER_ (same value anyway) commit c95f7278ecc6db417ec1053279f2a8172c47aee9 Author: Keith Whitwell <keithw@vmware.com> Date: Fri Apr 9 13:44:35 2010 +0100 llvmpipe: fix merge glitches commit 28f8b8683175149a381be5eff263d4c20568bce7 Author: Keith Whitwell <keithw@vmware.com> Date: Fri Apr 9 13:41:39 2010 +0100 r300g: update after merge for pipe_resources commit 248c93cbc066ba6e3fadd94c5fcf3bdbb373d8fd Author: Keith Whitwell <keithw@vmware.com> Date: Fri Apr 9 13:41:20 2010 +0100 st/mesa: fix old pipe_texture usages commit a563b1c5c2cb57b3ef28a3654d9b477460d13ced Author: Keith Whitwell <keithw@vmware.com> Date: Fri Apr 9 13:40:56 2010 +0100 r300g: remove unused variable commit 734500131d828c9dfd68c5fa26b3e6b07e086d2d Author: Keith Whitwell <keithw@vmware.com> Date: Fri Apr 9 13:40:36 2010 +0100 nv50: fix compiler warning commit efd402e13037e5c3e29759fa5b1c754c6d65d0e2 Merge: fec8a1d 5452615 Author: Keith Whitwell <keithw@vmware.com> Date: Fri Apr 9 13:33:57 2010 +0100 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/drivers/cell/ppu/cell_screen.c src/gallium/drivers/cell/ppu/cell_texture.c src/gallium/drivers/llvmpipe/lp_screen.c src/gallium/drivers/r300/r300_context.c src/gallium/drivers/r300/r300_render.c src/gallium/drivers/r300/r300_screen.c src/gallium/drivers/r300/r300_state.c src/gallium/drivers/r300/r300_texture.c src/gallium/drivers/r300/r300_transfer.c src/gallium/state_trackers/egl/common/egl_g3d.h src/gallium/state_trackers/egl/kms/native_kms.c src/gallium/state_trackers/egl/x11/native_dri2.c src/gallium/state_trackers/egl/x11/native_ximage.c commit fec8a1db13fac04ef56f6ece799d1f20aa3011db Author: Marek Olšák <maraeo@gmail.com> Date: Sat Apr 3 07:58:34 2010 +0200 util: fix assertion failures in pipe_buffer_flush_mapped_range commit 1ff3984c2edce9927744f3cce3e7b07778990170 Author: Roland Scheidegger <sroland@vmware.com> Date: Thu Apr 8 17:44:54 2010 +0200 docs: fix transfer_map description commit 20bf14be8ac6438cb1afa38212e306fc06a5ed40 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Apr 8 14:39:13 2010 +0100 util: fix up several uses of pipe_map_buffer_range This function used to return a pointer to where the start of the actual buffer would have been, even though only the requested range is being mapped. In the resources change, the function was modified to use a transfer internally, and started returning the pointer to the beginning of the transfer, ie the mapped range. Some users of the function were changed to reflect this new behaviour, some were not. Since then the function has reverted to its original behaviour, matching master. This change restores some of the users of the map_buffer_range helper to expect the old/original behaviour. commit 33179a86058b68b518f40971030db337dc26fe6e Author: Keith Whitwell <keithw@vmware.com> Date: Thu Apr 8 14:38:54 2010 +0100 mesa/st: fix up several uses of pipe_map_buffer_range This function used to return a pointer to where the start of the actual buffer would have been, even though only the requested range is being mapped. In the resources change, the function was modified to use a transfer internally, and started returning the pointer to the beginning of the transfer, ie the mapped range. Some users of the function were changed to reflect this new behaviour, some were not. Since then the function has reverted to its original behaviour, matching master. This change restores some of the users of the map_buffer_range helper to expect the old/original behaviour. commit 3f5363d4dc9d7ad48467ae82d58d5f3d9bd10698 Author: Keith Whitwell <keithw@vmware.com> Date: Wed Apr 7 17:26:52 2010 +0100 util: map_range and flush_range have offsets relative to start of buffer commit 7eb1bfb97a790c73188d6b616d54fb3849e69b1e Author: Keith Whitwell <keithw@vmware.com> Date: Wed Apr 7 17:26:08 2010 +0100 nv50: fix compiler warning commit d040daff0642dd791ac38e9b353dc251b03fc873 Author: Keith Whitwell <keithw@vmware.com> Date: Wed Apr 7 17:25:58 2010 +0100 nvfx: fix compiler warning commit 49ec01dffb8e99ab3ff8f856287db7b4df3efed6 Author: Chia-I Wu <olv@lunarg.com> Date: Mon Apr 5 11:58:53 2010 +0800 mesa/es: Fixes for gallium-resources. commit 47c87ada452be45766928a01b6d69da63e3a5f5e Author: Marek Olšák <maraeo@gmail.com> Date: Sat Apr 3 05:19:20 2010 +0200 r300g: fix transfers for textures created from winsys handles commit 5f2701fddaef9c18d85c049311c2819c49cc1ae0 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Sat Apr 3 03:52:38 2010 +0200 nouveau: don't use the staging usage Maybe it could make sense, but for now dynamic is enough. None of these avoid uncached reads from GART on AGP cards. commit 0db20fa49e008f35911007fa7ed9be1d678a2161 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Sat Apr 3 03:27:19 2010 +0200 i965: add brw_resource.c to Makefile commit b94f3e7389cbd1b6465de3c04e8059ce73f1ea1f Author: Luca Barbieri <luca@luca-barbieri.com> Date: Sat Apr 3 01:48:33 2010 +0200 nouveau: fix for gallium-resources commit a01ff99a19986e6beb7903431e60a074945b09bc Author: Roland Scheidegger <sroland@vmware.com> Date: Thu Apr 1 19:26:35 2010 +0200 gallium: fix missing includes commit 26aeded562ce947a6deeb867fe22bf8daf7b1a1a Author: Roland Scheidegger <sroland@vmware.com> Date: Thu Apr 1 19:19:18 2010 +0200 gallium: remove video interface and related stuff These interfaces weren't quite was needed, and building disabled for a while. Some code actually build since some branch merge, and were now not fully converted to gallium-resources. See http://www.mail-archive.com/mesa3d-dev@lists.sourceforge.net/msg09619.html for a discussion of this. Video related work is done in origin/pipe-video branch. commit c64285aea45997a276fb141d7badc8a04f617c7c Author: Roland Scheidegger <sroland@vmware.com> Date: Thu Apr 1 18:45:54 2010 +0200 python: fixes for resource changes doesn't look quite ok yet, but sort of compiles. commit 03d4d5a41f5cf158a358fd705c695e1c987a328f Author: Roland Scheidegger <sroland@vmware.com> Date: Thu Apr 1 18:34:46 2010 +0200 gallium: s/u_box_orgin_2d/u_box_origin_2d commit 2444f023142bcaf7bd310b44794580f273254408 Author: Marek Olšák <maraeo@gmail.com> Date: Thu Apr 1 03:26:50 2010 +0200 r300g: fix segfault when the transfers functions are used Still broken. commit 6f09bf4066ab651b323c131bb07978e700519805 Author: Roland Scheidegger <sroland@vmware.com> Date: Thu Apr 1 00:05:12 2010 +0200 r300g: compile fixes commit 76711ff40d2092f9ef03d452de7458c4e76d9246 Author: Roland Scheidegger <sroland@vmware.com> Date: Thu Apr 1 00:04:47 2010 +0200 nvfx: more compile fixes commit c5d2e90c9cc119447a447dc04a4bce4ab91fc671 Author: Roland Scheidegger <sroland@vmware.com> Date: Wed Mar 31 23:18:50 2010 +0200 gallium: more mostly merge fallout fixes... commit fbc3722696790857f4adc936190406e74dffd969 Merge: 86d9225 d97f696 Author: Roland Scheidegger <sroland@vmware.com> Date: Wed Mar 31 22:09:35 2010 +0200 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/drivers/cell/ppu/cell_screen.c src/gallium/drivers/i915/i915_buffer.c src/gallium/drivers/i915/i915_context.h src/gallium/drivers/i915/i915_resource_texture.c src/gallium/drivers/i915/i915_screen.c src/gallium/drivers/i915/i915_state_emit.c src/gallium/drivers/i965/brw_resource_texture.c src/gallium/drivers/llvmpipe/lp_screen.c src/gallium/drivers/llvmpipe/lp_setup.c src/gallium/drivers/nvfx/nv30_fragtex.c src/gallium/drivers/nvfx/nv40_fragtex.c src/gallium/drivers/nvfx/nvfx_miptree.c src/gallium/drivers/nvfx/nvfx_screen.c src/gallium/drivers/nvfx/nvfx_transfer.c src/gallium/drivers/r300/r300_state.c src/gallium/drivers/svga/svga_screen_texture.c src/gallium/state_trackers/dri/common/dri_drawable.c src/gallium/state_trackers/dri/common/dri_screen.c src/gallium/state_trackers/dri/common/dri_st_api.h src/gallium/state_trackers/dri/drm/dri1.c src/gallium/state_trackers/dri/drm/dri1.h src/gallium/state_trackers/dri/drm/dri2.c src/gallium/state_trackers/python/st_device.c src/gallium/state_trackers/python/st_sample.c src/mesa/state_tracker/st_cb_clear.c src/mesa/state_tracker/st_cb_drawpixels.c src/mesa/state_tracker/st_cb_readpixels.c src/mesa/state_tracker/st_cb_texture.c src/mesa/state_tracker/st_extensions.c commit 86d9225d19d194eebbbe95b059695697c3307d15 Author: Roland Scheidegger <sroland@vmware.com> Date: Wed Mar 31 19:06:06 2010 +0200 gallium: more fixes for bind changes commit a215ef0606347e34669a580ec8df93ede7e46399 Author: Roland Scheidegger <sroland@vmware.com> Date: Wed Mar 31 18:48:36 2010 +0200 gallium/docs: some updates for bind changes commit c6c7e6746cbc7af59f7972719ed76f43e8ac16fc Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 30 20:24:26 2010 +0200 gallium: more bind change compile fixes commit a83fa1504b78180524a5eb454ae186741a27cdf8 Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 30 17:37:13 2010 +0200 compile fixes commit 30dc8afcd243d6a160571bac5f06d773e54a4196 Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 30 16:56:28 2010 +0200 fix some merge issues commit 30aa617fee11fe50c0a9c2f33fcd120a474f5e34 Merge: 1dde609 3a830bc Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 30 16:09:45 2010 +0200 Merge commit 'origin/gallium-buffer-usage-cleanup' into gallium-resources Conflicts: src/gallium/drivers/nouveau/nouveau_screen.c src/gallium/drivers/nvfx/nvfx_transfer.c src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c commit 1dde609ad6c9d2dfa0a5f7167f3c5bcf023b7c4d Author: Roland Scheidegger <sroland@vmware.com> Date: Wed Mar 24 02:35:00 2010 +0100 docs: some updates for pipe_resource commit f236f9660d31b936f54b64ae07e569f8637067bd Author: Luca Barbieri <luca@luca-barbieri.com> Date: Wed Mar 24 01:31:28 2010 +0100 nvfx: fix for gallium-resources It seems to work with basic applications but almost surely needs more work. In particular, it probably shouldn't use PIPE_BUFFER_USAGE_* flags and should use PIPE_TRANSFER_* in several places. Also, we probably don't want the vtable indirect calls and that ought to be replaced with something better instead. commit 5a136ad7b63768cb9a753eff8686c44592e62325 Author: Luca Barbieri <luca@luca-barbieri.com> Date: Wed Mar 24 01:31:19 2010 +0100 nv50: fix build in gallium-resources Not actually tested. Also needs next patch tee to actually build, this is just the nv50 part split from the rest. commit 3a830bc4a3f0f60c925b9434845a6bcad9a913c5 Author: Keith Whitwell <keithw@vmware.com> Date: Tue Mar 23 14:00:52 2010 -0700 st/egl: fix up for binding flags commit c6a80dc32ef17bc972d4137ce7444ebed4d28ebb Author: Keith Whitwell <keithw@vmware.com> Date: Tue Mar 23 13:52:15 2010 -0700 r300: restore 4k alignment for oqbo buffers commit e75a8d5ea9e0ffcf67bc858e08937e10b4fc74ba Author: Keith Whitwell <keithw@vmware.com> Date: Tue Mar 23 13:00:07 2010 -0700 gallium: bind flags commit 1f5b509543a7f399835fd9edf27c18e1643fab7d Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 23 19:32:21 2010 +0100 i965g: scons compile fixes commit 2c385f8f905ec794d9119c05c6293e0b1b9b565a Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 23 19:20:33 2010 +0100 nouveau: drm compile fix commit b285086ebd5132b47c340897c4622cc9fbd286cb Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 23 18:36:19 2010 +0100 r300g: pipe_resource compile fixes bring back mistakenly deleted radeon_buffer.h plus some more commit 7810606f423ef2f51f0a14b919640c2fd2c931aa Author: Michal Krol <michal@vmware.com> Date: Tue Mar 23 16:21:03 2010 +0100 softpipe: Map GS constants, too. commit 366f1176fb89d2b1978da6cfe60000b76bbc7338 Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 23 15:51:52 2010 +0100 failover: update for pipe_resources commit 615f44d70d293704ed821bc0b21fcfe6e363895d Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 23 15:51:02 2010 +0100 identity: remove double is_resource_reference assignment commit 7008586020395905ddfff333d02b3893de369796 Author: Roland Scheidegger <sroland@vmware.com> Date: Tue Mar 23 15:50:32 2010 +0100 trace: compile fix commit 058c5697bda4c9cf7b49d26ee27a34586544efaa Merge: dd7ba13 b33fd3c Author: Keith Whitwell <keithw@vmware.com> Date: Tue Mar 23 06:40:39 2010 -0700 Merge commit 'origin/gallium-resources' into gallium-buffer-usage-cleanup Conflicts: src/gallium/state_trackers/vega/api_filters.c src/mesa/state_tracker/st_cb_drawpixels.c commit b33fd3ce3daf2921a895367d0ed3fd9c718a8575 Author: Michal Krol <michal@vmware.com> Date: Mon Mar 22 21:03:26 2010 +0100 gallium: Usage parameter of get_transfer/transfer_inline_write is a bitfield. commit 9c1162d9d656062a490a529997def3f674cc61fc Author: Michal Krol <michal@vmware.com> Date: Mon Mar 22 20:50:49 2010 +0100 scons: Update file lists after gallium-resources changes. commit af9793ab9e5386b150d6b25c0d1978fdc67172e4 Author: Michal Krol <michal@vmware.com> Date: Mon Mar 22 20:04:39 2010 +0100 gallium: Do not use `template` for formal parameter names. commit dc2e12d714c444af9ff1acdd5a7e91408b116c99 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:41:34 2010 +0000 ws/nouveau: remove pipe_texture reference commit b94c72329f1be85887d40d49b0586979da469d77 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:40:41 2010 +0000 ws/xlib: remove pipe_buffer reference in comment commit 0a2af3eeae7de1d1cb433f0a2c35136b115f9920 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:39:34 2010 +0000 st/vega: clean up reference to pipe_texture commit 437ce98daae46be5d532fbb04c7cbf4a503c1623 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:39:02 2010 +0000 st/python: begin conversion to pipe_resources, much more to do commit 1b02e1ee3e5e87774f0c9e5f0e1898b7f8de1b16 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:29:34 2010 +0000 st/xorg: update for pipe_resources commit eb39977fe7a1d9f0c3f4f2d4303a93c2c613cc3b Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:23:51 2010 +0000 st/dri: update for pipe_resources commit e447aeff597a4d8c0f5de25854c14c99f2cc138c Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:23:36 2010 +0000 st/egl: update for pipe_resources commit e4cc48da8fdbd7d521257a6d7cd10e6fc5aa1a65 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:08:44 2010 +0000 r300: drop use of R300 DONT SYNC flag commit 129a83ab4d32e44ded5faea3f86ae5e1e62cddb6 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:08:17 2010 +0000 pipebuffer: use transfer flag commit 575b35ee6b683d77095ef21c573c1de207107e79 Merge: f29ac73 9fc6c8b Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 22:03:25 2010 +0000 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/drivers/llvmpipe/lp_texture.c src/gallium/drivers/r300/r300_context.c src/gallium/drivers/r300/r300_texture.c src/gallium/winsys/drm/radeon/core/radeon_buffer.h commit f29ac73f3f626d5779a627b7fa6fecdb60a35aab Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 18:37:25 2010 +0000 cell: attempt to convert to pipe_resources Can't even compile test this driver. commit 484b1947f4af81bab60b41f21c3c23ea6f67488c Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 17:25:50 2010 +0000 nvfx: restore usage of pipe_winsys The interface that cannot be killed... commit ac76ac6eb30f4f9aa9f5733d60358b357925953a Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 17:25:10 2010 +0000 nv50: fix warning commit 9683f4423449fa5acf6c019c571223650473bd82 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 17:14:31 2010 +0000 util: restore u_simple_screen, nouveau still relies on it commit 961cbcb62232689c959965384c6aa9b8eca697c1 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 16:51:54 2010 +0000 nouveau: convert nvfx and nv50 to pipe_resources Compile tested only. This was a deeper change than I was hoping for, due to the layering of the pipe_texture implementation in each driver on top of a shared pipe_buffer implementation in the shared code. Have modified the shared code to act as a set of convenience routines operating on nouveau_bo objects. Each driver now uses the u_resource_vtbl technique to split the implementation of pipe_resources between the existing miptree code for textures and a new, minimal buffer implementation in each driver. Eventually these should be combined, not least because APIs are now allowing things like binding buffer resources as textures and render targets. commit 18ba74016db13b23282f5033ee37b628a12ee566 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 10:02:54 2010 +0000 r300: fix compilation after merge Also build r300 by default. commit eb9c0175c8e4baca3fcb0b8364f83ceba9d74e0d Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 09:59:49 2010 +0000 st/vega: fix up after merge commit ea8dd1d4ae7b58c9315c3491046ef3852ddd3377 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 09:59:44 2010 +0000 aux: remove unused piperesource helpers commit be7af29d3ad1a10409b0ea689d882cf30a4e1d62 Merge: d22c2c6 12deb9e Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 21 09:54:53 2010 +0000 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/auxiliary/cso_cache/cso_context.c src/gallium/auxiliary/cso_cache/cso_context.h src/gallium/drivers/r300/r300_context.c src/gallium/drivers/r300/r300_render.c src/gallium/drivers/r300/r300_state.c src/gallium/drivers/r300/r300_state_derived.c src/gallium/state_trackers/vega/api_filters.c src/gallium/state_trackers/vega/image.c src/gallium/state_trackers/vega/image.h src/gallium/state_trackers/vega/mask.c src/gallium/state_trackers/vega/mask.h src/gallium/state_trackers/vega/paint.c src/gallium/state_trackers/vega/paint.h src/gallium/state_trackers/vega/renderer.c src/gallium/state_trackers/vega/renderer.h src/gallium/state_trackers/vega/shader.c src/gallium/state_trackers/vega/vg_context.h src/gallium/state_trackers/vega/vg_tracker.c src/mesa/state_tracker/st_manager.c commit d22c2c6cb23a063e3334a165d0c5c3d73f05d234 Author: Keith Whitwell <keithw@vmware.com> Date: Sat Mar 20 11:48:54 2010 +0000 drm/r300: update for r300g pipe_resources conversion Remove old files that related to pipe_buffers but weren't being built. Hopefully this is correct. commit f07b2c836958bee5796899123eca4ed05ac6242b Author: Keith Whitwell <keithw@vmware.com> Date: Sat Mar 20 11:47:03 2010 +0000 r300: convert to pipe_resources Do a very shallow conversion - basically keeping the existing buffer and texture code intact and using a vtbl struct inside our resource struct to select between the two implementations. The buffer and texture treatments could be further merged without much effort, but try to keep the existing code working at this point. commit feca9c3ca62daaf0d8745370106d4e3b22340c49 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Mar 18 06:00:34 2010 +0000 gallium: update new merges to pipe_resource commit 1cad983eac77a0c5333e6a3ce92b90ac87407714 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Mar 18 06:00:19 2010 +0000 drm/sw: update new merges to pipe_resource commit 191d39490ed792c569f98d42cf05891b264f71f8 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Mar 18 06:00:01 2010 +0000 vg: update new merges to pipe_resource commit b727c59bc44812ad503d9390505c92b738a5b8b0 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Mar 18 05:59:38 2010 +0000 llvmpipe: update new merges to pipe_resource commit 5f4b64b37fdcd70162c382b2ebbd494bef751dbd Author: Keith Whitwell <keithw@vmware.com> Date: Thu Mar 18 05:59:23 2010 +0000 brw: pipe_resource fixes commit d4aca209f531f1b65bf706ce1e5fc0375b587eb6 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Mar 18 05:59:06 2010 +0000 util: update new merges to pipe_resource commit cf6bef0afee10763c78509a3d17e9a6e49bcd3c8 Merge: 1997231 6de8e56 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Mar 18 05:38:50 2010 +0000 Merge commit 'origin/master' into gallium-resources commit 1997231916144485c3c4a36f53eda39fce460272 Merge: ad88ac7 e1ee3ea Author: Keith Whitwell <keithw@vmware.com> Date: Wed Mar 17 08:46:38 2010 +0000 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/auxiliary/Makefile src/gallium/auxiliary/util/u_blit.c src/gallium/auxiliary/util/u_blit.h src/gallium/auxiliary/util/u_gen_mipmap.c src/gallium/auxiliary/util/u_gen_mipmap.h src/mesa/state_tracker/st_cb_texture.c src/mesa/state_tracker/st_gen_mipmap.c commit ad88ac79034a91670940276e722bdd398d5c9023 Merge: 77bc770 8cdfd12 Author: Keith Whitwell <keithw@vmware.com> Date: Tue Mar 16 09:13:07 2010 +0000 Merge branch 'gallium-sampler-view' into gallium-resources Conflicts: src/gallium/auxiliary/cso_cache/cso_context.c src/gallium/auxiliary/util/u_blit.c src/gallium/drivers/llvmpipe/lp_texture.c src/gallium/drivers/softpipe/sp_texture.c src/mesa/state_tracker/st_cb_fbo.c src/mesa/state_tracker/st_framebuffer.c src/mesa/state_tracker/st_texture.c commit 77bc770c991ea025c82eaa4e0e2390efd825d96d Author: Keith Whitwell <keithw@vmware.com> Date: Mon Mar 15 22:21:48 2010 +0000 util: missing file commit f83c91db8ae63a3c3a34ff21492427a5663fb760 Merge: c1d4774 42910eb Author: Keith Whitwell <keithw@vmware.com> Date: Mon Mar 15 09:48:58 2010 +0000 Merge commit 'origin/gallium-sampler-view' into gallium-resources Conflicts: src/gallium/drivers/nv40/nv40_transfer.c src/gallium/drivers/nvfx/nvfx_transfer.c src/gallium/drivers/trace/tr_drm.c commit dd7ba1378fc50710667724d30d6d4cf1125ad61e Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 23:54:36 2010 +0000 gallium: start a cleanup of buffer_usage Remove fairly meaningless CPU/GPU READ/WRITE flags and replace with proper usages. commit c1d4774187189f4af8ff421b210824f3d53ceefb Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 23:05:45 2010 +0000 llvmpipe: don't FREE userbuffer data commit 9bfa07afe179f8060e7beefb754a29c4d9c6e349 Merge: 65757a1 08cddfe Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 22:54:51 2010 +0000 Merge commit 'origin/master' into gallium-resources Conflicts: src/gallium/drivers/llvmpipe/lp_rast.c src/gallium/drivers/llvmpipe/lp_scene.c src/gallium/drivers/llvmpipe/lp_texture.c src/gallium/drivers/llvmpipe/lp_texture.h src/gallium/drivers/softpipe/sp_texture.c src/gallium/drivers/svga/svga_screen_texture.c commit 65757a143f8e3fcd7afbc1ff92db44a823edf46c Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 22:41:17 2010 +0000 svga: build fixes commit 2f5435220501d4b3050cab2bb1dce6174cd13ff6 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 22:39:25 2010 +0000 gallivm: build fix commit 42642ec0984107d82b740711f2debbf38457a06e Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 22:38:33 2010 +0000 llvmpipe: convert to pipe_resources commit 7bbcb21e20cb545ef8dd5fc61d67ed931c69e813 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 22:19:30 2010 +0000 gallivm: convert to pipe_resources commit 88ae0d04610ca52649b42e32141a52af6d5a739b Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 21:01:22 2010 +0000 configs: build svga commit 0e112bc69828e65085ebfaef895ecd78fe53f1c4 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 21:01:17 2010 +0000 gallium: restore PIPE_BUFFER_USAGE_CUSTOM commit 102aca688b95c976b7178b84092fba7d041ff9d2 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 21:00:41 2010 +0000 util: more transfer helpers commit a79f6a4a0836fc64c07f9aeec21d914474fe3649 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 20:59:36 2010 +0000 svga: convert to use pipe_resrource As with others so far, a fairly shallow conversion. commit 087fb54492fa5e3baf040c5efbf7dacd98a8849b Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 18:38:08 2010 +0000 brw: fix function name commit cfc9dd707d16e06fd23b6926da3a6e2269f31dc8 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 18:19:06 2010 +0000 gallium: enable brw compile commit 8a5b86d76bdd3c7de63322423f59940a4dc2ee25 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 18:18:50 2010 +0000 brw: compiles with pipe_resource commit 563ca458b548c41ca4dca559354c16ca1a80d009 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 18:18:42 2010 +0000 i915: hook up userbuffer create commit b5095b48247b6020e36cc942ac145c3fccbe9a19 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 17:20:51 2010 +0000 i915: use helpers for is_resource_referenced commit d5392bdc6d70002acf9c5bac0fde14ba405c4d84 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 17:20:38 2010 +0000 util: helpers for is_resource_referenced commit 2f3492a5aefbb2e745f6700d8e910ebb5cbb98cf Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 17:08:50 2010 +0000 i915: remove buffer.c again commit 1373a35b65fcc25ec6cdfea2703bbb3417de2c6d Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 17:08:34 2010 +0000 i915: add new files to scons commit 0251612d70e57fe38e10e75915b394631d224f2c Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 16:38:29 2010 +0000 i915: compiling with pipe_resources commit 9a0235864252929a8eedd44dbd2fe30fe54c531d Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 13:51:16 2010 +0000 gallium: remove inline_read transfer commit a6ba315e25793e0c228d3a4ae2f8201634dc9ff0 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 13:50:32 2010 +0000 trace: get running Some dumping will be incorrect or disabled, but it runs without crashing commit 2133f1d90aa919662a8420a0cf3b4557e6ec1afd Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 13:49:42 2010 +0000 gallium: remove the inline_read transfer There aren't enough users of this to justify it. commit bccaf1fa30881f6b4fb189a9b74fc7af79c3b481 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 12:30:37 2010 +0000 identity: hook up inline transfer operations commit e4c152a344f2f53c842b810724a2ae7cb4554f58 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 12:21:54 2010 +0000 gallium: build trace and identity commit 0b5a311db78852fa9fd021e17b5968a1e0436b49 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 12:21:36 2010 +0000 gallium: add more of the transfer state to pipe_transfer Not really sure if recording all the arguments to the create_{transfer,texture,surface,etc} functions in the result of those calls is a great idea, but it seems we're fairly dependent on it throughout the code. commit a23985c26eafe76b0a7dacc892e50cb589f211fe Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 12:19:46 2010 +0000 identity: compiles with pipe_resources commit d0d630944304c208f6dade6ef8836763ee2bc7b4 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 12:13:02 2010 +0000 trace: compiles with pipe_resources commit a4451ea459cc8bfc915fe6aed2891b90854b6c9d Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 11:39:50 2010 +0000 softpipe: give userbuffers a format other than NONE Most mesa demos working commit 32bb1bd4ba29884a4ecfa11c8441d33dfceabcef Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 11:39:21 2010 +0000 util: correct argument order in pipe_buffer_map commit 7e2696c06445282feb781047277b260308760a33 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 11:32:55 2010 +0000 softpipe: transfer flush commit a0543b13c042e3c1142522d9d136f16fd4cabf78 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 11:32:13 2010 +0000 util: noop implementation of transfer_flush_region commit ce418533be752dbeb164e7ff82a99483048e482b Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 11:26:07 2010 +0000 gallium: softpipe runs gears with pipe_resources commit bfda4f2eb34498e4b7f3c608d30fccff6bb9651b Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 11:25:48 2010 +0000 util: get clip_tile working again commit f5ef219c3bed62b6a0da842e675fae16268e0fbe Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 09:43:20 2010 +0000 softpipe: use u_transfer helpers commit 072957aab25affecf0702e925310e46c694a5ee4 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 09:42:46 2010 +0000 util: helpers for inline transfers commit 9c45561fb0d7a52400093bcb2ce5f727fafd7777 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 09:42:25 2010 +0000 util: fix typo calculating transfer box commit f3e98fd47f36804d019a684d49ff230df3ab0cf5 Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 09:25:46 2010 +0000 st/vega: convert to pipe_resource commit d1b7b00afc944f6499c83d676c7642115d62a62c Author: Keith Whitwell <keithw@vmware.com> Date: Sun Mar 14 08:37:56 2010 +0000 gallium: begin converting drivers to pipe_resource Work in progress... commit 51c25117f5d6da1926a2be5ecc66677952a8abf0 Author: Keith Whitwell <keithw@vmware.com> Date: Sat Mar 13 20:16:27 2010 +0000 gallium: work in progress on layering resources on top of old textures Helper code in an aux module to avoid rewriting all the drivers. commit fb6764d3ce95c55aa78af2f1c8cbb17b79ce1ba2 Author: Keith Whitwell <keithw@vmware.com> Date: Sat Mar 13 19:19:09 2010 +0000 heaps of wip commit ee6b3bc730fcdaf8da3646d62f04578ec06d36a1 Author: Keith Whitwell <keithw@vmware.com> Date: Sat Mar 13 16:38:02 2010 +0000 wip2 commit 1830880212445189fe267d615075239ed17c7cc0 Merge: 90b4045 47bfbd4 Author: Keith Whitwell <keithw@vmware.com> Date: Sat Mar 13 15:14:03 2010 +0000 Merge branch 'gallium-sampler-view' into gallium-resources Conflicts: src/gallium/include/pipe/p_context.h src/mesa/state_tracker/st_atom_texture.c src/mesa/state_tracker/st_cb_bitmap.c src/mesa/state_tracker/st_cb_drawpixels.c src/mesa/state_tracker/st_cb_texture.c src/mesa/state_tracker/st_context.c src/mesa/state_tracker/st_context.h src/mesa/state_tracker/st_texture.h commit 90b4045fbc0a093fcd04efba7e045ec259c490b8 Author: Keith Whitwell <keithw@vmware.com> Date: Sat Mar 13 14:52:43 2010 +0000 wip
-rw-r--r--configs/default2
-rw-r--r--configs/linux-debug2
-rw-r--r--src/gallium/auxiliary/Makefile4
-rw-r--r--src/gallium/auxiliary/SConscript4
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c21
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c14
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.c2
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample.h8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h44
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c34
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h1
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h1
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c10
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_validate.c6
-rw-r--r--src/gallium/auxiliary/util/u_blit.c33
-rw-r--r--src/gallium/auxiliary/util/u_blit.h2
-rw-r--r--src/gallium/auxiliary/util/u_blitter.c29
-rw-r--r--src/gallium/auxiliary/util/u_box.h73
-rw-r--r--src/gallium/auxiliary/util/u_debug.c37
-rw-r--r--src/gallium/auxiliary/util/u_debug.h4
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.c106
-rw-r--r--src/gallium/auxiliary/util/u_draw_quad.h4
-rw-r--r--src/gallium/auxiliary/util/u_dump.h2
-rw-r--r--src/gallium/auxiliary/util/u_dump_state.c19
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c69
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.h2
-rw-r--r--src/gallium/auxiliary/util/u_inlines.h292
-rw-r--r--src/gallium/auxiliary/util/u_rect.c102
-rw-r--r--src/gallium/auxiliary/util/u_resource.c97
-rw-r--r--src/gallium/auxiliary/util/u_sampler.c6
-rw-r--r--src/gallium/auxiliary/util/u_sampler.h4
-rw-r--r--src/gallium/auxiliary/util/u_simple_screen.c137
-rw-r--r--src/gallium/auxiliary/util/u_simple_screen.h23
-rw-r--r--src/gallium/auxiliary/util/u_surface.c23
-rw-r--r--src/gallium/auxiliary/util/u_surface.h6
-rw-r--r--src/gallium/auxiliary/util/u_tile.c32
-rw-r--r--src/gallium/auxiliary/util/u_tile.h18
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.c312
-rw-r--r--src/gallium/auxiliary/util/u_timed_winsys.h41
-rw-r--r--src/gallium/auxiliary/util/u_transfer.c110
-rw-r--r--src/gallium/auxiliary/util/u_transfer.h145
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.c75
-rw-r--r--src/gallium/auxiliary/util/u_upload_mgr.h10
-rw-r--r--src/gallium/auxiliary/vl/vl_bitstream_parser.c167
-rw-r--r--src/gallium/auxiliary/vl/vl_bitstream_parser.h63
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.c536
-rw-r--r--src/gallium/auxiliary/vl/vl_compositor.h77
-rw-r--r--src/gallium/auxiliary/vl/vl_csc.c206
-rw-r--r--src/gallium/auxiliary/vl/vl_csc.h53
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c1672
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h121
-rw-r--r--src/gallium/auxiliary/vl/vl_shader_build.c243
-rw-r--r--src/gallium/auxiliary/vl/vl_shader_build.h88
-rw-r--r--src/gallium/docs/source/context.rst52
-rw-r--r--src/gallium/docs/source/screen.rst135
-rw-r--r--src/gallium/drivers/cell/ppu/Makefile1
-rw-r--r--src/gallium/drivers/cell/ppu/cell_buffer.c118
-rw-r--r--src/gallium/drivers/cell/ppu/cell_buffer.h55
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c17
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.h4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.c10
-rw-r--r--src/gallium/drivers/cell/ppu/cell_fence.c10
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c20
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.c9
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_emit.c4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c10
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c276
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h17
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.h2
-rw-r--r--src/gallium/drivers/failover/fo_context.c28
-rw-r--r--src/gallium/drivers/failover/fo_context.h2
-rw-r--r--src/gallium/drivers/failover/fo_state.c12
-rw-r--r--src/gallium/drivers/i915/Makefile5
-rw-r--r--src/gallium/drivers/i915/SConscript5
-rw-r--r--src/gallium/drivers/i915/i915_buffer.c138
-rw-r--r--src/gallium/drivers/i915/i915_buffer.h31
-rw-r--r--src/gallium/drivers/i915/i915_context.c52
-rw-r--r--src/gallium/drivers/i915/i915_context.h39
-rw-r--r--src/gallium/drivers/i915/i915_resource.c51
-rw-r--r--src/gallium/drivers/i915/i915_resource.h114
-rw-r--r--src/gallium/drivers/i915/i915_resource_buffer.c162
-rw-r--r--src/gallium/drivers/i915/i915_resource_texture.c (renamed from src/gallium/drivers/i915/i915_texture.c)461
-rw-r--r--src/gallium/drivers/i915/i915_screen.c10
-rw-r--r--src/gallium/drivers/i915/i915_state.c30
-rw-r--r--src/gallium/drivers/i915/i915_state_emit.c9
-rw-r--r--src/gallium/drivers/i915/i915_state_sampler.c9
-rw-r--r--src/gallium/drivers/i915/i915_surface.c78
-rw-r--r--src/gallium/drivers/i915/i915_surface.h (renamed from src/gallium/drivers/i915/i915_texture.h)12
-rw-r--r--src/gallium/drivers/i915/i915_winsys.h6
-rw-r--r--src/gallium/drivers/i965/Makefile8
-rw-r--r--src/gallium/drivers/i965/SConscript8
-rw-r--r--src/gallium/drivers/i965/brw_context.c3
-rw-r--r--src/gallium/drivers/i965/brw_context.h6
-rw-r--r--src/gallium/drivers/i965/brw_curbe.c26
-rw-r--r--src/gallium/drivers/i965/brw_draw.c16
-rw-r--r--src/gallium/drivers/i965/brw_draw_upload.c21
-rw-r--r--src/gallium/drivers/i965/brw_pipe_flush.c31
-rw-r--r--src/gallium/drivers/i965/brw_pipe_sampler.c6
-rw-r--r--src/gallium/drivers/i965/brw_pipe_shader.c10
-rw-r--r--src/gallium/drivers/i965/brw_pipe_vertex.c4
-rw-r--r--src/gallium/drivers/i965/brw_resource.c50
-rw-r--r--src/gallium/drivers/i965/brw_resource.h151
-rw-r--r--src/gallium/drivers/i965/brw_resource_buffer.c201
-rw-r--r--src/gallium/drivers/i965/brw_resource_texture.c (renamed from src/gallium/drivers/i965/brw_screen_texture.c)433
-rw-r--r--src/gallium/drivers/i965/brw_resource_texture_layout.c (renamed from src/gallium/drivers/i965/brw_screen_tex_layout.c)66
-rw-r--r--src/gallium/drivers/i965/brw_screen.c8
-rw-r--r--src/gallium/drivers/i965/brw_screen.h104
-rw-r--r--src/gallium/drivers/i965/brw_screen_buffers.c202
-rw-r--r--src/gallium/drivers/i965/brw_screen_surface.c13
-rw-r--r--src/gallium/drivers/i965/brw_util.c36
-rw-r--r--src/gallium/drivers/i965/brw_vs_surface_state.c2
-rw-r--r--src/gallium/drivers/i965/brw_wm.c5
-rw-r--r--src/gallium/drivers/i965/brw_wm_constant_buffer.c2
-rw-r--r--src/gallium/drivers/i965/brw_wm_sampler_state.c8
-rw-r--r--src/gallium/drivers/i965/brw_wm_surface_state.c2
-rw-r--r--src/gallium/drivers/identity/id_context.c159
-rw-r--r--src/gallium/drivers/identity/id_objects.c132
-rw-r--r--src/gallium/drivers/identity/id_objects.h97
-rw-r--r--src/gallium/drivers/identity/id_screen.c198
-rw-r--r--src/gallium/drivers/llvmpipe/Makefile1
-rw-r--r--src/gallium/drivers/llvmpipe/SConscript1
-rw-r--r--src/gallium/drivers/llvmpipe/lp_buffer.c118
-rw-r--r--src/gallium/drivers/llvmpipe/lp_buffer.h55
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.c22
-rw-r--r--src/gallium/drivers/llvmpipe/lp_context.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_draw_arrays.c9
-rw-r--r--src/gallium/drivers/llvmpipe/lp_flush.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_flush.h2
-rw-r--r--src/gallium/drivers/llvmpipe/lp_rast.c4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_scene.c36
-rw-r--r--src/gallium/drivers/llvmpipe/lp_scene.h8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_screen.c16
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.c29
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup.h9
-rw-r--r--src/gallium/drivers/llvmpipe/lp_setup_context.h4
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state.h8
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_fs.c9
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_sampler.c6
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.c229
-rw-r--r--src/gallium/drivers/llvmpipe/lp_texture.h42
-rw-r--r--src/gallium/drivers/nouveau/Makefile6
-rw-r--r--src/gallium/drivers/nouveau/nouveau_context.c41
-rw-r--r--src/gallium/drivers/nouveau/nouveau_context.h11
-rw-r--r--src/gallium/drivers/nouveau/nouveau_screen.c225
-rw-r--r--src/gallium/drivers/nouveau/nouveau_screen.h70
-rw-r--r--src/gallium/drivers/nouveau/nouveau_util.h6
-rw-r--r--src/gallium/drivers/nouveau/nouveau_winsys.h28
-rw-r--r--src/gallium/drivers/nv50/Makefile2
-rw-r--r--src/gallium/drivers/nv50/nv50_buffer.c150
-rw-r--r--src/gallium/drivers/nv50/nv50_context.c6
-rw-r--r--src/gallium/drivers/nv50/nv50_context.h37
-rw-r--r--src/gallium/drivers/nv50/nv50_miptree.c130
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c12
-rw-r--r--src/gallium/drivers/nv50/nv50_push.c7
-rw-r--r--src/gallium/drivers/nv50/nv50_resource.c67
-rw-r--r--src/gallium/drivers/nv50/nv50_resource.h90
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.c7
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.h2
-rw-r--r--src/gallium/drivers/nv50/nv50_state.c8
-rw-r--r--src/gallium/drivers/nv50/nv50_state_validate.c5
-rw-r--r--src/gallium/drivers/nv50/nv50_surface.c1
-rw-r--r--src/gallium/drivers/nv50/nv50_tex.c1
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c84
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.h31
-rw-r--r--src/gallium/drivers/nv50/nv50_vbo.c33
-rw-r--r--src/gallium/drivers/nvfx/Makefile5
-rw-r--r--src/gallium/drivers/nvfx/nv04_surface_2d.c51
-rw-r--r--src/gallium/drivers/nvfx/nv04_surface_2d.h4
-rw-r--r--src/gallium/drivers/nvfx/nv30_fragtex.c5
-rw-r--r--src/gallium/drivers/nvfx/nv40_fragtex.c7
-rw-r--r--src/gallium/drivers/nvfx/nvfx_buffer.c153
-rw-r--r--src/gallium/drivers/nvfx/nvfx_context.c6
-rw-r--r--src/gallium/drivers/nvfx/nvfx_context.h9
-rw-r--r--src/gallium/drivers/nvfx/nvfx_draw.c28
-rw-r--r--src/gallium/drivers/nvfx/nvfx_fragprog.c55
-rw-r--r--src/gallium/drivers/nvfx/nvfx_miptree.c225
-rw-r--r--src/gallium/drivers/nvfx/nvfx_resource.c67
-rw-r--r--src/gallium/drivers/nvfx/nvfx_resource.h91
-rw-r--r--src/gallium/drivers/nvfx/nvfx_screen.c15
-rw-r--r--src/gallium/drivers/nvfx/nvfx_screen.h1
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state.c10
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state.h20
-rw-r--r--src/gallium/drivers/nvfx/nvfx_state_fb.c14
-rw-r--r--src/gallium/drivers/nvfx/nvfx_transfer.c137
-rw-r--r--src/gallium/drivers/nvfx/nvfx_transfer.h26
-rw-r--r--src/gallium/drivers/nvfx/nvfx_vbo.c34
-rw-r--r--src/gallium/drivers/nvfx/nvfx_vertprog.c12
-rw-r--r--src/gallium/drivers/r300/Makefile1
-rw-r--r--src/gallium/drivers/r300/r300_blit.c4
-rw-r--r--src/gallium/drivers/r300/r300_context.c41
-rw-r--r--src/gallium/drivers/r300/r300_context.h14
-rw-r--r--src/gallium/drivers/r300/r300_defines.h2
-rw-r--r--src/gallium/drivers/r300/r300_emit.c6
-rw-r--r--src/gallium/drivers/r300/r300_emit.h2
-rw-r--r--src/gallium/drivers/r300/r300_query.c21
-rw-r--r--src/gallium/drivers/r300/r300_render.c120
-rw-r--r--src/gallium/drivers/r300/r300_render.h10
-rw-r--r--src/gallium/drivers/r300/r300_resource.c92
-rw-r--r--src/gallium/drivers/r300/r300_screen.c27
-rw-r--r--src/gallium/drivers/r300/r300_screen.h2
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.c272
-rw-r--r--src/gallium/drivers/r300/r300_screen_buffer.h23
-rw-r--r--src/gallium/drivers/r300/r300_state.c31
-rw-r--r--src/gallium/drivers/r300/r300_state_derived.c6
-rw-r--r--src/gallium/drivers/r300/r300_texture.c288
-rw-r--r--src/gallium/drivers/r300/r300_texture.h42
-rw-r--r--src/gallium/drivers/r300/r300_transfer.c153
-rw-r--r--src/gallium/drivers/r300/r300_transfer.h20
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h11
-rw-r--r--src/gallium/drivers/softpipe/Makefile4
-rw-r--r--src/gallium/drivers/softpipe/SConscript2
-rw-r--r--src/gallium/drivers/softpipe/sp_buffer.c118
-rw-r--r--src/gallium/drivers/softpipe/sp_buffer.h55
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c18
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c16
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c10
-rw-r--r--src/gallium/drivers/softpipe/sp_state.h10
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c10
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c15
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c34
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.h4
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_tile_cache.c26
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_tile_cache.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c293
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.h32
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c26
-rw-r--r--src/gallium/drivers/softpipe/sp_video_context.c304
-rw-r--r--src/gallium/drivers/softpipe/sp_video_context.h57
-rw-r--r--src/gallium/drivers/svga/Makefile11
-rw-r--r--src/gallium/drivers/svga/SConscript8
-rw-r--r--src/gallium/drivers/svga/svga_cmd.c45
-rw-r--r--src/gallium/drivers/svga/svga_cmd.h1
-rw-r--r--src/gallium/drivers/svga/svga_context.c73
-rw-r--r--src/gallium/drivers/svga/svga_context.h4
-rw-r--r--src/gallium/drivers/svga/svga_draw.c38
-rw-r--r--src/gallium/drivers/svga/svga_draw.h6
-rw-r--r--src/gallium/drivers/svga/svga_draw_arrays.c40
-rw-r--r--src/gallium/drivers/svga/svga_draw_elements.c48
-rw-r--r--src/gallium/drivers/svga/svga_draw_private.h10
-rw-r--r--src/gallium/drivers/svga/svga_pipe_blit.c3
-rw-r--r--src/gallium/drivers/svga/svga_pipe_clear.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_constants.c4
-rw-r--r--src/gallium/drivers/svga/svga_pipe_draw.c6
-rw-r--r--src/gallium/drivers/svga/svga_pipe_flush.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_misc.c2
-rw-r--r--src/gallium/drivers/svga/svga_pipe_query.c4
-rw-r--r--src/gallium/drivers/svga/svga_pipe_sampler.c8
-rw-r--r--src/gallium/drivers/svga/svga_pipe_vertex.c8
-rw-r--r--src/gallium/drivers/svga/svga_resource.c55
-rw-r--r--src/gallium/drivers/svga/svga_resource.h (renamed from src/gallium/state_trackers/xorg/xvmc/attributes.c)37
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer.c355
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer.h (renamed from src/gallium/drivers/svga/svga_screen_buffer.h)36
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer_host.c2
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer_upload.c (renamed from src/gallium/drivers/svga/svga_screen_buffer.c)446
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer_upload.h54
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.c635
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.h (renamed from src/gallium/drivers/svga/svga_screen_texture.h)97
-rw-r--r--src/gallium/drivers/svga/svga_sampler_view.c199
-rw-r--r--src/gallium/drivers/svga/svga_sampler_view.h97
-rw-r--r--src/gallium/drivers/svga/svga_screen.c18
-rw-r--r--src/gallium/drivers/svga/svga_screen_texture.c1097
-rw-r--r--src/gallium/drivers/svga/svga_state_constants.c13
-rw-r--r--src/gallium/drivers/svga/svga_state_tss.c10
-rw-r--r--src/gallium/drivers/svga/svga_state_vdecl.c10
-rw-r--r--src/gallium/drivers/svga/svga_state_vs.c14
-rw-r--r--src/gallium/drivers/svga/svga_surface.c383
-rw-r--r--src/gallium/drivers/svga/svga_surface.h97
-rw-r--r--src/gallium/drivers/svga/svga_swtnl.h2
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_backend.c42
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_draw.c32
-rw-r--r--src/gallium/drivers/svga/svga_swtnl_private.h6
-rw-r--r--src/gallium/drivers/svga/svga_winsys.h33
-rw-r--r--src/gallium/drivers/trace/Makefile1
-rw-r--r--src/gallium/drivers/trace/SConscript1
-rw-r--r--src/gallium/drivers/trace/tr_buffer.c76
-rw-r--r--src/gallium/drivers/trace/tr_buffer.h70
-rw-r--r--src/gallium/drivers/trace/tr_context.c250
-rw-r--r--src/gallium/drivers/trace/tr_context.h6
-rw-r--r--src/gallium/drivers/trace/tr_dump.c31
-rw-r--r--src/gallium/drivers/trace/tr_dump.h12
-rw-r--r--src/gallium/drivers/trace/tr_dump_state.c22
-rw-r--r--src/gallium/drivers/trace/tr_dump_state.h2
-rw-r--r--src/gallium/drivers/trace/tr_rbug.c39
-rw-r--r--src/gallium/drivers/trace/tr_screen.c294
-rw-r--r--src/gallium/drivers/trace/tr_screen.h6
-rw-r--r--src/gallium/drivers/trace/tr_texture.c47
-rw-r--r--src/gallium/drivers/trace/tr_texture.h29
-rw-r--r--src/gallium/include/pipe/p_context.h64
-rw-r--r--src/gallium/include/pipe/p_defines.h225
-rw-r--r--src/gallium/include/pipe/p_format.h18
-rw-r--r--src/gallium/include/pipe/p_screen.h113
-rw-r--r--src/gallium/include/pipe/p_state.h86
-rw-r--r--src/gallium/include/pipe/p_video_context.h121
-rw-r--r--src/gallium/include/pipe/p_video_state.h185
-rw-r--r--src/gallium/include/state_tracker/dri1_api.h2
-rw-r--r--src/gallium/include/state_tracker/drm_api.h2
-rw-r--r--src/gallium/include/state_tracker/st_api.h10
-rw-r--r--src/gallium/include/state_tracker/sw_winsys.h8
-rw-r--r--src/gallium/state_trackers/dri/common/dri1_helper.c4
-rw-r--r--src/gallium/state_trackers/dri/common/dri1_helper.h2
-rw-r--r--src/gallium/state_trackers/dri/common/dri_drawable.h2
-rw-r--r--src/gallium/state_trackers/dri/common/dri_screen.c18
-rw-r--r--src/gallium/state_trackers/dri/common/dri_st_api.c8
-rw-r--r--src/gallium/state_trackers/dri/common/dri_st_api.h2
-rw-r--r--src/gallium/state_trackers/dri/drm/dri1.c24
-rw-r--r--src/gallium/state_trackers/dri/drm/dri2.c23
-rw-r--r--src/gallium/state_trackers/dri/sw/drisw.c22
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.c16
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d.h4
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_image.c12
-rw-r--r--src/gallium/state_trackers/egl/common/egl_g3d_st.c22
-rw-r--r--src/gallium/state_trackers/egl/common/native.h2
-rw-r--r--src/gallium/state_trackers/egl/kms/native_kms.c29
-rw-r--r--src/gallium/state_trackers/egl/kms/native_kms.h4
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c24
-rw-r--r--src/gallium/state_trackers/egl/x11/native_ximage.c21
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_api.c2
-rw-r--r--src/gallium/state_trackers/glx/xlib/xm_st.c38
-rw-r--r--src/gallium/state_trackers/python/gallium.i3
-rw-r--r--src/gallium/state_trackers/python/p_context.i165
-rw-r--r--src/gallium/state_trackers/python/p_device.i22
-rw-r--r--src/gallium/state_trackers/python/p_state.i4
-rw-r--r--src/gallium/state_trackers/python/p_texture.i157
-rw-r--r--src/gallium/state_trackers/python/st_device.c36
-rw-r--r--src/gallium/state_trackers/python/st_device.h6
-rw-r--r--src/gallium/state_trackers/python/st_sample.c24
-rw-r--r--src/gallium/state_trackers/vega/api_filters.c28
-rw-r--r--src/gallium/state_trackers/vega/api_images.c8
-rw-r--r--src/gallium/state_trackers/vega/api_masks.c7
-rw-r--r--src/gallium/state_trackers/vega/image.c32
-rw-r--r--src/gallium/state_trackers/vega/image.h2
-rw-r--r--src/gallium/state_trackers/vega/mask.c40
-rw-r--r--src/gallium/state_trackers/vega/mask.h2
-rw-r--r--src/gallium/state_trackers/vega/paint.c20
-rw-r--r--src/gallium/state_trackers/vega/paint.h2
-rw-r--r--src/gallium/state_trackers/vega/polygon.c9
-rw-r--r--src/gallium/state_trackers/vega/renderer.c61
-rw-r--r--src/gallium/state_trackers/vega/renderer.h8
-rw-r--r--src/gallium/state_trackers/vega/shader.c9
-rw-r--r--src/gallium/state_trackers/vega/st_inlines.h67
-rw-r--r--src/gallium/state_trackers/vega/vg_context.c24
-rw-r--r--src/gallium/state_trackers/vega/vg_context.h10
-rw-r--r--src/gallium/state_trackers/vega/vg_manager.c12
-rw-r--r--src/gallium/state_trackers/vega/vg_tracker.c36
-rw-r--r--src/gallium/state_trackers/vega/vg_tracker.h2
-rw-r--r--src/gallium/state_trackers/wgl/stw_pixelformat.c6
-rw-r--r--src/gallium/state_trackers/xorg/xorg_crtc.c18
-rw-r--r--src/gallium/state_trackers/xorg/xorg_dri2.c26
-rw-r--r--src/gallium/state_trackers/xorg/xorg_driver.c16
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.c87
-rw-r--r--src/gallium/state_trackers/xorg/xorg_exa.h6
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.c70
-rw-r--r--src/gallium/state_trackers/xorg/xorg_renderer.h12
-rw-r--r--src/gallium/state_trackers/xorg/xorg_tracker.h8
-rw-r--r--src/gallium/state_trackers/xorg/xorg_xv.c42
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/Makefile16
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/SConscript27
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/block.c88
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/context.c252
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/subpicture.c195
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/surface.c408
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/.gitignore5
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/Makefile28
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/test_blocks.c111
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/test_context.c119
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/test_rendering.c317
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/test_surface.c98
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/testlib.c146
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/testlib.h69
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/tests/xvmc_bench.c300
-rw-r--r--src/gallium/state_trackers/xorg/xvmc/xvmc_private.h58
-rw-r--r--src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c2
-rw-r--r--src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c2
-rw-r--r--src/gallium/winsys/g3dvl/Makefile11
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/Makefile43
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.c172
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.h39
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.c88
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.h20
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c94
-rw-r--r--src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.h10
-rw-r--r--src/gallium/winsys/g3dvl/vl_winsys.h51
-rw-r--r--src/gallium/winsys/g3dvl/xlib/Makefile68
-rw-r--r--src/gallium/winsys/g3dvl/xlib/xsp_winsys.c330
-rw-r--r--src/gallium/winsys/nouveau/drm/nouveau_drm_api.c18
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm.h16
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_drm_buffer.c24
-rw-r--r--src/gallium/winsys/radeon/drm/radeon_r300.c6
-rw-r--r--src/gallium/winsys/sw/dri/dri_sw_winsys.c2
-rw-r--r--src/gallium/winsys/sw/gdi/gdi_sw_winsys.c2
-rw-r--r--src/gallium/winsys/sw/null/null_sw_winsys.c2
-rw-r--r--src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c46
-rw-r--r--src/gallium/winsys/sw/xlib/xlib_sw_winsys.c4
-rw-r--r--src/mesa/es/state_tracker/st_cb_drawtex.c14
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c10
-rw-r--r--src/mesa/state_tracker/st_atom_framebuffer.c25
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c16
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c9
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c53
-rw-r--r--src/mesa/state_tracker/st_cb_blit.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c100
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.h5
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c10
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c69
-rw-r--r--src/mesa/state_tracker/st_cb_eglimage.c8
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c39
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.h4
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c30
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c74
-rw-r--r--src/mesa/state_tracker/st_context.c2
-rw-r--r--src/mesa/state_tracker/st_context.h8
-rw-r--r--src/mesa/state_tracker/st_draw.c31
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c37
-rw-r--r--src/mesa/state_tracker/st_extensions.c20
-rw-r--r--src/mesa/state_tracker/st_format.c14
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c4
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c30
-rw-r--r--src/mesa/state_tracker/st_inlines.h83
-rw-r--r--src/mesa/state_tracker/st_manager.c18
-rw-r--r--src/mesa/state_tracker/st_public.h4
-rw-r--r--src/mesa/state_tracker/st_texture.c71
-rw-r--r--src/mesa/state_tracker/st_texture.h30
430 files changed, 9266 insertions, 16111 deletions
diff --git a/configs/default b/configs/default
index 593fc32b7d..dd701de040 100644
--- a/configs/default
+++ b/configs/default
@@ -98,7 +98,7 @@ EGL_DRIVERS_DIRS = glx
# Gallium directories and
GALLIUM_DIRS = auxiliary drivers state_trackers
GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
-GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity
+GALLIUM_DRIVERS_DIRS = softpipe trace identity i915 i965 svga r300 nvfx nv50 failover
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
GALLIUM_WINSYS_DIRS = sw sw/xlib
GALLIUM_TARGET_DIRS = libgl-xlib
diff --git a/configs/linux-debug b/configs/linux-debug
index 01763b1a30..60e0b9769f 100644
--- a/configs/linux-debug
+++ b/configs/linux-debug
@@ -5,5 +5,5 @@ include $(TOP)/configs/linux
CONFIG_NAME = linux-debug
OPT_FLAGS = -g
-CFLAGS += -pedantic
+#CFLAGS += -pedantic
DEFINES += -DDEBUG -DDEBUG_MATH
diff --git a/src/gallium/auxiliary/Makefile b/src/gallium/auxiliary/Makefile
index 050c7043c3..c4d6b528b7 100644
--- a/src/gallium/auxiliary/Makefile
+++ b/src/gallium/auxiliary/Makefile
@@ -131,9 +131,9 @@ C_SOURCES = \
util/u_surface.c \
util/u_texture.c \
util/u_tile.c \
- util/u_timed_winsys.c \
+ util/u_transfer.c \
+ util/u_resource.c \
util/u_upload_mgr.c \
- util/u_simple_screen.c \
target-helpers/wrap_screen.c
# Disabling until pipe-video branch gets merged in
diff --git a/src/gallium/auxiliary/SConscript b/src/gallium/auxiliary/SConscript
index c23fbdf70a..bd8139f1de 100644
--- a/src/gallium/auxiliary/SConscript
+++ b/src/gallium/auxiliary/SConscript
@@ -172,6 +172,7 @@ source = [
'util/u_math.c',
'util/u_mm.c',
'util/u_rect.c',
+ 'util/u_resource.c',
'util/u_ringbuffer.c',
'util/u_sampler.c',
'util/u_simple_shaders.c',
@@ -179,9 +180,8 @@ source = [
'util/u_surface.c',
'util/u_texture.c',
'util/u_tile.c',
- 'util/u_timed_winsys.c',
+ 'util/u_transfer.c',
'util/u_upload_mgr.c',
- 'util/u_simple_screen.c',
# Disabling until pipe-video branch gets merged in
#'vl/vl_bitstream_parser.c',
#'vl/vl_mpeg12_mc_renderer.c',
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index f4615064e6..3844c04dd3 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -88,7 +88,7 @@ struct aaline_stage
uint pos_slot;
void *sampler_cso;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_sampler_view *sampler_view;
uint num_samplers;
uint num_sampler_views;
@@ -396,7 +396,7 @@ aaline_create_texture(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture texTemp;
+ struct pipe_resource texTemp;
struct pipe_sampler_view viewTempl;
uint level;
@@ -408,7 +408,7 @@ aaline_create_texture(struct aaline_stage *aaline)
texTemp.height0 = 1 << MAX_TEXTURE_LEVEL;
texTemp.depth0 = 1;
- aaline->texture = screen->texture_create(screen, &texTemp);
+ aaline->texture = screen->resource_create(screen, &texTemp);
if (!aaline->texture)
return FALSE;
@@ -428,16 +428,23 @@ aaline_create_texture(struct aaline_stage *aaline)
*/
for (level = 0; level <= MAX_TEXTURE_LEVEL; level++) {
struct pipe_transfer *transfer;
+ struct pipe_box box;
const uint size = u_minify(aaline->texture->width0, level);
ubyte *data;
uint i, j;
assert(aaline->texture->width0 == aaline->texture->height0);
+ u_box_origin_2d( size, size, &box );
+
/* This texture is new, no need to flush.
*/
- transfer = pipe->get_tex_transfer(pipe, aaline->texture, 0, level, 0,
- PIPE_TRANSFER_WRITE, 0, 0, size, size);
+ transfer = pipe->get_transfer(pipe,
+ aaline->texture,
+ u_subresource(0, level),
+ PIPE_TRANSFER_WRITE,
+ &box);
+
data = pipe->transfer_map(pipe, transfer);
if (data == NULL)
return FALSE;
@@ -463,7 +470,7 @@ aaline_create_texture(struct aaline_stage *aaline)
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
return TRUE;
}
@@ -746,7 +753,7 @@ aaline_destroy(struct draw_stage *stage)
aaline->pipe->delete_sampler_state(aaline->pipe, aaline->sampler_cso);
if (aaline->texture)
- pipe_texture_reference(&aaline->texture, NULL);
+ pipe_resource_reference(&aaline->texture, NULL);
if (aaline->sampler_view) {
pipe_sampler_view_reference(&aaline->sampler_view, NULL);
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index 794fd81d70..bd433deeca 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -75,7 +75,7 @@ struct pstip_stage
struct draw_stage stage;
void *sampler_cso;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_sampler_view *sampler_view;
uint num_samplers;
uint num_sampler_views;
@@ -389,8 +389,8 @@ pstip_update_texture(struct pstip_stage *pstip)
*/
pipe->flush( pipe, PIPE_FLUSH_TEXTURE_CACHE, NULL );
- transfer = pipe->get_tex_transfer(pipe, pstip->texture, 0, 0, 0,
- PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
+ transfer = pipe_get_transfer(pipe, pstip->texture, 0, 0, 0,
+ PIPE_TRANSFER_WRITE, 0, 0, 32, 32);
data = pipe->transfer_map(pipe, transfer);
/*
@@ -414,7 +414,7 @@ pstip_update_texture(struct pstip_stage *pstip)
/* unmap */
pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
@@ -426,7 +426,7 @@ pstip_create_texture(struct pstip_stage *pstip)
{
struct pipe_context *pipe = pstip->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture texTemp;
+ struct pipe_resource texTemp;
struct pipe_sampler_view viewTempl;
memset(&texTemp, 0, sizeof(texTemp));
@@ -437,7 +437,7 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.height0 = 32;
texTemp.depth0 = 1;
- pstip->texture = screen->texture_create(screen, &texTemp);
+ pstip->texture = screen->resource_create(screen, &texTemp);
if (pstip->texture == NULL)
return FALSE;
@@ -591,7 +591,7 @@ pstip_destroy(struct draw_stage *stage)
pstip->pipe->delete_sampler_state(pstip->pipe, pstip->sampler_cso);
- pipe_texture_reference(&pstip->texture, NULL);
+ pipe_resource_reference(&pstip->texture, NULL);
if (pstip->sampler_view) {
pipe_sampler_view_reference(&pstip->sampler_view, NULL);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.c b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
index 0744be6b41..4004741c19 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.c
@@ -51,7 +51,7 @@
*/
void
lp_sampler_static_state(struct lp_sampler_static_state *state,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
const struct pipe_sampler_state *sampler)
{
memset(state, 0, sizeof *state);
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample.h b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
index 92f3c57435..fcbf084baf 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample.h
@@ -38,7 +38,7 @@
#include "gallivm/lp_bld.h"
-struct pipe_texture;
+struct pipe_resource;
struct pipe_sampler_state;
struct util_format_description;
struct lp_type;
@@ -48,7 +48,7 @@ struct lp_build_context;
/**
* Sampler static state.
*
- * These are the bits of state from pipe_texture and pipe_sampler_state that
+ * These are the bits of state from pipe_resource and pipe_sampler_state that
* are embedded in the generated code.
*/
struct lp_sampler_static_state
@@ -78,7 +78,7 @@ struct lp_sampler_static_state
/**
* Sampler dynamic state.
*
- * These are the bits of state from pipe_texture and pipe_sampler_state that
+ * These are the bits of state from pipe_resource and pipe_sampler_state that
* are computed in runtime.
*
* There are obtained through callbacks, as we don't want to tie the texture
@@ -130,7 +130,7 @@ struct lp_sampler_dynamic_state
*/
void
lp_sampler_static_state(struct lp_sampler_static_state *state,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
const struct pipe_sampler_state *sampler);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 34b1b77df4..a6c50dcf0c 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -48,7 +48,6 @@
#include "util/u_debug.h"
#include "util/u_inlines.h"
#include "pipe/p_defines.h"
-#include "pipe/p_state.h"
#ifdef __cplusplus
@@ -58,8 +57,23 @@ extern "C" {
struct pb_vtbl;
struct pb_validate;
+struct pipe_fence_handle;
+#define PB_USAGE_CPU_READ (1 << 0)
+#define PB_USAGE_CPU_WRITE (1 << 1)
+#define PB_USAGE_GPU_READ (1 << 2)
+#define PB_USAGE_GPU_WRITE (1 << 3)
+#define PB_USAGE_UNSYNCHRONIZED (1 << 10)
+#define PB_USAGE_DONTBLOCK (1 << 9)
+
+#define PB_USAGE_CPU_READ_WRITE \
+ ( PB_USAGE_CPU_READ | PB_USAGE_CPU_WRITE )
+#define PB_USAGE_GPU_READ_WRITE \
+ ( PB_USAGE_GPU_READ | PB_USAGE_GPU_WRITE )
+#define PB_USAGE_WRITE \
+ ( PB_USAGE_CPU_WRITE | PB_USAGE_GPU_WRITE )
+
/**
* Buffer description.
*
@@ -83,7 +97,14 @@ typedef unsigned pb_size;
*/
struct pb_buffer
{
- struct pipe_buffer base;
+ /* This used to be a pipe_buffer struct:
+ */
+ struct {
+ struct pipe_reference reference;
+ unsigned size;
+ unsigned alignment;
+ unsigned usage;
+ } base;
/**
* Pointer to the virtual function table.
@@ -106,7 +127,7 @@ struct pb_vtbl
/**
* Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_FLAG_READ/WRITE.
+ * flags is bitmask of PB_USAGE_CPU_READ/WRITE.
*/
void *(*map)( struct pb_buffer *buf,
unsigned flags );
@@ -138,23 +159,6 @@ struct pb_vtbl
};
-static INLINE struct pipe_buffer *
-pb_pipe_buffer( struct pb_buffer *pbuf )
-{
- assert(pbuf);
- return &pbuf->base;
-}
-
-
-static INLINE struct pb_buffer *
-pb_buffer( struct pipe_buffer *buf )
-{
- assert(buf);
- /* Could add a magic cookie check on debug builds.
- */
- return (struct pb_buffer *)buf;
-}
-
/* Accessor functions for pb->vtbl:
*/
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index d97f749b6e..d6cf640582 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -135,7 +135,7 @@ struct fenced_buffer
void *data;
/**
- * A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current
+ * A bitmask of PB_USAGE_CPU/GPU_READ/WRITE describing the current
* buffer usage.
*/
unsigned flags;
@@ -270,7 +270,7 @@ fenced_buffer_add_locked(struct fenced_manager *fenced_mgr,
struct fenced_buffer *fenced_buf)
{
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
- assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
+ assert(fenced_buf->flags & PB_USAGE_GPU_READ_WRITE);
assert(fenced_buf->fence);
p_atomic_inc(&fenced_buf->base.base.reference.count);
@@ -299,7 +299,7 @@ fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr,
assert(fenced_buf->mgr == fenced_mgr);
ops->fence_reference(ops, &fenced_buf->fence, NULL);
- fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ fenced_buf->flags &= ~PB_USAGE_GPU_READ_WRITE;
assert(fenced_buf->head.prev);
assert(fenced_buf->head.next);
@@ -377,7 +377,7 @@ fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr,
assert(!destroyed);
- fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ fenced_buf->flags &= ~PB_USAGE_GPU_READ_WRITE;
ret = PIPE_OK;
}
@@ -624,7 +624,7 @@ fenced_buffer_copy_storage_to_gpu_locked(struct fenced_buffer *fenced_buf)
assert(fenced_buf->data);
assert(fenced_buf->buffer);
- map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pb_map(fenced_buf->buffer, PB_USAGE_CPU_WRITE);
if(!map)
return PIPE_ERROR;
@@ -644,7 +644,7 @@ fenced_buffer_copy_storage_to_cpu_locked(struct fenced_buffer *fenced_buf)
assert(fenced_buf->data);
assert(fenced_buf->buffer);
- map = pb_map(fenced_buf->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pb_map(fenced_buf->buffer, PB_USAGE_CPU_READ);
if(!map)
return PIPE_ERROR;
@@ -683,24 +683,24 @@ fenced_buffer_map(struct pb_buffer *buf,
pipe_mutex_lock(fenced_mgr->mutex);
- assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
+ assert(!(flags & PB_USAGE_GPU_READ_WRITE));
/*
* Serialize writes.
*/
- while((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) ||
- ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) &&
- (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) {
+ while((fenced_buf->flags & PB_USAGE_GPU_WRITE) ||
+ ((fenced_buf->flags & PB_USAGE_GPU_READ) &&
+ (flags & PB_USAGE_CPU_WRITE))) {
/*
* Don't wait for the GPU to finish accessing it, if blocking is forbidden.
*/
- if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) &&
+ if((flags & PB_USAGE_DONTBLOCK) &&
ops->fence_signalled(ops, fenced_buf->fence, 0) != 0) {
goto done;
}
- if (flags & PIPE_BUFFER_USAGE_UNSYNCHRONIZED) {
+ if (flags & PB_USAGE_UNSYNCHRONIZED) {
break;
}
@@ -721,7 +721,7 @@ fenced_buffer_map(struct pb_buffer *buf,
if(map) {
++fenced_buf->mapcount;
- fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ fenced_buf->flags |= flags & PB_USAGE_CPU_READ_WRITE;
}
done:
@@ -745,7 +745,7 @@ fenced_buffer_unmap(struct pb_buffer *buf)
pb_unmap(fenced_buf->buffer);
--fenced_buf->mapcount;
if(!fenced_buf->mapcount)
- fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ fenced_buf->flags &= ~PB_USAGE_CPU_READ_WRITE;
}
pipe_mutex_unlock(fenced_mgr->mutex);
@@ -771,9 +771,9 @@ fenced_buffer_validate(struct pb_buffer *buf,
goto done;
}
- assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
- assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE));
- flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ assert(flags & PB_USAGE_GPU_READ_WRITE);
+ assert(!(flags & ~PB_USAGE_GPU_READ_WRITE));
+ flags &= PB_USAGE_GPU_READ_WRITE;
/* Buffer cannot be validated in two different lists */
if(fenced_buf->vl && fenced_buf->vl != vl) {
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
index 0372f81d0a..004c2b939a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
@@ -59,7 +59,6 @@ extern "C" {
#endif
-struct pipe_buffer;
struct pipe_fence_handle;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
index 6bdce5fcb0..b706f429be 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
@@ -135,9 +135,9 @@ pb_malloc_buffer_create(pb_size size,
return NULL;
pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
buf->base.base.size = size;
+ buf->base.base.alignment = desc->alignment;
buf->base.vtbl = &malloc_buffer_vtbl;
buf->data = align_malloc(size, desc->alignment < sizeof(void*) ? sizeof(void*) : desc->alignment);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index 06669917ff..cec2524da2 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -60,7 +60,6 @@ extern "C" {
struct pb_desc;
-struct pipe_buffer;
/**
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 0f2ae05dae..88501e8d72 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -242,7 +242,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
if(!pb_check_usage(desc->usage, buf->base.base.usage))
return FALSE;
- map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_DONTBLOCK);
+ map = pb_map(buf->buffer, PB_USAGE_DONTBLOCK);
if (!map) {
return FALSE;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index a5dbded2bc..0dc5b31a75 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -158,7 +158,7 @@ pb_debug_buffer_fill(struct pb_debug_buffer *buf)
{
uint8_t *map;
- map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = pb_map(buf->buffer, PB_USAGE_CPU_WRITE);
assert(map);
if(map) {
fill_random_pattern(map, buf->underflow_size);
@@ -180,8 +180,8 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
uint8_t *map;
map = pb_map(buf->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_UNSYNCHRONIZED);
assert(map);
if(map) {
boolean underflow, overflow;
@@ -382,8 +382,8 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
real_size = mgr->underflow_size + size + mgr->overflow_size;
real_desc = *desc;
- real_desc.usage |= PIPE_BUFFER_USAGE_CPU_WRITE;
- real_desc.usage |= PIPE_BUFFER_USAGE_CPU_READ;
+ real_desc.usage |= PB_USAGE_CPU_WRITE;
+ real_desc.usage |= PB_USAGE_CPU_READ;
buf->buffer = mgr->provider->create_buffer(mgr->provider,
real_size,
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 63195715d6..faf7c35267 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -268,8 +268,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
mm->buffer = buffer;
mm->map = pb_map(mm->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_CPU_WRITE);
if(!mm->map)
goto failure;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
index cb32d25136..31f1ebbeb7 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
@@ -150,7 +150,7 @@ pb_ondemand_buffer_instantiate(struct pb_ondemand_buffer *buf)
if(!buf->buffer)
return PIPE_ERROR_OUT_OF_MEMORY;
- map = pb_map(buf->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pb_map(buf->buffer, PB_USAGE_CPU_READ);
if(!map) {
pb_reference(&buf->buffer, NULL);
return PIPE_ERROR;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index fea234ae8c..fdcce42878 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -284,8 +284,8 @@ pool_bufmgr_create(struct pb_manager *provider,
goto failure;
pool->map = pb_map(pool->buffer,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_CPU_WRITE);
if(!pool->map)
goto failure;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index 24e2820f88..7a3305aaf3 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -315,8 +315,8 @@ pb_slab_create(struct pb_slab_manager *mgr)
/* Note down the slab virtual address. All mappings are accessed directly
* through this address so it is required that the buffer is pinned. */
slab->virtual = pb_map(slab->bo,
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PB_USAGE_CPU_READ |
+ PB_USAGE_CPU_WRITE);
if(!slab->virtual) {
ret = PIPE_ERROR_OUT_OF_MEMORY;
goto out_err1;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c
index 903afc749d..b585422460 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c
@@ -69,9 +69,9 @@ pb_validate_add_buffer(struct pb_validate *vl,
if(!buf)
return PIPE_ERROR;
- assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
- assert(!(flags & ~PIPE_BUFFER_USAGE_GPU_READ_WRITE));
- flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE;
+ assert(flags & PB_USAGE_GPU_READ_WRITE);
+ assert(!(flags & ~PB_USAGE_GPU_READ_WRITE));
+ flags &= PB_USAGE_GPU_READ_WRITE;
/* We only need to store one reference for each buffer, so avoid storing
* consecutive references for the same buffer. It might not be the most
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index cd95f85b63..7850f81e58 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -69,7 +69,7 @@ struct blit_state
void *vs;
void *fs[TGSI_WRITEMASK_XYZW + 1];
- struct pipe_buffer *vbuf; /**< quad vertices */
+ struct pipe_resource *vbuf; /**< quad vertices */
unsigned vbuf_slot;
float vertices[4][2][4]; /**< vertex/texcoords for quad */
@@ -167,7 +167,7 @@ util_destroy_blit(struct blit_state *ctx)
if (ctx->fs[i])
pipe->delete_fs_state(pipe, ctx->fs[i]);
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -186,8 +186,7 @@ get_next_slot( struct blit_state *ctx )
if (!ctx->vbuf) {
ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
max_slots * sizeof ctx->vertices);
}
@@ -236,7 +235,7 @@ setup_vertex_data_tex(struct blit_state *ctx,
offset = get_next_slot( ctx );
- pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf,
+ pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf,
offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
@@ -304,9 +303,9 @@ util_blit_pixels_writemask(struct blit_state *ctx,
filter == PIPE_TEX_MIPFILTER_LINEAR);
assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ PIPE_BIND_SAMPLER_VIEW, 0));
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
+ PIPE_BIND_RENDER_TARGET, 0));
/* do the regions overlap? */
overlap = util_same_surface(src, dst) &&
@@ -335,7 +334,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
}
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
+ PIPE_BIND_RENDER_TARGET, 0));
/* Create a temporary texture when src and dest alias or when src
* is anything other than a single-level 2d texture.
@@ -346,8 +345,8 @@ util_blit_pixels_writemask(struct blit_state *ctx,
src->texture->target != PIPE_TEXTURE_2D ||
src->texture->last_level != 0)
{
- struct pipe_texture texTemp;
- struct pipe_texture *tex;
+ struct pipe_resource texTemp;
+ struct pipe_resource *tex;
struct pipe_sampler_view sv_templ;
struct pipe_surface *texSurf;
const int srcLeft = MIN2(srcX0, srcX1);
@@ -376,7 +375,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- tex = screen->texture_create(screen, &texTemp);
+ tex = screen->resource_create(screen, &texTemp);
if (!tex)
return;
@@ -384,12 +383,12 @@ util_blit_pixels_writemask(struct blit_state *ctx,
sampler_view = ctx->pipe->create_sampler_view(ctx->pipe, tex, &sv_templ);
if (!sampler_view) {
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&tex, NULL);
return;
}
texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION);
/* load temp texture */
if (pipe->surface_copy) {
@@ -412,7 +411,7 @@ util_blit_pixels_writemask(struct blit_state *ctx,
t0 = 0.0f;
t1 = 1.0f;
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&tex, NULL);
}
else {
pipe_sampler_view_reference(&sampler_view, src_sampler_view);
@@ -540,7 +539,7 @@ util_blit_pixels(struct blit_state *ctx,
*/
void util_blit_flush( struct blit_state *ctx )
{
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
ctx->vbuf_slot = 0;
}
@@ -566,7 +565,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
struct pipe_framebuffer_state fb;
float s0, t0, s1, t1;
unsigned offset;
- struct pipe_texture *tex = src_sampler_view->texture;
+ struct pipe_resource *tex = src_sampler_view->texture;
assert(filter == PIPE_TEX_MIPFILTER_NEAREST ||
filter == PIPE_TEX_MIPFILTER_LINEAR);
@@ -582,7 +581,7 @@ util_blit_pixels_tex(struct blit_state *ctx,
assert(ctx->pipe->screen->is_format_supported(ctx->pipe->screen, dst->format,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ PIPE_BIND_RENDER_TARGET,
0));
/* save state (restored below) */
diff --git a/src/gallium/auxiliary/util/u_blit.h b/src/gallium/auxiliary/util/u_blit.h
index 1ebe65b455..464ff9aace 100644
--- a/src/gallium/auxiliary/util/u_blit.h
+++ b/src/gallium/auxiliary/util/u_blit.h
@@ -37,7 +37,7 @@ extern "C" {
struct pipe_context;
struct pipe_surface;
-struct pipe_texture;
+struct pipe_resource;
struct cso_context;
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index 1692987e8e..104cbf7f6c 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -56,7 +56,7 @@ struct blitter_context_priv
struct blitter_context blitter;
struct pipe_context *pipe; /**< pipe context */
- struct pipe_buffer *vbuf; /**< quad */
+ struct pipe_resource *vbuf; /**< quad */
float vertices[4][2][4]; /**< {pos, color} or {pos, texcoord} */
@@ -215,8 +215,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
/* create the vertex buffer */
ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
sizeof(ctx->vertices));
return &ctx->blitter;
@@ -259,7 +258,7 @@ void util_blitter_destroy(struct blitter_context *blitter)
pipe_sampler_view_reference(&ctx->sampler_view, NULL);
}
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -451,7 +450,7 @@ static void blitter_draw_quad(struct blitter_context_priv *ctx)
struct pipe_context *pipe = ctx->pipe;
/* write vertices and draw them */
- pipe_buffer_write(pipe->screen, ctx->vbuf,
+ pipe_buffer_write(pipe, ctx->vbuf,
0, sizeof(ctx->vertices), ctx->vertices);
util_draw_vertex_buffer(pipe, ctx->vbuf, 0, PIPE_PRIM_TRIANGLE_FAN,
@@ -714,8 +713,8 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter,
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture texTemp;
- struct pipe_texture *texture;
+ struct pipe_resource texTemp;
+ struct pipe_resource *texture;
struct pipe_surface *tex_surf;
/* check whether the states are properly saved */
@@ -729,13 +728,13 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter,
texTemp.height0 = height;
texTemp.depth0 = 1;
- texture = screen->texture_create(screen, &texTemp);
+ texture = screen->resource_create(screen, &texTemp);
if (!texture)
return;
tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION);
/* blit from the src to the temp */
util_blitter_do_copy(blitter, tex_surf, 0, 0,
@@ -747,7 +746,7 @@ static void util_blitter_overlap_copy(struct blitter_context *blitter,
width, height,
FALSE);
pipe_surface_reference(&tex_surf, NULL);
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
blitter_restore_CSOs(ctx);
}
@@ -781,8 +780,8 @@ void util_blitter_copy(struct blitter_context *blitter,
is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
- dst_tex_usage = is_depth || is_stencil ? PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ dst_tex_usage = is_depth || is_stencil ? PIPE_BIND_DEPTH_STENCIL :
+ PIPE_BIND_RENDER_TARGET;
/* check if we can sample from and render to the surfaces */
/* (assuming copying a stencil buffer is not possible) */
@@ -790,7 +789,7 @@ void util_blitter_copy(struct blitter_context *blitter,
!screen->is_format_supported(screen, dst->format, dst->texture->target,
dst_tex_usage, 0) ||
!screen->is_format_supported(screen, src->format, src->texture->target,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
width, height);
return;
@@ -827,7 +826,7 @@ void util_blitter_fill(struct blitter_context *blitter,
/* check if we can render to the surface */
if (util_format_is_depth_or_stencil(dst->format) || /* unlikely, but you never know */
!screen->is_format_supported(screen, dst->format, dst->texture->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
util_surface_fill(pipe, dst, dstx, dsty, width, height, value);
return;
}
diff --git a/src/gallium/auxiliary/util/u_box.h b/src/gallium/auxiliary/util/u_box.h
new file mode 100644
index 0000000000..919967b55a
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_box.h
@@ -0,0 +1,73 @@
+#ifndef UTIL_BOX_INLINES_H
+#define UTIL_BOX_INLINES_H
+
+#include "pipe/p_state.h"
+
+static INLINE
+void u_box_1d( unsigned x,
+ unsigned w,
+ struct pipe_box *box )
+{
+ box->x = x;
+ box->y = 0;
+ box->z = 0;
+ box->width = w;
+ box->height = 1;
+ box->depth = 1;
+}
+
+static INLINE
+void u_box_2d( unsigned x,
+ unsigned y,
+ unsigned w,
+ unsigned h,
+ struct pipe_box *box )
+{
+ box->x = x;
+ box->y = y;
+ box->z = 0;
+ box->width = w;
+ box->height = h;
+ box->depth = 1;
+}
+
+static INLINE
+void u_box_origin_2d( unsigned w,
+ unsigned h,
+ struct pipe_box *box )
+{
+ box->x = 0;
+ box->y = 0;
+ box->z = 0;
+ box->width = w;
+ box->height = h;
+ box->depth = 1;
+}
+
+static INLINE
+void u_box_2d_zslice( unsigned x,
+ unsigned y,
+ unsigned z,
+ unsigned w,
+ unsigned h,
+ struct pipe_box *box )
+{
+ box->x = x;
+ box->y = y;
+ box->z = z;
+ box->width = w;
+ box->height = h;
+ box->depth = 1;
+}
+
+static INLINE
+struct pipe_subresource u_subresource( unsigned face,
+ unsigned level )
+{
+ struct pipe_subresource subresource;
+ subresource.face = face;
+ subresource.level = level;
+ return subresource;
+}
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index e997cfa8a3..dd044973f9 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -425,7 +425,7 @@ void debug_dump_surface(struct pipe_context *pipe,
const char *prefix,
struct pipe_surface *surface)
{
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_transfer *transfer;
void *data;
@@ -440,7 +440,7 @@ void debug_dump_surface(struct pipe_context *pipe,
*/
texture = surface->texture;
- transfer = pipe->get_tex_transfer(pipe, texture, surface->face,
+ transfer = pipe_get_transfer(pipe, texture, surface->face,
surface->level, surface->zslice,
PIPE_TRANSFER_READ, 0, 0, surface->width,
surface->height);
@@ -452,20 +452,20 @@ void debug_dump_surface(struct pipe_context *pipe,
debug_dump_image(prefix,
texture->format,
util_format_get_blocksize(texture->format),
- util_format_get_nblocksx(texture->format, transfer->width),
- util_format_get_nblocksy(texture->format, transfer->height),
+ util_format_get_nblocksx(texture->format, surface->width),
+ util_format_get_nblocksy(texture->format, surface->height),
transfer->stride,
data);
pipe->transfer_unmap(pipe, transfer);
error:
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
void debug_dump_texture(struct pipe_context *pipe,
const char *prefix,
- struct pipe_texture *texture)
+ struct pipe_resource *texture)
{
struct pipe_surface *surface;
struct pipe_screen *screen;
@@ -477,7 +477,7 @@ void debug_dump_texture(struct pipe_context *pipe,
/* XXX for now, just dump image for face=0, level=0 */
surface = screen->get_tex_surface(screen, texture, 0, 0, 0,
- PIPE_TEXTURE_USAGE_SAMPLER);
+ PIPE_BIND_SAMPLER_VIEW);
if (surface) {
debug_dump_surface(pipe, prefix, surface);
screen->tex_surface_destroy(surface);
@@ -523,16 +523,16 @@ debug_dump_surface_bmp(struct pipe_context *pipe,
{
#ifndef PIPE_SUBSYSTEM_WINDOWS_MINIPORT
struct pipe_transfer *transfer;
- struct pipe_texture *texture = surface->texture;
+ struct pipe_resource *texture = surface->texture;
- transfer = pipe->get_tex_transfer(pipe, texture, surface->face,
- surface->level, surface->zslice,
- PIPE_TRANSFER_READ, 0, 0, surface->width,
- surface->height);
+ transfer = pipe_get_transfer(pipe, texture, surface->face,
+ surface->level, surface->zslice,
+ PIPE_TRANSFER_READ, 0, 0, surface->width,
+ surface->height);
debug_dump_transfer_bmp(pipe, filename, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
#endif
}
@@ -547,17 +547,20 @@ debug_dump_transfer_bmp(struct pipe_context *pipe,
if (!transfer)
goto error1;
- rgba = MALLOC(transfer->width*transfer->height*4*sizeof(float));
+ rgba = MALLOC(transfer->box.width *
+ transfer->box.height *
+ transfer->box.depth *
+ 4*sizeof(float));
if(!rgba)
goto error1;
pipe_get_tile_rgba(pipe, transfer, 0, 0,
- transfer->width, transfer->height,
+ transfer->box.width, transfer->box.height,
rgba);
debug_dump_float_rgba_bmp(filename,
- transfer->width, transfer->height,
- rgba, transfer->width);
+ transfer->box.width, transfer->box.height,
+ rgba, transfer->box.width);
FREE(rgba);
error1:
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index 98addeb372..b6d0b508e3 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -315,7 +315,7 @@ debug_memory_end(unsigned long beginning);
struct pipe_context;
struct pipe_surface;
struct pipe_transfer;
-struct pipe_texture;
+struct pipe_resource;
void debug_dump_image(const char *prefix,
unsigned format, unsigned cpp,
@@ -327,7 +327,7 @@ void debug_dump_surface(struct pipe_context *pipe,
struct pipe_surface *surface);
void debug_dump_texture(struct pipe_context *pipe,
const char *prefix,
- struct pipe_texture *texture);
+ struct pipe_resource *texture);
void debug_dump_surface_bmp(struct pipe_context *pipe,
const char *filename,
struct pipe_surface *surface);
diff --git a/src/gallium/auxiliary/util/u_draw_quad.c b/src/gallium/auxiliary/util/u_draw_quad.c
index 8c194102bf..b37b48b5ae 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.c
+++ b/src/gallium/auxiliary/util/u_draw_quad.c
@@ -30,6 +30,7 @@
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/u_draw_quad.h"
+#include "util/u_memory.h"
/**
@@ -38,7 +39,7 @@
*/
void
util_draw_vertex_buffer(struct pipe_context *pipe,
- struct pipe_buffer *vbuf,
+ struct pipe_resource *vbuf,
uint offset,
uint prim_type,
uint num_verts,
@@ -66,60 +67,63 @@ util_draw_vertex_buffer(struct pipe_context *pipe,
/**
* Draw screen-aligned textured quad.
- * Note: this function allocs/destroys a vertex buffer and isn't especially
- * efficient.
+ * Note: this isn't especially efficient.
*/
void
util_draw_texquad(struct pipe_context *pipe,
float x0, float y0, float x1, float y1, float z)
{
- struct pipe_buffer *vbuf;
- uint numAttribs = 2, vertexBytes, i, j;
-
- vertexBytes = 4 * (4 * numAttribs * sizeof(float));
-
- /* XXX create one-time */
- vbuf = pipe_buffer_create(pipe->screen, 32,
- PIPE_BUFFER_USAGE_VERTEX, vertexBytes);
- if (vbuf) {
- float *v = (float *) pipe_buffer_map(pipe->screen, vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- if (v) {
- /*
- * Load vertex buffer
- */
- for (i = j = 0; i < 4; i++) {
- v[j + 2] = z; /* z */
- v[j + 3] = 1.0; /* w */
- v[j + 6] = 0.0; /* r */
- v[j + 7] = 1.0; /* q */
- j += 8;
- }
-
- v[0] = x0;
- v[1] = y0;
- v[4] = 0.0; /*s*/
- v[5] = 0.0; /*t*/
-
- v[8] = x1;
- v[9] = y0;
- v[12] = 1.0;
- v[13] = 0.0;
-
- v[16] = x1;
- v[17] = y1;
- v[20] = 1.0;
- v[21] = 1.0;
-
- v[24] = x0;
- v[25] = y1;
- v[28] = 0.0;
- v[29] = 1.0;
-
- pipe_buffer_unmap(pipe->screen, vbuf);
- util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
- }
-
- pipe_buffer_reference(&vbuf, NULL);
+ uint numAttribs = 2, i, j;
+ uint vertexBytes = 4 * (4 * numAttribs * sizeof(float));
+ struct pipe_resource *vbuf = NULL;
+ uint *v = NULL;
+
+ v = MALLOC(vertexBytes);
+ if (v == NULL)
+ goto out;
+
+ /*
+ * Load vertex buffer
+ */
+ for (i = j = 0; i < 4; i++) {
+ v[j + 2] = z; /* z */
+ v[j + 3] = 1.0; /* w */
+ v[j + 6] = 0.0; /* r */
+ v[j + 7] = 1.0; /* q */
+ j += 8;
}
+
+ v[0] = x0;
+ v[1] = y0;
+ v[4] = 0.0; /*s*/
+ v[5] = 0.0; /*t*/
+
+ v[8] = x1;
+ v[9] = y0;
+ v[12] = 1.0;
+ v[13] = 0.0;
+
+ v[16] = x1;
+ v[17] = y1;
+ v[20] = 1.0;
+ v[21] = 1.0;
+
+ v[24] = x0;
+ v[25] = y1;
+ v[28] = 0.0;
+ v[29] = 1.0;
+
+ vbuf = pipe_user_buffer_create(pipe->screen, v, vertexBytes,
+ PIPE_BIND_VERTEX_BUFFER);
+ if (!vbuf)
+ goto out;
+
+ util_draw_vertex_buffer(pipe, vbuf, 0, PIPE_PRIM_TRIANGLE_FAN, 4, 2);
+
+out:
+ if (vbuf)
+ pipe_resource_reference(&vbuf, NULL);
+
+ if (v)
+ FREE(v);
}
diff --git a/src/gallium/auxiliary/util/u_draw_quad.h b/src/gallium/auxiliary/util/u_draw_quad.h
index 00d3f5b715..42eb184428 100644
--- a/src/gallium/auxiliary/util/u_draw_quad.h
+++ b/src/gallium/auxiliary/util/u_draw_quad.h
@@ -33,11 +33,11 @@
extern "C" {
#endif
-struct pipe_buffer;
+struct pipe_resource;
extern void
util_draw_vertex_buffer(struct pipe_context *pipe,
- struct pipe_buffer *vbuf, uint offset,
+ struct pipe_resource *vbuf, uint offset,
uint num_attribs, uint num_verts, uint prim_type);
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index 379f18ef38..bdc73ac47d 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -92,7 +92,7 @@ util_dump_tex_filter(unsigned value, boolean shortened);
void
util_dump_template(struct os_stream *stream,
- const struct pipe_texture *templat);
+ const struct pipe_resource *templat);
void
util_dump_rasterizer_state(struct os_stream *stream,
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 52cf3ef4ce..79fd38ef5c 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -255,14 +255,14 @@ util_dump_enum_func(struct os_stream *stream, unsigned value)
void
-util_dump_template(struct os_stream *stream, const struct pipe_texture *templat)
+util_dump_template(struct os_stream *stream, const struct pipe_resource *templat)
{
if(!templat) {
util_dump_null(stream);
return;
}
- util_dump_struct_begin(stream, "pipe_texture");
+ util_dump_struct_begin(stream, "pipe_resource");
util_dump_member(stream, int, templat, target);
util_dump_member(stream, format, templat, format);
@@ -280,7 +280,9 @@ util_dump_template(struct os_stream *stream, const struct pipe_texture *templat)
util_dump_member_end(stream);
util_dump_member(stream, uint, templat, last_level);
- util_dump_member(stream, uint, templat, tex_usage);
+ util_dump_member(stream, uint, templat, _usage);
+ util_dump_member(stream, uint, templat, bind);
+ util_dump_member(stream, uint, templat, flags);
util_dump_struct_end(stream);
}
@@ -653,16 +655,13 @@ util_dump_transfer(struct os_stream *stream, const struct pipe_transfer *state)
util_dump_struct_begin(stream, "pipe_transfer");
- util_dump_member(stream, uint, state, width);
- util_dump_member(stream, uint, state, height);
+ util_dump_member(stream, ptr, state, resource);
+// util_dump_member(stream, uint, state, box);
util_dump_member(stream, uint, state, stride);
- util_dump_member(stream, uint, state, usage);
+ util_dump_member(stream, uint, state, slice_stride);
- util_dump_member(stream, ptr, state, texture);
- util_dump_member(stream, uint, state, face);
- util_dump_member(stream, uint, state, level);
- util_dump_member(stream, uint, state, zslice);
+// util_dump_member(stream, ptr, state, data);
util_dump_struct_end(stream);
}
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 509d38754f..eee6030ddc 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -67,7 +67,7 @@ struct gen_mipmap_state
void *vs;
void *fs2d, *fsCube;
- struct pipe_buffer *vbuf; /**< quad vertices */
+ struct pipe_resource *vbuf; /**< quad vertices */
unsigned vbuf_slot;
float vertices[4][2][4]; /**< vertex/texcoords for quad */
@@ -1116,7 +1116,7 @@ reduce_3d(enum pipe_format pformat,
static void
make_1d_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
struct pipe_context *pipe = ctx->pipe;
@@ -1128,11 +1128,11 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_transfer *srcTrans, *dstTrans;
void *srcMap, *dstMap;
- srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice,
+ srcTrans = pipe_get_transfer(pipe, pt, face, srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
u_minify(pt->width0, srcLevel),
u_minify(pt->height0, srcLevel));
- dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice,
+ dstTrans = pipe_get_transfer(pipe, pt, face, dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
u_minify(pt->width0, dstLevel),
u_minify(pt->height0, dstLevel));
@@ -1141,21 +1141,21 @@ make_1d_mipmap(struct gen_mipmap_state *ctx,
dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
reduce_1d(pt->format,
- srcTrans->width, srcMap,
- dstTrans->width, dstMap);
+ srcTrans->box.width, srcMap,
+ dstTrans->box.width, dstMap);
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
- pipe->tex_transfer_destroy(pipe, srcTrans);
- pipe->tex_transfer_destroy(pipe, dstTrans);
+ pipe->transfer_destroy(pipe, srcTrans);
+ pipe->transfer_destroy(pipe, dstTrans);
}
}
static void
make_2d_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
struct pipe_context *pipe = ctx->pipe;
@@ -1170,36 +1170,36 @@ make_2d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice,
- PIPE_TRANSFER_READ, 0, 0,
- u_minify(pt->width0, srcLevel),
- u_minify(pt->height0, srcLevel));
- dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice,
- PIPE_TRANSFER_WRITE, 0, 0,
- u_minify(pt->width0, dstLevel),
- u_minify(pt->height0, dstLevel));
+ srcTrans = pipe_get_transfer(pipe, pt, face, srcLevel, zslice,
+ PIPE_TRANSFER_READ, 0, 0,
+ u_minify(pt->width0, srcLevel),
+ u_minify(pt->height0, srcLevel));
+ dstTrans = pipe_get_transfer(pipe, pt, face, dstLevel, zslice,
+ PIPE_TRANSFER_WRITE, 0, 0,
+ u_minify(pt->width0, dstLevel),
+ u_minify(pt->height0, dstLevel));
srcMap = (ubyte *) pipe->transfer_map(pipe, srcTrans);
dstMap = (ubyte *) pipe->transfer_map(pipe, dstTrans);
reduce_2d(pt->format,
- srcTrans->width, srcTrans->height,
+ srcTrans->box.width, srcTrans->box.height,
srcTrans->stride, srcMap,
- dstTrans->width, dstTrans->height,
+ dstTrans->box.width, dstTrans->box.height,
dstTrans->stride, dstMap);
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
- pipe->tex_transfer_destroy(pipe, srcTrans);
- pipe->tex_transfer_destroy(pipe, dstTrans);
+ pipe->transfer_destroy(pipe, srcTrans);
+ pipe->transfer_destroy(pipe, dstTrans);
}
}
static void
make_3d_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
#if 0
@@ -1215,11 +1215,11 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
struct pipe_transfer *srcTrans, *dstTrans;
ubyte *srcMap, *dstMap;
- srcTrans = pipe->get_tex_transfer(pipe, pt, face, srcLevel, zslice,
+ srcTrans = pipe->get_transfer(pipe, pt, face, srcLevel, zslice,
PIPE_TRANSFER_READ, 0, 0,
u_minify(pt->width0, srcLevel),
u_minify(pt->height0, srcLevel));
- dstTrans = pipe->get_tex_transfer(pipe, pt, face, dstLevel, zslice,
+ dstTrans = pipe->get_transfer(pipe, pt, face, dstLevel, zslice,
PIPE_TRANSFER_WRITE, 0, 0,
u_minify(pt->width0, dstLevel),
u_minify(pt->height0, dstLevel));
@@ -1236,8 +1236,8 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
pipe->transfer_unmap(pipe, srcTrans);
pipe->transfer_unmap(pipe, dstTrans);
- pipe->tex_transfer_destroy(pipe, srcTrans);
- pipe->tex_transfer_destroy(pipe, dstTrans);
+ pipe->transfer_destroy(pipe, srcTrans);
+ pipe->transfer_destroy(pipe, dstTrans);
}
#else
(void) reduce_3d;
@@ -1247,7 +1247,7 @@ make_3d_mipmap(struct gen_mipmap_state *ctx,
static void
fallback_gen_mipmap(struct gen_mipmap_state *ctx,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
uint face, uint baseLevel, uint lastLevel)
{
switch (pt->target) {
@@ -1358,8 +1358,7 @@ get_next_slot(struct gen_mipmap_state *ctx)
if (!ctx->vbuf) {
ctx->vbuf = pipe_buffer_create(ctx->pipe->screen,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
max_slots * sizeof ctx->vertices);
}
@@ -1420,7 +1419,7 @@ set_vertex_data(struct gen_mipmap_state *ctx,
offset = get_next_slot( ctx );
- pipe_buffer_write_nooverlap(ctx->pipe->screen, ctx->vbuf,
+ pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf,
offset, sizeof(ctx->vertices), ctx->vertices);
return offset;
@@ -1440,7 +1439,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
pipe->delete_fs_state(pipe, ctx->fs2d);
pipe->delete_fs_state(pipe, ctx->fsCube);
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
FREE(ctx);
}
@@ -1452,7 +1451,7 @@ util_destroy_gen_mipmap(struct gen_mipmap_state *ctx)
*/
void util_gen_mipmap_flush( struct gen_mipmap_state *ctx )
{
- pipe_buffer_reference(&ctx->vbuf, NULL);
+ pipe_resource_reference(&ctx->vbuf, NULL);
ctx->vbuf_slot = 0;
}
@@ -1476,7 +1475,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
struct pipe_framebuffer_state fb;
- struct pipe_texture *pt = psv->texture;
+ struct pipe_resource *pt = psv->texture;
void *fs = (pt->target == PIPE_TEXTURE_CUBE) ? ctx->fsCube : ctx->fs2d;
uint dstLevel;
uint zslice = 0;
@@ -1495,7 +1494,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
/* check if we can render in the texture's format */
if (!screen->is_format_supported(screen, psv->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
return;
}
@@ -1541,7 +1540,7 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
struct pipe_surface *surf =
screen->get_tex_surface(screen, pt, face, dstLevel, zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
/*
* Setup framebuffer / dest surface
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.h b/src/gallium/auxiliary/util/u_gen_mipmap.h
index 35ac9daeaa..a7502b9982 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.h
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.h
@@ -37,7 +37,7 @@ extern "C" {
struct pipe_context;
-struct pipe_texture;
+struct pipe_resource;
struct cso_context;
struct gen_mipmap_state;
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index e22ab188e1..c2f4f05990 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -34,6 +34,7 @@
#include "pipe/p_screen.h"
#include "util/u_debug.h"
#include "util/u_atomic.h"
+#include "util/u_box.h"
#ifdef __cplusplus
@@ -87,18 +88,6 @@ pipe_reference(struct pipe_reference *ptr, struct pipe_reference *reference)
return destroy;
}
-static INLINE void
-pipe_buffer_reference(struct pipe_buffer **ptr, struct pipe_buffer *buf)
-{
- struct pipe_buffer *old_buf;
-
- assert(ptr);
- old_buf = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &buf->reference))
- old_buf->screen->buffer_destroy(old_buf);
- *ptr = buf;
-}
static INLINE void
pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
@@ -110,16 +99,18 @@ pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf)
*ptr = surf;
}
+
static INLINE void
-pipe_texture_reference(struct pipe_texture **ptr, struct pipe_texture *tex)
+pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
{
- struct pipe_texture *old_tex = *ptr;
+ struct pipe_resource *old_tex = *ptr;
if (pipe_reference(&(*ptr)->reference, &tex->reference))
- old_tex->screen->texture_destroy(old_tex);
+ old_tex->screen->resource_destroy(old_tex->screen, old_tex);
*ptr = tex;
}
+
static INLINE void
pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_view *view)
{
@@ -135,91 +126,135 @@ pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_
* Convenience wrappers for screen buffer functions.
*/
-static INLINE struct pipe_buffer *
+static INLINE struct pipe_resource *
pipe_buffer_create( struct pipe_screen *screen,
- unsigned alignment, unsigned usage, unsigned size )
+ unsigned bind,
+ unsigned size )
{
- return screen->buffer_create(screen, alignment, usage, size);
+ struct pipe_resource buffer;
+ memset(&buffer, 0, sizeof buffer);
+ buffer.target = PIPE_BUFFER;
+ buffer.format = PIPE_FORMAT_R8_UNORM; /* want TYPELESS or similar */
+ buffer.bind = bind;
+ buffer._usage = PIPE_USAGE_DEFAULT;
+ buffer.flags = 0;
+ buffer.width0 = size;
+ buffer.height0 = 1;
+ buffer.depth0 = 1;
+ return screen->resource_create(screen, &buffer);
}
-static INLINE struct pipe_buffer *
-pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size )
+
+static INLINE struct pipe_resource *
+pipe_user_buffer_create( struct pipe_screen *screen, void *ptr, unsigned size,
+ unsigned usage )
{
- return screen->user_buffer_create(screen, ptr, size);
+ return screen->user_buffer_create(screen, ptr, size, usage);
}
static INLINE void *
-pipe_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned usage)
+pipe_buffer_map_range(struct pipe_context *pipe,
+ struct pipe_resource *buffer,
+ unsigned offset,
+ unsigned length,
+ unsigned usage,
+ struct pipe_transfer **transfer)
{
- if(screen->buffer_map_range) {
- unsigned offset = 0;
- unsigned length = buf->size;
- return screen->buffer_map_range(screen, buf, offset, length, usage);
+ struct pipe_box box;
+ void *map;
+
+ assert(offset < buffer->width0);
+ assert(offset + length <= buffer->width0);
+ assert(length);
+
+ u_box_1d(offset, length, &box);
+
+ *transfer = pipe->get_transfer( pipe,
+ buffer,
+ u_subresource(0, 0),
+ usage,
+ &box);
+
+ if (*transfer == NULL)
+ return NULL;
+
+ map = pipe->transfer_map( pipe, *transfer );
+ if (map == NULL) {
+ pipe->transfer_destroy( pipe, *transfer );
+ return NULL;
}
- else
- return screen->buffer_map(screen, buf, usage);
+
+ /* Match old screen->buffer_map_range() behaviour, return pointer
+ * to where the beginning of the buffer would be:
+ */
+ return (void *)((char *)map - offset);
}
-static INLINE void
-pipe_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
+
+static INLINE void *
+pipe_buffer_map(struct pipe_context *pipe,
+ struct pipe_resource *buffer,
+ unsigned usage,
+ struct pipe_transfer **transfer)
{
- screen->buffer_unmap(screen, buf);
+ return pipe_buffer_map_range(pipe, buffer, 0, buffer->width0, usage, transfer);
}
-static INLINE void *
-pipe_buffer_map_range(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset,
- unsigned length,
- unsigned usage)
+
+static INLINE void
+pipe_buffer_unmap(struct pipe_context *pipe,
+ struct pipe_resource *buf,
+ struct pipe_transfer *transfer)
{
- assert(offset < buf->size);
- assert(offset + length <= buf->size);
- assert(length);
- if(screen->buffer_map_range)
- return screen->buffer_map_range(screen, buf, offset, length, usage);
- else
- return screen->buffer_map(screen, buf, usage);
+ if (transfer) {
+ pipe->transfer_unmap(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
+ }
}
static INLINE void
-pipe_buffer_flush_mapped_range(struct pipe_screen *screen,
- struct pipe_buffer *buf,
+pipe_buffer_flush_mapped_range(struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
unsigned offset,
unsigned length)
{
- assert(offset < buf->size);
- assert(offset + length <= buf->size);
+ struct pipe_box box;
+ int transfer_offset;
+
assert(length);
- if(screen->buffer_flush_mapped_range)
- screen->buffer_flush_mapped_range(screen, buf, offset, length);
+ assert(transfer->box.x <= offset);
+ assert(offset + length <= transfer->box.x + transfer->box.width);
+
+ /* Match old screen->buffer_flush_mapped_range() behaviour, where
+ * offset parameter is relative to the start of the buffer, not the
+ * mapped range.
+ */
+ transfer_offset = offset - transfer->box.x;
+
+ u_box_1d(transfer_offset, length, &box);
+
+ pipe->transfer_flush_region(pipe, transfer, &box);
}
static INLINE void
-pipe_buffer_write(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned size,
+pipe_buffer_write(struct pipe_context *pipe,
+ struct pipe_resource *buf,
+ unsigned offset,
+ unsigned size,
const void *data)
{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD);
- assert(map);
- if(map) {
- memcpy((uint8_t *)map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, size);
- pipe_buffer_unmap(screen, buf);
- }
+ struct pipe_box box;
+
+ u_box_1d(offset, size, &box);
+
+ pipe->transfer_inline_write( pipe,
+ buf,
+ u_subresource(0,0),
+ PIPE_TRANSFER_WRITE,
+ &box,
+ data,
+ size,
+ 0);
}
/**
@@ -229,86 +264,87 @@ pipe_buffer_write(struct pipe_screen *screen,
* been written before.
*/
static INLINE void
-pipe_buffer_write_nooverlap(struct pipe_screen *screen,
- struct pipe_buffer *buf,
+pipe_buffer_write_nooverlap(struct pipe_context *pipe,
+ struct pipe_resource *buf,
unsigned offset, unsigned size,
const void *data)
{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
- assert(map);
- if(map) {
- memcpy((uint8_t *)map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, size);
- pipe_buffer_unmap(screen, buf);
- }
+ struct pipe_box box;
+
+ u_box_1d(offset, size, &box);
+
+ pipe->transfer_inline_write(pipe,
+ buf,
+ u_subresource(0,0),
+ (PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_NOOVERWRITE),
+ &box,
+ data,
+ 0, 0);
}
static INLINE void
-pipe_buffer_read(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned size,
+pipe_buffer_read(struct pipe_context *pipe,
+ struct pipe_resource *buf,
+ unsigned offset,
+ unsigned size,
void *data)
{
- void *map;
-
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
- assert(size);
-
- map = pipe_buffer_map_range(screen, buf, offset, size, PIPE_BUFFER_USAGE_CPU_READ);
- assert(map);
- if(map) {
- memcpy(data, (const uint8_t *)map + offset, size);
- pipe_buffer_unmap(screen, buf);
- }
+ struct pipe_transfer *src_transfer;
+ ubyte *map;
+
+ map = (ubyte *) pipe_buffer_map_range(pipe,
+ buf,
+ offset, size,
+ PIPE_TRANSFER_READ,
+ &src_transfer);
+
+ if (map)
+ memcpy(data, map + offset, size);
+
+ pipe_buffer_unmap(pipe, buf, src_transfer);
+}
+
+static INLINE struct pipe_transfer *
+pipe_get_transfer( struct pipe_context *context,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level,
+ unsigned zslice,
+ enum pipe_transfer_usage usage,
+ unsigned x, unsigned y,
+ unsigned w, unsigned h)
+{
+ struct pipe_box box;
+ u_box_2d_zslice( x, y, zslice, w, h, &box );
+ return context->get_transfer( context,
+ resource,
+ u_subresource(face, level),
+ usage,
+ &box );
}
static INLINE void *
pipe_transfer_map( struct pipe_context *context,
- struct pipe_transfer *transf )
+ struct pipe_transfer *transfer )
{
- return context->transfer_map(context, transf);
+ return context->transfer_map( context, transfer );
}
static INLINE void
pipe_transfer_unmap( struct pipe_context *context,
- struct pipe_transfer *transf )
+ struct pipe_transfer *transfer )
{
- context->transfer_unmap(context, transf);
+ context->transfer_unmap( context, transfer );
}
+
static INLINE void
-pipe_transfer_destroy( struct pipe_context *context,
- struct pipe_transfer *transfer )
+pipe_transfer_destroy( struct pipe_context *context,
+ struct pipe_transfer *transfer )
{
- context->tex_transfer_destroy(context, transfer);
+ context->transfer_destroy(context, transfer);
}
-static INLINE unsigned
-pipe_transfer_buffer_flags( struct pipe_transfer *transf )
-{
- switch (transf->usage & PIPE_TRANSFER_READ_WRITE) {
- case PIPE_TRANSFER_READ_WRITE:
- return PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE;
- case PIPE_TRANSFER_READ:
- return PIPE_BUFFER_USAGE_CPU_READ;
- case PIPE_TRANSFER_WRITE:
- return PIPE_BUFFER_USAGE_CPU_WRITE;
- default:
- debug_assert(0);
- return 0;
- }
-}
#ifdef __cplusplus
}
diff --git a/src/gallium/auxiliary/util/u_rect.c b/src/gallium/auxiliary/util/u_rect.c
index e73797f1b7..098cdfd58b 100644
--- a/src/gallium/auxiliary/util/u_rect.c
+++ b/src/gallium/auxiliary/util/u_rect.c
@@ -35,6 +35,7 @@
#include "pipe/p_context.h"
#include "pipe/p_screen.h"
#include "util/u_format.h"
+#include "util/u_inlines.h"
#include "util/u_rect.h"
@@ -181,21 +182,21 @@ util_surface_copy(struct pipe_context *pipe,
src_format = src->texture->format;
dst_format = dst->texture->format;
- src_trans = pipe->get_tex_transfer(pipe,
- src->texture,
- src->face,
- src->level,
- src->zslice,
- PIPE_TRANSFER_READ,
- src_x, src_y, w, h);
-
- dst_trans = pipe->get_tex_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
- PIPE_TRANSFER_WRITE,
- dst_x, dst_y, w, h);
+ src_trans = pipe_get_transfer(pipe,
+ src->texture,
+ src->face,
+ src->level,
+ src->zslice,
+ PIPE_TRANSFER_READ,
+ src_x, src_y, w, h);
+
+ dst_trans = pipe_get_transfer(pipe,
+ dst->texture,
+ dst->face,
+ dst->level,
+ dst->zslice,
+ PIPE_TRANSFER_WRITE,
+ dst_x, dst_y, w, h);
assert(util_format_get_blocksize(dst_format) == util_format_get_blocksize(src_format));
assert(util_format_get_blockwidth(dst_format) == util_format_get_blockwidth(src_format));
@@ -223,8 +224,8 @@ util_surface_copy(struct pipe_context *pipe,
pipe->transfer_unmap(pipe, src_trans);
pipe->transfer_unmap(pipe, dst_trans);
- pipe->tex_transfer_destroy(pipe, src_trans);
- pipe->tex_transfer_destroy(pipe, dst_trans);
+ pipe->transfer_destroy(pipe, src_trans);
+ pipe->transfer_destroy(pipe, dst_trans);
}
@@ -248,13 +249,13 @@ util_surface_fill(struct pipe_context *pipe,
assert(dst->texture);
if (!dst->texture)
return;
- dst_trans = pipe->get_tex_transfer(pipe,
- dst->texture,
- dst->face,
- dst->level,
- dst->zslice,
- PIPE_TRANSFER_WRITE,
- dstx, dsty, width, height);
+ dst_trans = pipe_get_transfer(pipe,
+ dst->texture,
+ dst->face,
+ dst->level,
+ dst->zslice,
+ PIPE_TRANSFER_WRITE,
+ dstx, dsty, width, height);
dst_map = pipe->transfer_map(pipe, dst_trans);
@@ -263,37 +264,38 @@ util_surface_fill(struct pipe_context *pipe,
if (dst_map) {
assert(dst_trans->stride > 0);
- switch (util_format_get_blocksize(dst_trans->texture->format)) {
+ switch (util_format_get_blocksize(dst->texture->format)) {
case 1:
case 2:
case 4:
- util_fill_rect(dst_map, dst_trans->texture->format, dst_trans->stride,
+ util_fill_rect(dst_map, dst->texture->format,
+ dst_trans->stride,
0, 0, width, height, value);
break;
case 8:
- {
- /* expand the 4-byte clear value to an 8-byte value */
- ushort *row = (ushort *) dst_map;
- ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
- ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
- ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
- ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
- unsigned i, j;
- val0 = (val0 << 8) | val0;
- val1 = (val1 << 8) | val1;
- val2 = (val2 << 8) | val2;
- val3 = (val3 << 8) | val3;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- row[j*4+0] = val0;
- row[j*4+1] = val1;
- row[j*4+2] = val2;
- row[j*4+3] = val3;
- }
- row += dst_trans->stride/2;
- }
- }
- break;
+ {
+ /* expand the 4-byte clear value to an 8-byte value */
+ ushort *row = (ushort *) dst_map;
+ ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
+ ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
+ ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
+ ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
+ unsigned i, j;
+ val0 = (val0 << 8) | val0;
+ val1 = (val1 << 8) | val1;
+ val2 = (val2 << 8) | val2;
+ val3 = (val3 << 8) | val3;
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++) {
+ row[j*4+0] = val0;
+ row[j*4+1] = val1;
+ row[j*4+2] = val2;
+ row[j*4+3] = val3;
+ }
+ row += dst_trans->stride/2;
+ }
+ }
+ break;
default:
assert(0);
break;
@@ -301,5 +303,5 @@ util_surface_fill(struct pipe_context *pipe,
}
pipe->transfer_unmap(pipe, dst_trans);
- pipe->tex_transfer_destroy(pipe, dst_trans);
+ pipe->transfer_destroy(pipe, dst_trans);
}
diff --git a/src/gallium/auxiliary/util/u_resource.c b/src/gallium/auxiliary/util/u_resource.c
new file mode 100644
index 0000000000..c37a68bc42
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_resource.c
@@ -0,0 +1,97 @@
+
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_transfer.h"
+
+static INLINE struct u_resource *
+u_resource( struct pipe_resource *res )
+{
+ return (struct u_resource *)res;
+}
+
+boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->resource_get_handle(screen, resource, handle);
+}
+
+void u_resource_destroy_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource)
+{
+ struct u_resource *ur = u_resource(resource);
+ ur->vtbl->resource_destroy(screen, resource);
+}
+
+unsigned u_is_resource_referenced_vtbl( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->is_resource_referenced(pipe, resource, face, level);
+}
+
+struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ enum pipe_transfer_usage usage,
+ const struct pipe_box *box)
+{
+ struct u_resource *ur = u_resource(resource);
+ return ur->vtbl->get_transfer(context, resource, sr, usage, box);
+}
+
+void u_transfer_destroy_vtbl(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_destroy(pipe, transfer);
+}
+
+void *u_transfer_map_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ return ur->vtbl->transfer_map(pipe, transfer);
+}
+
+void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_flush_region(pipe, transfer, box);
+}
+
+void u_transfer_unmap_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct u_resource *ur = u_resource(transfer->resource);
+ ur->vtbl->transfer_unmap(pipe, transfer);
+}
+
+void u_transfer_inline_write_vtbl( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride)
+{
+ struct u_resource *ur = u_resource(resource);
+ ur->vtbl->transfer_inline_write(pipe,
+ resource,
+ sr,
+ usage,
+ box,
+ data,
+ stride,
+ slice_stride);
+}
+
+
+
+
diff --git a/src/gallium/auxiliary/util/u_sampler.c b/src/gallium/auxiliary/util/u_sampler.c
index 4d8f861ce4..e77f562ea2 100644
--- a/src/gallium/auxiliary/util/u_sampler.c
+++ b/src/gallium/auxiliary/util/u_sampler.c
@@ -32,7 +32,7 @@
static void
default_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format,
unsigned expand_green_blue)
{
@@ -77,7 +77,7 @@ default_template(struct pipe_sampler_view *view,
void
u_sampler_view_default_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format)
{
/* Expand to (0, 0, 0, 1) */
@@ -89,7 +89,7 @@ u_sampler_view_default_template(struct pipe_sampler_view *view,
void
u_sampler_view_default_dx9_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format)
{
/* Expand to (1, 1, 1, 1) */
diff --git a/src/gallium/auxiliary/util/u_sampler.h b/src/gallium/auxiliary/util/u_sampler.h
index bdd061c851..f3dad7417e 100644
--- a/src/gallium/auxiliary/util/u_sampler.h
+++ b/src/gallium/auxiliary/util/u_sampler.h
@@ -41,12 +41,12 @@ extern "C" {
void
u_sampler_view_default_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format);
void
u_sampler_view_default_dx9_template(struct pipe_sampler_view *view,
- const struct pipe_texture *texture,
+ const struct pipe_resource *texture,
enum pipe_format format);
diff --git a/src/gallium/auxiliary/util/u_simple_screen.c b/src/gallium/auxiliary/util/u_simple_screen.c
deleted file mode 100644
index 9203cb6580..0000000000
--- a/src/gallium/auxiliary/util/u_simple_screen.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "u_simple_screen.h"
-
-#include "pipe/p_screen.h"
-#include "pipe/p_state.h"
-#include "util/u_simple_screen.h"
-
-
-static struct pipe_buffer *
-pass_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct pipe_buffer *buffer =
- screen->winsys->buffer_create(screen->winsys, alignment, usage, size);
-
- buffer->screen = screen;
-
- return buffer;
-}
-
-static struct pipe_buffer *
-pass_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct pipe_buffer *buffer =
- screen->winsys->user_buffer_create(screen->winsys, ptr, bytes);
-
- buffer->screen = screen;
-
- return buffer;
-}
-
-
-
-static void *
-pass_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned usage)
-{
- return screen->winsys->buffer_map(screen->winsys, buf, usage);
-}
-
-static void
-pass_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
-{
- screen->winsys->buffer_unmap(screen->winsys, buf);
-}
-
-static void
-pass_buffer_destroy(struct pipe_buffer *buf)
-{
- buf->screen->winsys->buffer_destroy(buf);
-}
-
-
-static void
-pass_flush_frontbuffer(struct pipe_screen *screen,
- struct pipe_surface *surf,
- void *context_private)
-{
- screen->winsys->flush_frontbuffer(screen->winsys, surf, context_private);
-}
-
-static void
-pass_fence_reference(struct pipe_screen *screen,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
- screen->winsys->fence_reference(screen->winsys, ptr, fence);
-}
-
-static int
-pass_fence_signalled(struct pipe_screen *screen,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return screen->winsys->fence_signalled(screen->winsys, fence, flag);
-}
-
-static int
-pass_fence_finish(struct pipe_screen *screen,
- struct pipe_fence_handle *fence,
- unsigned flag)
-{
- return screen->winsys->fence_finish(screen->winsys, fence, flag);
-}
-
-void
-u_simple_screen_init(struct pipe_screen *screen)
-{
- screen->buffer_create = pass_buffer_create;
- screen->user_buffer_create = pass_user_buffer_create;
-
- screen->buffer_map = pass_buffer_map;
- screen->buffer_unmap = pass_buffer_unmap;
- screen->buffer_destroy = pass_buffer_destroy;
- screen->flush_frontbuffer = pass_flush_frontbuffer;
- screen->fence_reference = pass_fence_reference;
- screen->fence_signalled = pass_fence_signalled;
- screen->fence_finish = pass_fence_finish;
-}
-
-const char *
-u_simple_screen_winsys_name(struct pipe_screen *screen)
-{
- return screen->winsys->get_name(screen->winsys);
-}
diff --git a/src/gallium/auxiliary/util/u_simple_screen.h b/src/gallium/auxiliary/util/u_simple_screen.h
index bb3f5ba102..de6325fe2a 100644
--- a/src/gallium/auxiliary/util/u_simple_screen.h
+++ b/src/gallium/auxiliary/util/u_simple_screen.h
@@ -33,7 +33,7 @@
struct pipe_screen;
struct pipe_fence_handle;
struct pipe_surface;
-struct pipe_buffer;
+struct pipe_resource;
/**
* Gallium3D drivers are (meant to be!) independent of both GL and the
@@ -73,14 +73,13 @@ struct pipe_winsys
* window systems must then implement that interface (rather than the
* other way around...).
*
- * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
- * usage argument is only an optimization hint, not a guarantee, therefore
- * proper behavior must be observed in all circumstances.
+ * usage is a bitmask of PIPE_BIND_*.
+ * All possible usages must be present.
*
* alignment indicates the client's alignment requirements, eg for
* SSE instructions.
*/
- struct pipe_buffer *(*buffer_create)( struct pipe_winsys *ws,
+ struct pipe_resource *(*buffer_create)( struct pipe_winsys *ws,
unsigned alignment,
unsigned usage,
unsigned size );
@@ -106,7 +105,7 @@ struct pipe_winsys
* Note that ptr may be accessed at any time upto the time when the
* buffer is destroyed, so the data must not be freed before then.
*/
- struct pipe_buffer *(*user_buffer_create)(struct pipe_winsys *ws,
+ struct pipe_resource *(*user_buffer_create)(struct pipe_winsys *ws,
void *ptr,
unsigned bytes);
@@ -117,11 +116,11 @@ struct pipe_winsys
* display targets) must be allocated with special characteristics, memory
* pools, or obtained directly from the windowing system.
*
- * This callback is invoked by the pipe_screenwhen creating a texture marked
- * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
+ * This callback is invoked by the pipe_screen when creating a texture marked
+ * with the PIPE_BIND_DISPLAY_TARGET flag to get the underlying
* buffer storage.
*/
- struct pipe_buffer *(*surface_buffer_create)(struct pipe_winsys *ws,
+ struct pipe_resource *(*surface_buffer_create)(struct pipe_winsys *ws,
unsigned width, unsigned height,
enum pipe_format format,
unsigned usage,
@@ -134,13 +133,13 @@ struct pipe_winsys
* flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
*/
void *(*buffer_map)( struct pipe_winsys *ws,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned usage );
void (*buffer_unmap)( struct pipe_winsys *ws,
- struct pipe_buffer *buf );
+ struct pipe_resource *buf );
- void (*buffer_destroy)( struct pipe_buffer *buf );
+ void (*buffer_destroy)( struct pipe_resource *buf );
/** Set ptr = fence, with reference counting */
diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c
index 33306bbc2a..42440d0d67 100644
--- a/src/gallium/auxiliary/util/u_surface.c
+++ b/src/gallium/auxiliary/util/u_surface.c
@@ -50,7 +50,8 @@
boolean
util_create_rgba_surface(struct pipe_screen *screen,
uint width, uint height,
- struct pipe_texture **textureOut,
+ uint bind,
+ struct pipe_resource **textureOut,
struct pipe_surface **surfaceOut)
{
static const enum pipe_format rgbaFormats[] = {
@@ -60,15 +61,14 @@ util_create_rgba_surface(struct pipe_screen *screen,
PIPE_FORMAT_NONE
};
const uint target = PIPE_TEXTURE_2D;
- const uint usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
enum pipe_format format = PIPE_FORMAT_NONE;
- struct pipe_texture templ;
+ struct pipe_resource templ;
uint i;
/* Choose surface format */
for (i = 0; rgbaFormats[i]; i++) {
if (screen->is_format_supported(screen, rgbaFormats[i],
- target, usage, 0)) {
+ target, bind, 0)) {
format = rgbaFormats[i];
break;
}
@@ -84,16 +84,19 @@ util_create_rgba_surface(struct pipe_screen *screen,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- templ.tex_usage = usage;
+ templ.bind = bind;
- *textureOut = screen->texture_create(screen, &templ);
+ *textureOut = screen->resource_create(screen, &templ);
if (!*textureOut)
return FALSE;
/* create surface / view into texture */
- *surfaceOut = screen->get_tex_surface(screen, *textureOut, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+ *surfaceOut = screen->get_tex_surface(screen,
+ *textureOut,
+ 0, 0, 0,
+ bind);
if (!*surfaceOut) {
- pipe_texture_reference(textureOut, NULL);
+ pipe_resource_reference(textureOut, NULL);
return FALSE;
}
@@ -105,11 +108,11 @@ util_create_rgba_surface(struct pipe_screen *screen,
* Release the surface and texture from util_create_rgba_surface().
*/
void
-util_destroy_rgba_surface(struct pipe_texture *texture,
+util_destroy_rgba_surface(struct pipe_resource *texture,
struct pipe_surface *surface)
{
pipe_surface_reference(&surface, NULL);
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
}
diff --git a/src/gallium/auxiliary/util/u_surface.h b/src/gallium/auxiliary/util/u_surface.h
index 3c60df2c3e..119fcd4ce8 100644
--- a/src/gallium/auxiliary/util/u_surface.h
+++ b/src/gallium/auxiliary/util/u_surface.h
@@ -52,13 +52,13 @@ util_same_surface(const struct pipe_surface *s1, const struct pipe_surface *s2)
extern boolean
util_create_rgba_surface(struct pipe_screen *screen,
- uint width, uint height,
- struct pipe_texture **textureOut,
+ uint width, uint height, uint bind,
+ struct pipe_resource **textureOut,
struct pipe_surface **surfaceOut);
extern void
-util_destroy_rgba_surface(struct pipe_texture *texture,
+util_destroy_rgba_surface(struct pipe_resource *texture,
struct pipe_surface *surface);
diff --git a/src/gallium/auxiliary/util/u_tile.c b/src/gallium/auxiliary/util/u_tile.c
index 88a1424dff..fe327c302b 100644
--- a/src/gallium/auxiliary/util/u_tile.c
+++ b/src/gallium/auxiliary/util/u_tile.c
@@ -53,9 +53,9 @@ pipe_get_tile_raw(struct pipe_context *pipe,
const void *src;
if (dst_stride == 0)
- dst_stride = util_format_get_stride(pt->texture->format, w);
+ dst_stride = util_format_get_stride(pt->resource->format, w);
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
src = pipe->transfer_map(pipe, pt);
@@ -63,7 +63,7 @@ pipe_get_tile_raw(struct pipe_context *pipe,
if(!src)
return;
- util_copy_rect(dst, pt->texture->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
+ util_copy_rect(dst, pt->resource->format, dst_stride, 0, 0, w, h, src, pt->stride, x, y);
pipe->transfer_unmap(pipe, pt);
}
@@ -79,12 +79,12 @@ pipe_put_tile_raw(struct pipe_context *pipe,
const void *src, int src_stride)
{
void *dst;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
if (src_stride == 0)
src_stride = util_format_get_stride(format, w);
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
dst = pipe->transfer_map(pipe, pt);
@@ -285,9 +285,9 @@ pipe_get_tile_rgba(struct pipe_context *pipe,
{
unsigned dst_stride = w * 4;
void *packed;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
@@ -325,7 +325,7 @@ pipe_get_tile_swizzle(struct pipe_context *pipe,
uint iy;
float rgba01[6];
- if (pipe_clip_tile(x, y, &w, &h, pt)) {
+ if (u_clip_tile(x, y, &w, &h, &pt->box)) {
return;
}
@@ -383,9 +383,9 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
{
unsigned src_stride = w * 4;
void *packed;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
packed = MALLOC(util_format_get_nblocks(format, w, h) * util_format_get_blocksize(format));
@@ -434,9 +434,9 @@ pipe_get_tile_z(struct pipe_context *pipe,
ubyte *map;
uint *pDest = z;
uint i, j;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
map = (ubyte *)pipe->transfer_map(pipe, pt);
@@ -519,9 +519,9 @@ pipe_put_tile_z(struct pipe_context *pipe,
const uint *ptrc = zSrc;
ubyte *map;
uint i, j;
- enum pipe_format format = pt->texture->format;
+ enum pipe_format format = pt->resource->format;
- if (pipe_clip_tile(x, y, &w, &h, pt))
+ if (u_clip_tile(x, y, &w, &h, &pt->box))
return;
map = (ubyte *)pipe->transfer_map(pipe, pt);
@@ -544,7 +544,7 @@ pipe_put_tile_z(struct pipe_context *pipe,
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
{
uint *pDest = (uint *) (map + y * pt->stride + x*4);
- assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
+ //assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 24-bit Z, preserve stencil */
@@ -571,7 +571,7 @@ pipe_put_tile_z(struct pipe_context *pipe,
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
{
uint *pDest = (uint *) (map + y * pt->stride + x*4);
- assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
+ //assert((pt->usage & PIPE_TRANSFER_READ_WRITE) == PIPE_TRANSFER_READ_WRITE);
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
/* convert 32-bit Z to 24-bit Z, preserve stencil */
diff --git a/src/gallium/auxiliary/util/u_tile.h b/src/gallium/auxiliary/util/u_tile.h
index 1d8ce7d8cb..986eee0743 100644
--- a/src/gallium/auxiliary/util/u_tile.h
+++ b/src/gallium/auxiliary/util/u_tile.h
@@ -32,22 +32,24 @@
struct pipe_transfer;
-
/**
* Clip tile against transfer dims.
+ *
+ * XXX: this only clips width and height!
+ *
* \return TRUE if tile is totally clipped, FALSE otherwise
*/
static INLINE boolean
-pipe_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_transfer *pt)
+u_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box)
{
- if (x >= pt->width)
+ if (x >= box->width)
return TRUE;
- if (y >= pt->height)
+ if (y >= box->height)
return TRUE;
- if (x + *w > pt->width)
- *w = pt->width - x;
- if (y + *h > pt->height)
- *h = pt->height - y;
+ if (x + *w > box->width)
+ *w = box->width - x;
+ if (y + *h > box->height)
+ *h = box->height - y;
return FALSE;
}
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.c b/src/gallium/auxiliary/util/u_timed_winsys.c
deleted file mode 100644
index d88298bc14..0000000000
--- a/src/gallium/auxiliary/util/u_timed_winsys.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include "pipe/p_state.h"
-#include "util/u_simple_screen.h"
-#include "u_timed_winsys.h"
-#include "util/u_memory.h"
-#include "os/os_time.h"
-
-
-struct timed_winsys {
- struct pipe_winsys base;
- struct pipe_winsys *backend;
- uint64_t last_dump;
- struct {
- const char *name_key;
- double total;
- unsigned calls;
- } funcs[13];
-};
-
-
-static struct timed_winsys *timed_winsys( struct pipe_winsys *winsys )
-{
- return (struct timed_winsys *)winsys;
-}
-
-
-static void time_display( struct pipe_winsys *winsys )
-{
- struct timed_winsys *tws = timed_winsys(winsys);
- unsigned i;
- double overall = 0;
-
- for (i = 0; i < Elements(tws->funcs); i++) {
- if (tws->funcs[i].name_key) {
- debug_printf("*** %-25s %5.3fms (%d calls, avg %.3fms)\n",
- tws->funcs[i].name_key,
- tws->funcs[i].total,
- tws->funcs[i].calls,
- tws->funcs[i].total / tws->funcs[i].calls);
- overall += tws->funcs[i].total;
- tws->funcs[i].calls = 0;
- tws->funcs[i].total = 0;
- }
- }
-
- debug_printf("*** %-25s %5.3fms\n",
- "OVERALL WINSYS",
- overall);
-}
-
-static void time_finish( struct pipe_winsys *winsys,
- long long startval,
- unsigned idx,
- const char *name )
-{
- struct timed_winsys *tws = timed_winsys(winsys);
- int64_t endval = os_time_get();
- double elapsed = (endval - startval)/1000.0;
-
- if (endval - startval > 1000LL)
- debug_printf("*** %s %.3f\n", name, elapsed );
-
- assert( tws->funcs[idx].name_key == name ||
- tws->funcs[idx].name_key == NULL);
-
- tws->funcs[idx].name_key = name;
- tws->funcs[idx].total += elapsed;
- tws->funcs[idx].calls++;
-
- if (endval - tws->last_dump > 10LL * 1000LL * 1000LL) {
- time_display( winsys );
- tws->last_dump = endval;
- }
-}
-
-
-/* Pipe has no concept of pools, but the psb driver passes a flag that
- * can be mapped onto pools in the backend.
- */
-static struct pipe_buffer *
-timed_buffer_create(struct pipe_winsys *winsys,
- unsigned alignment,
- unsigned usage,
- unsigned size )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- struct pipe_buffer *buf =
- backend->buffer_create( backend, alignment, usage, size );
-
- time_finish(winsys, start, 0, __FUNCTION__);
-
- return buf;
-}
-
-
-
-
-static struct pipe_buffer *
-timed_user_buffer_create(struct pipe_winsys *winsys,
- void *data,
- unsigned bytes)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- struct pipe_buffer *buf = backend->user_buffer_create( backend, data, bytes );
-
- time_finish(winsys, start, 1, __FUNCTION__);
-
- return buf;
-}
-
-
-static void *
-timed_buffer_map(struct pipe_winsys *winsys,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- void *map = backend->buffer_map( backend, buf, flags );
-
- time_finish(winsys, start, 2, __FUNCTION__);
-
- return map;
-}
-
-
-static void
-timed_buffer_unmap(struct pipe_winsys *winsys,
- struct pipe_buffer *buf)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->buffer_unmap( backend, buf );
-
- time_finish(winsys, start, 3, __FUNCTION__);
-}
-
-
-static void
-timed_buffer_destroy(struct pipe_buffer *buf)
-{
- struct pipe_winsys *winsys = buf->screen->winsys;
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->buffer_destroy( buf );
-
- time_finish(winsys, start, 4, __FUNCTION__);
-}
-
-
-static void
-timed_flush_frontbuffer( struct pipe_winsys *winsys,
- struct pipe_surface *surf,
- void *context_private)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->flush_frontbuffer( backend, surf, context_private );
-
- time_finish(winsys, start, 5, __FUNCTION__);
-}
-
-
-
-
-static struct pipe_buffer *
-timed_surface_buffer_create(struct pipe_winsys *winsys,
- unsigned width, unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- struct pipe_buffer *ret = backend->surface_buffer_create( backend, width, height,
- format, usage, tex_usage, stride );
-
- time_finish(winsys, start, 7, __FUNCTION__);
-
- return ret;
-}
-
-
-static const char *
-timed_get_name( struct pipe_winsys *winsys )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- const char *ret = backend->get_name( backend );
-
- time_finish(winsys, start, 9, __FUNCTION__);
-
- return ret;
-}
-
-static void
-timed_fence_reference(struct pipe_winsys *winsys,
- struct pipe_fence_handle **ptr,
- struct pipe_fence_handle *fence)
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- backend->fence_reference( backend, ptr, fence );
-
- time_finish(winsys, start, 10, __FUNCTION__);
-}
-
-
-static int
-timed_fence_signalled( struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- int ret = backend->fence_signalled( backend, fence, flag );
-
- time_finish(winsys, start, 11, __FUNCTION__);
-
- return ret;
-}
-
-static int
-timed_fence_finish( struct pipe_winsys *winsys,
- struct pipe_fence_handle *fence,
- unsigned flag )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- int64_t start = os_time_get();
-
- int ret = backend->fence_finish( backend, fence, flag );
-
- time_finish(winsys, start, 12, __FUNCTION__);
-
- return ret;
-}
-
-static void
-timed_winsys_destroy( struct pipe_winsys *winsys )
-{
- struct pipe_winsys *backend = timed_winsys(winsys)->backend;
- backend->destroy( backend );
- FREE(winsys);
-}
-
-
-
-struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend )
-{
- struct timed_winsys *ws = CALLOC_STRUCT(timed_winsys);
-
- ws->base.user_buffer_create = timed_user_buffer_create;
- ws->base.buffer_map = timed_buffer_map;
- ws->base.buffer_unmap = timed_buffer_unmap;
- ws->base.buffer_destroy = timed_buffer_destroy;
- ws->base.buffer_create = timed_buffer_create;
- ws->base.surface_buffer_create = timed_surface_buffer_create;
- ws->base.flush_frontbuffer = timed_flush_frontbuffer;
- ws->base.get_name = timed_get_name;
- ws->base.fence_reference = timed_fence_reference;
- ws->base.fence_signalled = timed_fence_signalled;
- ws->base.fence_finish = timed_fence_finish;
- ws->base.destroy = timed_winsys_destroy;
-
- ws->backend = backend;
-
- return &ws->base;
-}
-
diff --git a/src/gallium/auxiliary/util/u_timed_winsys.h b/src/gallium/auxiliary/util/u_timed_winsys.h
deleted file mode 100644
index 542365112d..0000000000
--- a/src/gallium/auxiliary/util/u_timed_winsys.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
- * USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-
-#ifndef U_TIMED_WINSYS_H
-#define U_TIMED_WINSYS_H
-
-
-struct pipe_winsys;
-struct pipe_winsys *u_timed_winsys_create( struct pipe_winsys *backend );
-
-
-#endif
diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c
new file mode 100644
index 0000000000..bedace3b1d
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_transfer.c
@@ -0,0 +1,110 @@
+#include "pipe/p_context.h"
+#include "util/u_rect.h"
+#include "util/u_inlines.h"
+#include "util/u_transfer.h"
+#include "util/u_memory.h"
+
+/* One-shot transfer operation with data supplied in a user
+ * pointer. XXX: strides??
+ */
+void u_default_transfer_inline_write( struct pipe_context *pipe,
+ 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_transfer *transfer = NULL;
+ uint8_t *map = NULL;
+
+ transfer = pipe->get_transfer(pipe,
+ resource,
+ sr,
+ usage,
+ box );
+ if (transfer == NULL)
+ goto out;
+
+ map = pipe_transfer_map(pipe, transfer);
+ if (map == NULL)
+ goto out;
+
+ assert(box->depth == 1); /* XXX: fix me */
+
+ util_copy_rect(map,
+ resource->format,
+ transfer->stride, /* bytes? */
+ 0, 0,
+ box->width,
+ box->height,
+ data,
+ box->width, /* bytes? texels? */
+ 0, 0);
+
+out:
+ if (map)
+ pipe_transfer_unmap(pipe, transfer);
+
+ if (transfer)
+ pipe_transfer_destroy(pipe, transfer);
+}
+
+
+boolean u_default_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ return FALSE;
+}
+
+
+
+void u_default_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ /* This is a no-op implementation, nothing to do.
+ */
+}
+
+unsigned u_default_is_resource_referenced( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level)
+{
+ return 0;
+}
+
+struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
+{
+ struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
+ if (transfer == NULL)
+ return NULL;
+
+ transfer->resource = resource;
+ transfer->sr = sr;
+ transfer->usage = usage;
+ transfer->box = *box;
+
+ /* Note strides are zero, this is ok for buffers, but not for
+ * textures 2d & higher at least.
+ */
+ return transfer;
+}
+
+void u_default_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+}
+
+void u_default_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ FREE(transfer);
+}
+
diff --git a/src/gallium/auxiliary/util/u_transfer.h b/src/gallium/auxiliary/util/u_transfer.h
new file mode 100644
index 0000000000..eb07945d15
--- /dev/null
+++ b/src/gallium/auxiliary/util/u_transfer.h
@@ -0,0 +1,145 @@
+
+#ifndef U_TRANSFER_H
+#define U_TRANSFER_H
+
+/* Fallback implementations for inline read/writes which just go back
+ * to the regular transfer behaviour.
+ */
+#include "pipe/p_state.h"
+
+struct pipe_context;
+
+boolean u_default_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle);
+
+void u_default_transfer_inline_write( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride);
+
+void u_default_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box);
+
+unsigned u_default_is_resource_referenced( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level);
+
+struct pipe_transfer * u_default_get_transfer(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box);
+
+void u_default_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer );
+
+void u_default_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer);
+
+
+
+/* Useful helper to allow >1 implementation of resource functionality
+ * to exist in a single driver. This is intended to be transitionary!
+ */
+struct u_resource_vtbl {
+
+ boolean (*resource_get_handle)(struct pipe_screen *,
+ struct pipe_resource *tex,
+ struct winsys_handle *handle);
+
+ void (*resource_destroy)(struct pipe_screen *,
+ struct pipe_resource *pt);
+
+ unsigned (*is_resource_referenced)(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ unsigned face, unsigned level);
+
+ struct pipe_transfer *(*get_transfer)(struct pipe_context *,
+ struct pipe_resource *resource,
+ struct pipe_subresource,
+ unsigned usage,
+ const struct pipe_box *);
+
+ void (*transfer_destroy)(struct pipe_context *,
+ struct pipe_transfer *);
+
+ void *(*transfer_map)( struct pipe_context *,
+ struct pipe_transfer *transfer );
+
+ void (*transfer_flush_region)( struct pipe_context *,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *);
+
+ void (*transfer_unmap)( struct pipe_context *,
+ struct pipe_transfer *transfer );
+
+ void (*transfer_inline_write)( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride);
+};
+
+
+struct u_resource {
+ struct pipe_resource b;
+ struct u_resource_vtbl *vtbl;
+};
+
+
+boolean u_resource_get_handle_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle);
+
+void u_resource_destroy_vtbl(struct pipe_screen *screen,
+ struct pipe_resource *resource);
+
+unsigned u_is_resource_referenced_vtbl( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level);
+
+struct pipe_transfer *u_get_transfer_vtbl(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box);
+
+void u_transfer_destroy_vtbl(struct pipe_context *pipe,
+ struct pipe_transfer *transfer);
+
+void *u_transfer_map_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer );
+
+void u_transfer_flush_region_vtbl( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box);
+
+void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
+ struct pipe_transfer *transfer );
+
+void u_transfer_inline_write_vtbl( 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);
+
+
+
+
+
+
+
+
+#endif
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.c b/src/gallium/auxiliary/util/u_upload_mgr.c
index 012b2ae233..75d44432d9 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.c
+++ b/src/gallium/auxiliary/util/u_upload_mgr.c
@@ -31,7 +31,7 @@
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
-#include "pipe/p_screen.h"
+#include "pipe/p_context.h"
#include "util/u_memory.h"
#include "util/u_math.h"
@@ -39,7 +39,7 @@
struct u_upload_mgr {
- struct pipe_screen *screen;
+ struct pipe_context *pipe;
unsigned default_size;
unsigned alignment;
@@ -47,21 +47,21 @@ struct u_upload_mgr {
/* The active buffer:
*/
- struct pipe_buffer *buffer;
+ struct pipe_resource *buffer;
unsigned size;
unsigned offset;
};
-struct u_upload_mgr *u_upload_create( struct pipe_screen *screen,
+struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
unsigned default_size,
unsigned alignment,
unsigned usage )
{
struct u_upload_mgr *upload = CALLOC_STRUCT( u_upload_mgr );
+ upload->pipe = pipe;
upload->default_size = default_size;
- upload->screen = screen;
upload->alignment = alignment;
upload->usage = usage;
upload->buffer = NULL;
@@ -69,31 +69,44 @@ struct u_upload_mgr *u_upload_create( struct pipe_screen *screen,
return upload;
}
-
+/* Slightly specialized version of buffer_write designed to maximize
+ * chances of the driver consolidating successive writes into a single
+ * upload.
+ *
+ * dirty_size may be slightly greater than size to cope with
+ * alignment. We don't want to leave holes between succesively mapped
+ * regions as that may prevent the driver from consolidating uploads.
+ *
+ * Note that the 'data' pointer has probably come from the application
+ * and we cannot read even a byte past its end without risking
+ * segfaults, or at least complaints from valgrind..
+ */
static INLINE enum pipe_error
-my_buffer_write(struct pipe_screen *screen,
- struct pipe_buffer *buf,
+my_buffer_write(struct pipe_context *pipe,
+ struct pipe_resource *buf,
unsigned offset, unsigned size, unsigned dirty_size,
const void *data)
{
+ struct pipe_transfer *transfer = NULL;
uint8_t *map;
- assert(offset < buf->size);
- assert(offset + size <= buf->size);
+ assert(offset < buf->width0);
+ assert(offset + size <= buf->width0);
assert(dirty_size >= size);
assert(size);
- map = pipe_buffer_map_range(screen, buf, offset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
+ map = pipe_buffer_map_range(pipe, buf, offset, dirty_size,
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_FLUSH_EXPLICIT |
+ PIPE_TRANSFER_DISCARD |
+ PIPE_TRANSFER_UNSYNCHRONIZED,
+ &transfer);
if (map == NULL)
return PIPE_ERROR_OUT_OF_MEMORY;
memcpy(map + offset, data, size);
- pipe_buffer_flush_mapped_range(screen, buf, offset, dirty_size);
- pipe_buffer_unmap(screen, buf);
+ pipe_buffer_flush_mapped_range(pipe, transfer, offset, dirty_size);
+ pipe_buffer_unmap(pipe, buf, transfer);
return PIPE_OK;
}
@@ -109,7 +122,7 @@ my_buffer_write(struct pipe_screen *screen,
*/
void u_upload_flush( struct u_upload_mgr *upload )
{
- pipe_buffer_reference( &upload->buffer, NULL );
+ pipe_resource_reference( &upload->buffer, NULL );
upload->size = 0;
}
@@ -135,9 +148,8 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
*/
size = align(MAX2(upload->default_size, min_size), 4096);
- upload->buffer = pipe_buffer_create( upload->screen,
- upload->alignment,
- upload->usage | PIPE_BUFFER_USAGE_CPU_WRITE,
+ upload->buffer = pipe_buffer_create( upload->pipe->screen,
+ upload->usage,
size );
if (upload->buffer == NULL)
goto fail;
@@ -149,7 +161,7 @@ u_upload_alloc_buffer( struct u_upload_mgr *upload,
fail:
if (upload->buffer)
- pipe_buffer_reference( &upload->buffer, NULL );
+ pipe_resource_reference( &upload->buffer, NULL );
return PIPE_ERROR_OUT_OF_MEMORY;
}
@@ -159,7 +171,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
unsigned size,
const void *data,
unsigned *out_offset,
- struct pipe_buffer **outbuf )
+ struct pipe_resource **outbuf )
{
unsigned alloc_size = align( size, upload->alignment );
enum pipe_error ret = PIPE_OK;
@@ -172,7 +184,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
/* Copy the data, using map_range if available:
*/
- ret = my_buffer_write( upload->screen,
+ ret = my_buffer_write( upload->pipe,
upload->buffer,
upload->offset,
size,
@@ -183,7 +195,7 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
/* Emit the return values:
*/
- pipe_buffer_reference( outbuf, upload->buffer );
+ pipe_resource_reference( outbuf, upload->buffer );
*out_offset = upload->offset;
upload->offset += alloc_size;
return PIPE_OK;
@@ -198,15 +210,18 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
unsigned offset,
unsigned size,
- struct pipe_buffer *inbuf,
+ struct pipe_resource *inbuf,
unsigned *out_offset,
- struct pipe_buffer **outbuf )
+ struct pipe_resource **outbuf )
{
enum pipe_error ret = PIPE_OK;
+ struct pipe_transfer *transfer = NULL;
const char *map = NULL;
- map = (const char *)pipe_buffer_map(
- upload->screen, inbuf, PIPE_BUFFER_USAGE_CPU_READ );
+ map = (const char *)pipe_buffer_map(upload->pipe,
+ inbuf,
+ PIPE_TRANSFER_READ,
+ &transfer);
if (map == NULL) {
ret = PIPE_ERROR_OUT_OF_MEMORY;
@@ -226,7 +241,7 @@ enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
done:
if (map)
- pipe_buffer_unmap( upload->screen, inbuf );
+ pipe_buffer_unmap( upload->pipe, inbuf, transfer );
return ret;
}
diff --git a/src/gallium/auxiliary/util/u_upload_mgr.h b/src/gallium/auxiliary/util/u_upload_mgr.h
index e158bed9d0..a124924fc8 100644
--- a/src/gallium/auxiliary/util/u_upload_mgr.h
+++ b/src/gallium/auxiliary/util/u_upload_mgr.h
@@ -35,11 +35,11 @@
#include "pipe/p_defines.h"
struct pipe_screen;
-struct pipe_buffer;
+struct pipe_resource;
struct u_upload_mgr;
-struct u_upload_mgr *u_upload_create( struct pipe_screen *screen,
+struct u_upload_mgr *u_upload_create( struct pipe_context *pipe,
unsigned default_size,
unsigned alignment,
unsigned usage );
@@ -61,15 +61,15 @@ enum pipe_error u_upload_data( struct u_upload_mgr *upload,
unsigned size,
const void *data,
unsigned *out_offset,
- struct pipe_buffer **outbuf );
+ struct pipe_resource **outbuf );
enum pipe_error u_upload_buffer( struct u_upload_mgr *upload,
unsigned offset,
unsigned size,
- struct pipe_buffer *inbuf,
+ struct pipe_resource *inbuf,
unsigned *out_offset,
- struct pipe_buffer **outbuf );
+ struct pipe_resource **outbuf );
diff --git a/src/gallium/auxiliary/vl/vl_bitstream_parser.c b/src/gallium/auxiliary/vl/vl_bitstream_parser.c
deleted file mode 100644
index 3193ea5f41..0000000000
--- a/src/gallium/auxiliary/vl/vl_bitstream_parser.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_bitstream_parser.h"
-#include <assert.h>
-#include <limits.h>
-#include <util/u_memory.h>
-
-static unsigned
-grab_bits(unsigned cursor, unsigned how_many_bits, unsigned bitstream_elt)
-{
- unsigned excess_bits = sizeof(unsigned) * CHAR_BIT - how_many_bits - cursor;
-
- assert(cursor < sizeof(unsigned) * CHAR_BIT);
- assert(how_many_bits > 0 && how_many_bits <= sizeof(unsigned) * CHAR_BIT);
- assert(cursor + how_many_bits <= sizeof(unsigned) * CHAR_BIT);
-
- return (bitstream_elt << excess_bits) >> (excess_bits + cursor);
-}
-
-static unsigned
-show_bits(unsigned cursor, unsigned how_many_bits, const unsigned *bitstream)
-{
- unsigned cur_int = cursor / (sizeof(unsigned) * CHAR_BIT);
- unsigned cur_bit = cursor % (sizeof(unsigned) * CHAR_BIT);
-
- assert(bitstream);
-
- if (cur_bit + how_many_bits > sizeof(unsigned) * CHAR_BIT) {
- unsigned lower = grab_bits(cur_bit, sizeof(unsigned) * CHAR_BIT - cur_bit,
- bitstream[cur_int]);
- unsigned upper = grab_bits(0, cur_bit + how_many_bits - sizeof(unsigned) * CHAR_BIT,
- bitstream[cur_int + 1]);
- return lower | upper << (sizeof(unsigned) * CHAR_BIT - cur_bit);
- }
- else
- return grab_bits(cur_bit, how_many_bits, bitstream[cur_int]);
-}
-
-bool vl_bitstream_parser_init(struct vl_bitstream_parser *parser,
- unsigned num_bitstreams,
- const void **bitstreams,
- const unsigned *sizes)
-{
- assert(parser);
- assert(num_bitstreams);
- assert(bitstreams);
- assert(sizes);
-
- parser->num_bitstreams = num_bitstreams;
- parser->bitstreams = (const unsigned**)bitstreams;
- parser->sizes = sizes;
- parser->cur_bitstream = 0;
- parser->cursor = 0;
-
- return true;
-}
-
-void vl_bitstream_parser_cleanup(struct vl_bitstream_parser *parser)
-{
- assert(parser);
-}
-
-unsigned
-vl_bitstream_parser_get_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- unsigned bits;
-
- assert(parser);
-
- bits = vl_bitstream_parser_show_bits(parser, how_many_bits);
-
- vl_bitstream_parser_forward(parser, how_many_bits);
-
- return bits;
-}
-
-unsigned
-vl_bitstream_parser_show_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- unsigned bits = 0;
- unsigned shift = 0;
- unsigned cursor;
- unsigned cur_bitstream;
-
- assert(parser);
-
- cursor = parser->cursor;
- cur_bitstream = parser->cur_bitstream;
-
- while (1) {
- unsigned bits_left = parser->sizes[cur_bitstream] * CHAR_BIT - cursor;
- unsigned bits_to_show = how_many_bits > bits_left ? bits_left : how_many_bits;
-
- bits |= show_bits(cursor, bits_to_show,
- parser->bitstreams[cur_bitstream]) << shift;
-
- if (how_many_bits > bits_to_show) {
- how_many_bits -= bits_to_show;
- cursor = 0;
- ++cur_bitstream;
- shift += bits_to_show;
- }
- else
- break;
- }
-
- return bits;
-}
-
-void vl_bitstream_parser_forward(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- assert(parser);
- assert(how_many_bits);
-
- parser->cursor += how_many_bits;
-
- while (parser->cursor > parser->sizes[parser->cur_bitstream] * CHAR_BIT) {
- parser->cursor -= parser->sizes[parser->cur_bitstream++] * CHAR_BIT;
- assert(parser->cur_bitstream < parser->num_bitstreams);
- }
-}
-
-void vl_bitstream_parser_rewind(struct vl_bitstream_parser *parser,
- unsigned how_many_bits)
-{
- signed c;
-
- assert(parser);
- assert(how_many_bits);
-
- c = parser->cursor - how_many_bits;
-
- while (c < 0) {
- c += parser->sizes[parser->cur_bitstream--] * CHAR_BIT;
- assert(parser->cur_bitstream < parser->num_bitstreams);
- }
-
- parser->cursor = (unsigned)c;
-}
diff --git a/src/gallium/auxiliary/vl/vl_bitstream_parser.h b/src/gallium/auxiliary/vl/vl_bitstream_parser.h
deleted file mode 100644
index 30ec743fa7..0000000000
--- a/src/gallium/auxiliary/vl/vl_bitstream_parser.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_bitstream_parser_h
-#define vl_bitstream_parser_h
-
-#include "pipe/p_compiler.h"
-
-struct vl_bitstream_parser
-{
- unsigned num_bitstreams;
- const unsigned **bitstreams;
- const unsigned *sizes;
- unsigned cur_bitstream;
- unsigned cursor;
-};
-
-bool vl_bitstream_parser_init(struct vl_bitstream_parser *parser,
- unsigned num_bitstreams,
- const void **bitstreams,
- const unsigned *sizes);
-
-void vl_bitstream_parser_cleanup(struct vl_bitstream_parser *parser);
-
-unsigned
-vl_bitstream_parser_get_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-unsigned
-vl_bitstream_parser_show_bits(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-void vl_bitstream_parser_forward(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-void vl_bitstream_parser_rewind(struct vl_bitstream_parser *parser,
- unsigned how_many_bits);
-
-#endif /* vl_bitstream_parser_h */
diff --git a/src/gallium/auxiliary/vl/vl_compositor.c b/src/gallium/auxiliary/vl/vl_compositor.c
deleted file mode 100644
index 6d461cb880..0000000000
--- a/src/gallium/auxiliary/vl/vl_compositor.c
+++ /dev/null
@@ -1,536 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_compositor.h"
-#include <assert.h>
-#include <pipe/p_context.h>
-#include <util/u_inlines.h>
-#include <tgsi/tgsi_parse.h>
-#include <tgsi/tgsi_build.h>
-#include <util/u_memory.h>
-#include "vl_csc.h"
-#include "vl_shader_build.h"
-
-struct vertex2f
-{
- float x, y;
-};
-
-struct vertex4f
-{
- float x, y, z, w;
-};
-
-struct vertex_shader_consts
-{
- struct vertex4f dst_scale;
- struct vertex4f dst_trans;
- struct vertex4f src_scale;
- struct vertex4f src_trans;
-};
-
-struct fragment_shader_consts
-{
- float matrix[16];
-};
-
-/*
- * Represents 2 triangles in a strip in normalized coords.
- * Used to render the surface onto the frame buffer.
- */
-static const struct vertex2f surface_verts[4] =
-{
- {0.0f, 0.0f},
- {0.0f, 1.0f},
- {1.0f, 0.0f},
- {1.0f, 1.0f}
-};
-
-/*
- * Represents texcoords for the above. We can use the position values directly.
- * TODO: Duplicate these in the shader, no need to create a buffer.
- */
-static const struct vertex2f *surface_texcoords = surface_verts;
-
-static void
-create_vert_shader(struct vl_compositor *c)
-{
- const unsigned max_tokens = 50;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(c);
-
- tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header*)&tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Vertex texcoords
- */
- for (i = 0; i < 2; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl c0 ; Scaling vector to scale vertex pos rect to destination size
- * decl c1 ; Translation vector to move vertex pos rect into position
- * decl c2 ; Scaling vector to scale texcoord rect to source size
- * decl c3 ; Translation vector to move texcoord rect into position
- */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 3);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Vertex texcoords
- */
- for (i = 0; i < 2; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /* decl t0, t1 */
- decl = vl_decl_temps(0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * mad o0, i0, c0, c1 ; Scale and translate unit output rect to destination size and pos
- * mad o1, i1, c2, c3 ; Scale and translate unit texcoord rect to source size and pos
- */
- for (i = 0; i < 2; ++i) {
- inst = vl_inst4(TGSI_OPCODE_MAD, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i, TGSI_FILE_CONSTANT, i * 2, TGSI_FILE_CONSTANT, i * 2 + 1);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- c->vertex_shader = c->pipe->create_vs_state(c->pipe, &vs);
- FREE(tokens);
-}
-
-static void
-create_frag_shader(struct vl_compositor *c)
-{
- const unsigned max_tokens = 50;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(c);
-
- tokens = (struct tgsi_token*)MALLOC(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header*)&tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor*)&tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /* decl i0 ; Texcoords for s0 */
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, 1, 0, 0, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl c0-c3 ; CSC matrix c0-c3
- */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 3);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0 */
- decl = vl_decl_temps(0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl s0 ; Sampler for tex containing picture to display */
- decl = vl_decl_samplers(0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* tex2d t0, i0, s0 ; Read src pixel */
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_INPUT, 0, TGSI_FILE_SAMPLER, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /*
- * dp4 o0.x, t0, c0 ; Multiply pixel by the color conversion matrix
- * dp4 o0.y, t0, c1
- * dp4 o0.z, t0, c2
- * dp4 o0.w, t0, c3
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst3(TGSI_OPCODE_DP4, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, i);
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- c->fragment_shader = c->pipe->create_fs_state(c->pipe, &fs);
- FREE(tokens);
-}
-
-static bool
-init_pipe_state(struct vl_compositor *c)
-{
- struct pipe_sampler_state sampler;
- struct pipe_vertex_element vertex_elems[2];
-
- assert(c);
-
- c->fb_state.nr_cbufs = 1;
- c->fb_state.zsbuf = NULL;
-
- sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR;
- sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
- sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR;
- sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
- sampler.compare_func = PIPE_FUNC_ALWAYS;
- sampler.normalized_coords = 1;
- /*sampler.lod_bias = ;*/
- /*sampler.min_lod = ;*/
- /*sampler.max_lod = ;*/
- /*sampler.border_color[i] = ;*/
- /*sampler.max_anisotropy = ;*/
- c->sampler = c->pipe->create_sampler_state(c->pipe, &sampler);
-
- vertex_elems[0].src_offset = 0;
- vertex_elems[0].instance_divisor = 0;
- vertex_elems[0].vertex_buffer_index = 0;
- vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
- vertex_elems[1].src_offset = 0;
- vertex_elems[1].instance_divisor = 0;
- vertex_elems[1].vertex_buffer_index = 1;
- vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
- c->vertex_elems = c->pipe->create_vertex_elements_state(c->pipe, 2, vertex_elems);
-
-
- return true;
-}
-
-static void cleanup_pipe_state(struct vl_compositor *c)
-{
- assert(c);
-
- c->pipe->delete_sampler_state(c->pipe, c->sampler);
- c->pipe->delete_vertex_elements_state(c->pipe, c->vertex_elems);
-}
-
-static bool
-init_shaders(struct vl_compositor *c)
-{
- assert(c);
-
- create_vert_shader(c);
- create_frag_shader(c);
-
- return true;
-}
-
-static void cleanup_shaders(struct vl_compositor *c)
-{
- assert(c);
-
- c->pipe->delete_vs_state(c->pipe, c->vertex_shader);
- c->pipe->delete_fs_state(c->pipe, c->fragment_shader);
-}
-
-static bool
-init_buffers(struct vl_compositor *c)
-{
- struct fragment_shader_consts fsc;
-
- assert(c);
-
- /*
- * Create our vertex buffer and vertex buffer element
- * VB contains 4 vertices that render a quad covering the entire window
- * to display a rendered surface
- * Quad is rendered as a tri strip
- */
- c->vertex_bufs[0].stride = sizeof(struct vertex2f);
- c->vertex_bufs[0].max_index = 3;
- c->vertex_bufs[0].buffer_offset = 0;
- c->vertex_bufs[0].buffer = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_VERTEX,
- sizeof(struct vertex2f) * 4
- );
-
- memcpy
- (
- pipe_buffer_map(c->pipe->screen, c->vertex_bufs[0].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- surface_verts,
- sizeof(struct vertex2f) * 4
- );
-
- pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[0].buffer);
-
- /*
- * Create our texcoord buffer and texcoord buffer element
- * Texcoord buffer contains the TCs for mapping the rendered surface to the 4 vertices
- */
- c->vertex_bufs[1].stride = sizeof(struct vertex2f);
- c->vertex_bufs[1].max_index = 3;
- c->vertex_bufs[1].buffer_offset = 0;
- c->vertex_bufs[1].buffer = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_VERTEX,
- sizeof(struct vertex2f) * 4
- );
-
- memcpy
- (
- pipe_buffer_map(c->pipe->screen, c->vertex_bufs[1].buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
- surface_texcoords,
- sizeof(struct vertex2f) * 4
- );
-
- pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[1].buffer);
-
- /*
- * Create our vertex shader's constant buffer
- * Const buffer contains scaling and translation vectors
- */
- c->vs_const_buf = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_CONSTANT | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex_shader_consts)
- );
-
- /*
- * Create our fragment shader's constant buffer
- * Const buffer contains the color conversion matrix and bias vectors
- */
- c->fs_const_buf = pipe_buffer_create
- (
- c->pipe->screen,
- 1,
- PIPE_BUFFER_USAGE_CONSTANT,
- sizeof(struct fragment_shader_consts)
- );
-
- vl_csc_get_matrix(VL_CSC_COLOR_STANDARD_IDENTITY, NULL, true, fsc.matrix);
-
- vl_compositor_set_csc_matrix(c, fsc.matrix);
-
- return true;
-}
-
-static void
-cleanup_buffers(struct vl_compositor *c)
-{
- unsigned i;
-
- assert(c);
-
- for (i = 0; i < 2; ++i)
- pipe_buffer_reference(&c->vertex_bufs[i].buffer, NULL);
-
- pipe_buffer_reference(&c->vs_const_buf, NULL);
- pipe_buffer_reference(&c->fs_const_buf, NULL);
-}
-
-bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe)
-{
- assert(compositor);
-
- memset(compositor, 0, sizeof(struct vl_compositor));
-
- compositor->pipe = pipe;
-
- if (!init_pipe_state(compositor))
- return false;
- if (!init_shaders(compositor)) {
- cleanup_pipe_state(compositor);
- return false;
- }
- if (!init_buffers(compositor)) {
- cleanup_shaders(compositor);
- cleanup_pipe_state(compositor);
- return false;
- }
-
- return true;
-}
-
-void vl_compositor_cleanup(struct vl_compositor *compositor)
-{
- assert(compositor);
-
- cleanup_buffers(compositor);
- cleanup_shaders(compositor);
- cleanup_pipe_state(compositor);
-}
-
-void vl_compositor_render(struct vl_compositor *compositor,
- /*struct pipe_texture *backround,
- struct pipe_video_rect *backround_area,*/
- struct pipe_texture *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_texture *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_texture *future_surfaces,*/
- struct pipe_video_rect *src_area,
- struct pipe_texture *dst_surface,
- struct pipe_video_rect *dst_area,
- /*unsigned num_layers,
- struct pipe_texture *layers,
- struct pipe_video_rect *layer_src_areas,
- struct pipe_video_rect *layer_dst_areas*/
- struct pipe_fence_handle **fence)
-{
- struct vertex_shader_consts *vs_consts;
-
- assert(compositor);
- assert(src_surface);
- assert(src_area);
- assert(dst_surface);
- assert(dst_area);
- assert(picture_type == PIPE_MPEG12_PICTURE_TYPE_FRAME);
-
- compositor->fb_state.width = dst_surface->width0;
- compositor->fb_state.height = dst_surface->height0;
- compositor->fb_state.cbufs[0] = compositor->pipe->screen->get_tex_surface
- (
- compositor->pipe->screen,
- dst_surface,
- 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE
- );
-
- compositor->viewport.scale[0] = compositor->fb_state.width;
- compositor->viewport.scale[1] = compositor->fb_state.height;
- compositor->viewport.scale[2] = 1;
- compositor->viewport.scale[3] = 1;
- compositor->viewport.translate[0] = 0;
- compositor->viewport.translate[1] = 0;
- compositor->viewport.translate[2] = 0;
- compositor->viewport.translate[3] = 0;
-
- compositor->scissor.maxx = compositor->fb_state.width;
- compositor->scissor.maxy = compositor->fb_state.height;
-
- compositor->pipe->set_framebuffer_state(compositor->pipe, &compositor->fb_state);
- compositor->pipe->set_viewport_state(compositor->pipe, &compositor->viewport);
- compositor->pipe->set_scissor_state(compositor->pipe, &compositor->scissor);
- compositor->pipe->bind_fragment_sampler_states(compositor->pipe, 1, &compositor->sampler);
- compositor->pipe->set_fragment_sampler_textures(compositor->pipe, 1, &src_surface);
- compositor->pipe->bind_vs_state(compositor->pipe, compositor->vertex_shader);
- compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader);
- compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs);
- compositor->pipe->bind_vertex_elements_state(compositor->pipe, compositor->vertex_elems);
- compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_VERTEX, 0, compositor->vs_const_buf);
- compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, compositor->fs_const_buf);
-
- vs_consts = pipe_buffer_map
- (
- compositor->pipe->screen,
- compositor->vs_const_buf,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- vs_consts->dst_scale.x = dst_area->w / (float)compositor->fb_state.cbufs[0]->width;
- vs_consts->dst_scale.y = dst_area->h / (float)compositor->fb_state.cbufs[0]->height;
- vs_consts->dst_scale.z = 1;
- vs_consts->dst_scale.w = 1;
- vs_consts->dst_trans.x = dst_area->x / (float)compositor->fb_state.cbufs[0]->width;
- vs_consts->dst_trans.y = dst_area->y / (float)compositor->fb_state.cbufs[0]->height;
- vs_consts->dst_trans.z = 0;
- vs_consts->dst_trans.w = 0;
-
- vs_consts->src_scale.x = src_area->w / (float)src_surface->width0;
- vs_consts->src_scale.y = src_area->h / (float)src_surface->height0;
- vs_consts->src_scale.z = 1;
- vs_consts->src_scale.w = 1;
- vs_consts->src_trans.x = src_area->x / (float)src_surface->width0;
- vs_consts->src_trans.y = src_area->y / (float)src_surface->height0;
- vs_consts->src_trans.z = 0;
- vs_consts->src_trans.w = 0;
-
- pipe_buffer_unmap(compositor->pipe->screen, compositor->vs_const_buf);
-
- compositor->pipe->draw_arrays(compositor->pipe, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
- compositor->pipe->flush(compositor->pipe, PIPE_FLUSH_RENDER_CACHE, fence);
-
- pipe_surface_reference(&compositor->fb_state.cbufs[0], NULL);
-}
-
-void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float *mat)
-{
- assert(compositor);
-
- memcpy
- (
- pipe_buffer_map(compositor->pipe->screen, compositor->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
- mat,
- sizeof(struct fragment_shader_consts)
- );
-
- pipe_buffer_unmap(compositor->pipe->screen, compositor->fs_const_buf);
-}
diff --git a/src/gallium/auxiliary/vl/vl_compositor.h b/src/gallium/auxiliary/vl/vl_compositor.h
deleted file mode 100644
index 51755554da..0000000000
--- a/src/gallium/auxiliary/vl/vl_compositor.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_compositor_h
-#define vl_compositor_h
-
-#include <pipe/p_compiler.h>
-#include <pipe/p_state.h>
-#include <pipe/p_video_state.h>
-
-struct pipe_context;
-struct pipe_texture;
-
-struct vl_compositor
-{
- struct pipe_context *pipe;
-
- struct pipe_framebuffer_state fb_state;
- void *sampler;
- void *vertex_shader;
- void *fragment_shader;
- void *vertex_elems;
- struct pipe_viewport_state viewport;
- struct pipe_scissor_state scissor;
- struct pipe_vertex_buffer vertex_bufs[2];
- struct pipe_buffer *vs_const_buf, *fs_const_buf;
-};
-
-bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
-
-void vl_compositor_cleanup(struct vl_compositor *compositor);
-
-void vl_compositor_render(struct vl_compositor *compositor,
- /*struct pipe_texture *backround,
- struct pipe_video_rect *backround_area,*/
- struct pipe_texture *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_texture *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_texture *future_surfaces,*/
- struct pipe_video_rect *src_area,
- struct pipe_texture *dst_surface,
- struct pipe_video_rect *dst_area,
- /*unsigned num_layers,
- struct pipe_texture *layers,
- struct pipe_video_rect *layer_src_areas,
- struct pipe_video_rect *layer_dst_areas,*/
- struct pipe_fence_handle **fence);
-
-void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float *mat);
-
-#endif /* vl_compositor_h */
diff --git a/src/gallium/auxiliary/vl/vl_csc.c b/src/gallium/auxiliary/vl/vl_csc.c
deleted file mode 100644
index 5ecc43a5fa..0000000000
--- a/src/gallium/auxiliary/vl/vl_csc.c
+++ /dev/null
@@ -1,206 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_csc.h"
-#include <util/u_math.h>
-#include <util/u_debug.h>
-
-/*
- * Color space conversion formulas
- *
- * To convert YCbCr to RGB,
- * vec4 ycbcr, rgb
- * mat44 csc
- * rgb = csc * ycbcr
- *
- * To calculate the color space conversion matrix csc with ProcAmp adjustments,
- * mat44 csc, cstd, procamp, bias
- * csc = cstd * (procamp * bias)
- *
- * Where cstd is a matrix corresponding to one of the color standards (BT.601, BT.709, etc)
- * adjusted for the kind of YCbCr -> RGB mapping wanted (1:1, full),
- * bias is a matrix corresponding to the kind of YCbCr -> RGB mapping wanted (1:1, full)
- *
- * To calculate procamp,
- * mat44 procamp, hue, saturation, brightness, contrast
- * procamp = brightness * (saturation * (contrast * hue))
- * Alternatively,
- * procamp = saturation * (brightness * (contrast * hue))
- *
- * contrast
- * [ c, 0, 0, 0]
- * [ 0, c, 0, 0]
- * [ 0, 0, c, 0]
- * [ 0, 0, 0, 1]
- *
- * brightness
- * [ 1, 0, 0, b]
- * [ 0, 1, 0, 0]
- * [ 0, 0, 1, 0]
- * [ 0, 0, 0, 1]
- *
- * saturation
- * [ 1, 0, 0, 0]
- * [ 0, s, 0, 0]
- * [ 0, 0, s, 0]
- * [ 0, 0, 0, 1]
- *
- * hue
- * [ 1, 0, 0, 0]
- * [ 0, cos(h), sin(h), 0]
- * [ 0, -sin(h), cos(h), 0]
- * [ 0, 0, 0, 1]
- *
- * procamp
- * [ c, 0, 0, b]
- * [ 0, c*s*cos(h), c*s*sin(h), 0]
- * [ 0, -c*s*sin(h), c*s*cos(h), 0]
- * [ 0, 0, 0, 1]
- *
- * bias
- * [ 1, 0, 0, ybias]
- * [ 0, 1, 0, cbbias]
- * [ 0, 0, 1, crbias]
- * [ 0, 0, 0, 1]
- *
- * csc
- * [ c*cstd[ 0], c*cstd[ 1]*s*cos(h) - c*cstd[ 2]*s*sin(h), c*cstd[ 2]*s*cos(h) + c*cstd[ 1]*s*sin(h), cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 2]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- * [ c*cstd[ 4], c*cstd[ 5]*s*cos(h) - c*cstd[ 6]*s*sin(h), c*cstd[ 6]*s*cos(h) + c*cstd[ 5]*s*sin(h), cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[ 6]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- * [ c*cstd[ 8], c*cstd[ 9]*s*cos(h) - c*cstd[10]*s*sin(h), c*cstd[10]*s*cos(h) + c*cstd[ 9]*s*sin(h), cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[10]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- * [ c*cstd[12], c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h), c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h), cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h))]
- */
-
-/*
- * Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [16,235]
- */
-static const float bt_601[16] =
-{
- 1.0f, 0.0f, 1.371f, 0.0f,
- 1.0f, -0.336f, -0.698f, 0.0f,
- 1.0f, 1.732f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-/*
- * Converts ITU-R BT.601 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [0,255]
- */
-static const float bt_601_full[16] =
-{
- 1.164f, 0.0f, 1.596f, 0.0f,
- 1.164f, -0.391f, -0.813f, 0.0f,
- 1.164f, 2.018f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-/*
- * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [16,235]
- */
-static const float bt_709[16] =
-{
- 1.0f, 0.0f, 1.540f, 0.0f,
- 1.0f, -0.183f, -0.459f, 0.0f,
- 1.0f, 1.816f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-/*
- * Converts ITU-R BT.709 YCbCr pixels to RGB pixels where:
- * Y is in [16,235], Cb and Cr are in [16,240]
- * R, G, and B are in [0,255]
- */
-static const float bt_709_full[16] =
-{
- 1.164f, 0.0f, 1.793f, 0.0f,
- 1.164f, -0.213f, -0.534f, 0.0f,
- 1.164f, 2.115f, 0.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-static const float identity[16] =
-{
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f
-};
-
-void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
- struct vl_procamp *procamp,
- bool full_range,
- float *matrix)
-{
- float ybias = full_range ? -16.0f/255.0f : 0.0f;
- float cbbias = -128.0f/255.0f;
- float crbias = -128.0f/255.0f;
- float c = procamp ? procamp->contrast : 1.0f;
- float s = procamp ? procamp->saturation : 1.0f;
- float b = procamp ? procamp->brightness : 0.0f;
- float h = procamp ? procamp->hue : 0.0f;
- const float *cstd;
-
- assert(matrix);
-
- switch (cs) {
- case VL_CSC_COLOR_STANDARD_BT_601:
- cstd = full_range ? &bt_601_full[0] : &bt_601[0];
- break;
- case VL_CSC_COLOR_STANDARD_BT_709:
- cstd = full_range ? &bt_709_full[0] : &bt_709[0];
- break;
- case VL_CSC_COLOR_STANDARD_IDENTITY:
- default:
- assert(cs == VL_CSC_COLOR_STANDARD_IDENTITY);
- memcpy(matrix, &identity[0], sizeof(float) * 16);
- return;
- }
-
- matrix[ 0] = c*cstd[ 0];
- matrix[ 1] = c*cstd[ 1]*s*cosf(h) - c*cstd[ 2]*s*sinf(h);
- matrix[ 2] = c*cstd[ 2]*s*cosf(h) + c*cstd[ 1]*s*sinf(h);
- matrix[ 3] = cstd[ 3] + cstd[ 0]*(b + c*ybias) + cstd[ 1]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 2]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[ 4] = c*cstd[ 4];
- matrix[ 5] = c*cstd[ 5]*s*cosf(h) - c*cstd[ 6]*s*sinf(h);
- matrix[ 6] = c*cstd[ 6]*s*cosf(h) + c*cstd[ 5]*s*sinf(h);
- matrix[ 7] = cstd[ 7] + cstd[ 4]*(b + c*ybias) + cstd[ 5]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[ 6]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[ 8] = c*cstd[ 8];
- matrix[ 9] = c*cstd[ 9]*s*cosf(h) - c*cstd[10]*s*sinf(h);
- matrix[10] = c*cstd[10]*s*cosf(h) + c*cstd[ 9]*s*sinf(h);
- matrix[11] = cstd[11] + cstd[ 8]*(b + c*ybias) + cstd[ 9]*(c*cbbias*s*cosf(h) + c*crbias*s*sinf(h)) + cstd[10]*(c*crbias*s*cosf(h) - c*cbbias*s*sinf(h));
-
- matrix[12] = c*cstd[12];
- matrix[13] = c*cstd[13]*s*cos(h) - c*cstd[14]*s*sin(h);
- matrix[14] = c*cstd[14]*s*cos(h) + c*cstd[13]*s*sin(h);
- matrix[15] = cstd[15] + cstd[12]*(b + c*ybias) + cstd[13]*(c*cbbias*s*cos(h) + c*crbias*s*sin(h)) + cstd[14]*(c*crbias*s*cos(h) - c*cbbias*s*sin(h));
-}
diff --git a/src/gallium/auxiliary/vl/vl_csc.h b/src/gallium/auxiliary/vl/vl_csc.h
deleted file mode 100644
index 722ca35f33..0000000000
--- a/src/gallium/auxiliary/vl/vl_csc.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_csc_h
-#define vl_csc_h
-
-#include <pipe/p_compiler.h>
-
-struct vl_procamp
-{
- float brightness;
- float contrast;
- float saturation;
- float hue;
-};
-
-enum VL_CSC_COLOR_STANDARD
-{
- VL_CSC_COLOR_STANDARD_IDENTITY,
- VL_CSC_COLOR_STANDARD_BT_601,
- VL_CSC_COLOR_STANDARD_BT_709
-};
-
-void vl_csc_get_matrix(enum VL_CSC_COLOR_STANDARD cs,
- struct vl_procamp *procamp,
- bool full_range,
- float *matrix);
-
-#endif /* vl_csc_h */
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
deleted file mode 100644
index beb4722901..0000000000
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
+++ /dev/null
@@ -1,1672 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_mpeg12_mc_renderer.h"
-#include <assert.h>
-#include <pipe/p_context.h>
-#include <util/u_inlines.h>
-#include <util/u_format.h>
-#include <util/u_math.h>
-#include <util/u_memory.h>
-#include <tgsi/tgsi_parse.h>
-#include <tgsi/tgsi_build.h>
-#include "vl_shader_build.h"
-
-#define DEFAULT_BUF_ALIGNMENT 1
-#define MACROBLOCK_WIDTH 16
-#define MACROBLOCK_HEIGHT 16
-#define BLOCK_WIDTH 8
-#define BLOCK_HEIGHT 8
-#define ZERO_BLOCK_NIL -1.0f
-#define ZERO_BLOCK_IS_NIL(zb) ((zb).x < 0.0f)
-
-struct vertex2f
-{
- float x, y;
-};
-
-struct vertex4f
-{
- float x, y, z, w;
-};
-
-struct vertex_shader_consts
-{
- struct vertex4f denorm;
-};
-
-struct fragment_shader_consts
-{
- struct vertex4f multiplier;
- struct vertex4f div;
-};
-
-/*
- * Muliplier renormalizes block samples from 16 bits to 12 bits.
- * Divider is used when calculating Y % 2 for choosing top or bottom
- * field for P or B macroblocks.
- * TODO: Use immediates.
- */
-static const struct fragment_shader_consts fs_consts = {
- {32767.0f / 255.0f, 32767.0f / 255.0f, 32767.0f / 255.0f, 0.0f},
- {0.5f, 2.0f, 0.0f, 0.0f}
-};
-
-struct vert_stream_0
-{
- struct vertex2f pos;
- struct vertex2f luma_tc;
- struct vertex2f cb_tc;
- struct vertex2f cr_tc;
-};
-
-enum MACROBLOCK_TYPE
-{
- MACROBLOCK_TYPE_INTRA,
- MACROBLOCK_TYPE_FWD_FRAME_PRED,
- MACROBLOCK_TYPE_FWD_FIELD_PRED,
- MACROBLOCK_TYPE_BKWD_FRAME_PRED,
- MACROBLOCK_TYPE_BKWD_FIELD_PRED,
- MACROBLOCK_TYPE_BI_FRAME_PRED,
- MACROBLOCK_TYPE_BI_FIELD_PRED,
-
- NUM_MACROBLOCK_TYPES
-};
-
-static void
-create_intra_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 50;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Luma texcoords
- * decl i2 ; Chroma Cb texcoords
- * decl i3 ; Chroma Cr texcoords
- */
- for (i = 0; i < 4; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Luma texcoords
- * decl o2 ; Chroma Cb texcoords
- * decl o3 ; Chroma Cr texcoords
- */
- for (i = 0; i < 4; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * mov o0, i0 ; Move input vertex pos to output
- * mov o1, i1 ; Move input luma texcoords to output
- * mov o2, i2 ; Move input chroma Cb texcoords to output
- * mov o3, i3 ; Move input chroma Cr texcoords to output
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- r->i_vs = r->pipe->create_vs_state(r->pipe, &vs);
- free(tokens);
-}
-
-static void
-create_intra_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Luma texcoords
- * decl i1 ; Chroma Cb texcoords
- * decl i2 ; Chroma Cr texcoords
- */
- for (i = 0; i < 3; ++i) {
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, i + 1, i, i, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /* decl c0 ; Scaling factor, rescales 16-bit snorm to 9-bit snorm */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0, t1 */
- decl = vl_decl_temps(0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl s0 ; Sampler for luma texture
- * decl s1 ; Sampler for chroma Cb texture
- * decl s2 ; Sampler for chroma Cr texture
- */
- for (i = 0; i < 3; ++i) {
- decl = vl_decl_samplers(i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * tex2d t1, i0, s0 ; Read texel from luma texture
- * mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
- * mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
- * mov t0.z, t1.x ; Move Cr sample into .z component
- */
- for (i = 0; i < 3; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* mul o0, t0, c0 ; Rescale texel to correct range */
- inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- r->i_fs = r->pipe->create_fs_state(r->pipe, &fs);
- free(tokens);
-}
-
-static void
-create_frame_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Luma texcoords
- * decl i2 ; Chroma Cb texcoords
- * decl i3 ; Chroma Cr texcoords
- * decl i4 ; Ref surface top field texcoords
- * decl i5 ; Ref surface bottom field texcoords (unused, packed in the same stream)
- */
- for (i = 0; i < 6; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Luma texcoords
- * decl o2 ; Chroma Cb texcoords
- * decl o3 ; Chroma Cr texcoords
- * decl o4 ; Ref macroblock texcoords
- */
- for (i = 0; i < 5; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * mov o0, i0 ; Move input vertex pos to output
- * mov o1, i1 ; Move input luma texcoords to output
- * mov o2, i2 ; Move input chroma Cb texcoords to output
- * mov o3, i3 ; Move input chroma Cr texcoords to output
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* add o4, i0, i4 ; Translate vertex pos by motion vec to form ref macroblock texcoords */
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, 4, TGSI_FILE_INPUT, 0, TGSI_FILE_INPUT, 4);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- r->p_vs[0] = r->pipe->create_vs_state(r->pipe, &vs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-create_frame_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Luma texcoords
- * decl i1 ; Chroma Cb texcoords
- * decl i2 ; Chroma Cr texcoords
- * decl i3 ; Ref macroblock texcoords
- */
- for (i = 0; i < 4; ++i) {
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, i + 1, i, i, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /* decl c0 ; Scaling factor, rescales 16-bit snorm to 9-bit snorm */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0, t1 */
- decl = vl_decl_temps(0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl s0 ; Sampler for luma texture
- * decl s1 ; Sampler for chroma Cb texture
- * decl s2 ; Sampler for chroma Cr texture
- * decl s3 ; Sampler for ref surface texture
- */
- for (i = 0; i < 4; ++i) {
- decl = vl_decl_samplers(i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * tex2d t1, i0, s0 ; Read texel from luma texture
- * mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
- * mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
- * mov t0.z, t1.x ; Move Cr sample into .z component
- */
- for (i = 0; i < 3; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* mul t0, t0, c0 ; Rescale texel to correct range */
- inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* tex2d t1, i3, s3 ; Read texel from ref macroblock */
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, 3, TGSI_FILE_SAMPLER, 3);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* add o0, t0, t1 ; Add ref and differential to form final output */
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- r->p_fs[0] = r->pipe->create_fs_state(r->pipe, &fs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-create_frame_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state vs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_VERTEX, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Vertex pos
- * decl i1 ; Luma texcoords
- * decl i2 ; Chroma Cb texcoords
- * decl i3 ; Chroma Cr texcoords
- * decl i4 ; First ref macroblock top field texcoords
- * decl i5 ; First ref macroblock bottom field texcoords (unused, packed in the same stream)
- * decl i6 ; Second ref macroblock top field texcoords
- * decl i7 ; Second ref macroblock bottom field texcoords (unused, packed in the same stream)
- */
- for (i = 0; i < 8; i++) {
- decl = vl_decl_input(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl o0 ; Vertex pos
- * decl o1 ; Luma texcoords
- * decl o2 ; Chroma Cb texcoords
- * decl o3 ; Chroma Cr texcoords
- * decl o4 ; First ref macroblock texcoords
- * decl o5 ; Second ref macroblock texcoords
- */
- for (i = 0; i < 6; i++) {
- decl = vl_decl_output(i == 0 ? TGSI_SEMANTIC_POSITION : TGSI_SEMANTIC_GENERIC, i, i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * mov o0, i0 ; Move input vertex pos to output
- * mov o1, i1 ; Move input luma texcoords to output
- * mov o2, i2 ; Move input chroma Cb texcoords to output
- * mov o3, i3 ; Move input chroma Cr texcoords to output
- */
- for (i = 0; i < 4; ++i) {
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_OUTPUT, i, TGSI_FILE_INPUT, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * add o4, i0, i4 ; Translate vertex pos by motion vec to form first ref macroblock texcoords
- * add o5, i0, i6 ; Translate vertex pos by motion vec to form second ref macroblock texcoords
- */
- for (i = 0; i < 2; ++i) {
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, i + 4, TGSI_FILE_INPUT, 0, TGSI_FILE_INPUT, (i + 2) * 2);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- vs.tokens = tokens;
- r->b_vs[0] = r->pipe->create_vs_state(r->pipe, &vs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_bi_pred_vert_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-create_frame_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- const unsigned max_tokens = 100;
-
- struct pipe_shader_state fs;
- struct tgsi_token *tokens;
- struct tgsi_header *header;
-
- struct tgsi_full_declaration decl;
- struct tgsi_full_instruction inst;
-
- unsigned ti;
-
- unsigned i;
-
- assert(r);
-
- tokens = (struct tgsi_token *) malloc(max_tokens * sizeof(struct tgsi_token));
- header = (struct tgsi_header *) &tokens[0];
- *header = tgsi_build_header();
- *(struct tgsi_processor *) &tokens[1] = tgsi_build_processor(TGSI_PROCESSOR_FRAGMENT, header);
-
- ti = 2;
-
- /*
- * decl i0 ; Luma texcoords
- * decl i1 ; Chroma Cb texcoords
- * decl i2 ; Chroma Cr texcoords
- * decl i3 ; First ref macroblock texcoords
- * decl i4 ; Second ref macroblock texcoords
- */
- for (i = 0; i < 5; ++i) {
- decl = vl_decl_interpolated_input(TGSI_SEMANTIC_GENERIC, i + 1, i, i, TGSI_INTERPOLATE_LINEAR);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * decl c0 ; Scaling factor, rescales 16-bit snorm to 9-bit snorm
- * decl c1 ; Constant 1/2 in .x channel to use as weight to blend past and future texels
- */
- decl = vl_decl_constants(TGSI_SEMANTIC_GENERIC, 0, 0, 1);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl o0 ; Fragment color */
- decl = vl_decl_output(TGSI_SEMANTIC_COLOR, 0, 0, 0);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /* decl t0-t2 */
- decl = vl_decl_temps(0, 2);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
-
- /*
- * decl s0 ; Sampler for luma texture
- * decl s1 ; Sampler for chroma Cb texture
- * decl s2 ; Sampler for chroma Cr texture
- * decl s3 ; Sampler for first ref surface texture
- * decl s4 ; Sampler for second ref surface texture
- */
- for (i = 0; i < 5; ++i) {
- decl = vl_decl_samplers(i, i);
- ti += tgsi_build_full_declaration(&decl, &tokens[ti], header, max_tokens - ti);
- }
-
- /*
- * tex2d t1, i0, s0 ; Read texel from luma texture
- * mov t0.x, t1.x ; Move luma sample into .x component
- * tex2d t1, i1, s1 ; Read texel from chroma Cb texture
- * mov t0.y, t1.x ; Move Cb sample into .y component
- * tex2d t1, i2, s2 ; Read texel from chroma Cr texture
- * mov t0.z, t1.x ; Move Cr sample into .z component
- */
- for (i = 0; i < 3; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_INPUT, i, TGSI_FILE_SAMPLER, i);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- inst = vl_inst2(TGSI_OPCODE_MOV, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Dst[0].Register.WriteMask = TGSI_WRITEMASK_X << i;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* mul t0, t0, c0 ; Rescale texel to correct range */
- inst = vl_inst3(TGSI_OPCODE_MUL, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_CONSTANT, 0);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /*
- * tex2d t1, i3, s3 ; Read texel from first ref macroblock
- * tex2d t2, i4, s4 ; Read texel from second ref macroblock
- */
- for (i = 0; i < 2; ++i) {
- inst = vl_tex(TGSI_TEXTURE_2D, TGSI_FILE_TEMPORARY, i + 1, TGSI_FILE_INPUT, i + 3, TGSI_FILE_SAMPLER, i + 3);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
- }
-
- /* lerp t1, c1.x, t1, t2 ; Blend past and future texels */
- inst = vl_inst4(TGSI_OPCODE_LRP, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_CONSTANT, 1, TGSI_FILE_TEMPORARY, 1, TGSI_FILE_TEMPORARY, 2);
- inst.Src[0].Register.SwizzleX = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleY = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleZ = TGSI_SWIZZLE_X;
- inst.Src[0].Register.SwizzleW = TGSI_SWIZZLE_X;
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* add o0, t0, t1 ; Add past/future ref and differential to form final output */
- inst = vl_inst3(TGSI_OPCODE_ADD, TGSI_FILE_OUTPUT, 0, TGSI_FILE_TEMPORARY, 0, TGSI_FILE_TEMPORARY, 1);
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- /* end */
- inst = vl_end();
- ti += tgsi_build_full_instruction(&inst, &tokens[ti], header, max_tokens - ti);
-
- assert(ti <= max_tokens);
-
- fs.tokens = tokens;
- r->b_fs[0] = r->pipe->create_fs_state(r->pipe, &fs);
- free(tokens);
-}
-
-#if 0
-static void
-create_field_bi_pred_frag_shader(struct vl_mpeg12_mc_renderer *r)
-{
- assert(false);
-}
-#endif
-
-static void
-xfer_buffers_map(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- for (i = 0; i < 3; ++i) {
- r->tex_transfer[i] = r->pipe->get_tex_transfer
- (
- r->pipe, r->textures.all[i],
- 0, 0, 0, PIPE_TRANSFER_WRITE, 0, 0,
- r->textures.all[i]->width0, r->textures.all[i]->height0
- );
-
- r->texels[i] = r->pipe->transfer_map(r->pipe, r->tex_transfer[i]);
- }
-}
-
-static void
-xfer_buffers_unmap(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- for (i = 0; i < 3; ++i) {
- r->pipe->transfer_unmap(r->pipe, r->tex_transfer[i]);
- r->pipe->tex_transfer_destroy(r->pipe, r->tex_transfer[i]);
- }
-}
-
-static bool
-init_pipe_state(struct vl_mpeg12_mc_renderer *r)
-{
- struct pipe_sampler_state sampler;
- struct pipe_vertex_element vertex_elems[8];
- unsigned filters[5];
- unsigned i;
-
- assert(r);
-
- r->viewport.scale[0] = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- r->viewport.scale[1] = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
- r->viewport.scale[2] = 1;
- r->viewport.scale[3] = 1;
- r->viewport.translate[0] = 0;
- r->viewport.translate[1] = 0;
- r->viewport.translate[2] = 0;
- r->viewport.translate[3] = 0;
-
- r->scissor.maxx = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- r->scissor.maxy = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
-
- r->fb_state.width = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- r->fb_state.height = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
- r->fb_state.nr_cbufs = 1;
- r->fb_state.zsbuf = NULL;
-
- /* Luma filter */
- filters[0] = PIPE_TEX_FILTER_NEAREST;
- /* Chroma filters */
- if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_444 ||
- r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE) {
- filters[1] = PIPE_TEX_FILTER_NEAREST;
- filters[2] = PIPE_TEX_FILTER_NEAREST;
- }
- else {
- filters[1] = PIPE_TEX_FILTER_LINEAR;
- filters[2] = PIPE_TEX_FILTER_LINEAR;
- }
- /* Fwd, bkwd ref filters */
- filters[3] = PIPE_TEX_FILTER_LINEAR;
- filters[4] = PIPE_TEX_FILTER_LINEAR;
-
- for (i = 0; i < 5; ++i) {
- sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
- sampler.min_img_filter = filters[i];
- sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
- sampler.mag_img_filter = filters[i];
- sampler.compare_mode = PIPE_TEX_COMPARE_NONE;
- sampler.compare_func = PIPE_FUNC_ALWAYS;
- sampler.normalized_coords = 1;
- /*sampler.shadow_ambient = ; */
- /*sampler.lod_bias = ; */
- sampler.min_lod = 0;
- /*sampler.max_lod = ; */
- /*sampler.border_color[i] = ; */
- /*sampler.max_anisotropy = ; */
- r->samplers.all[i] = r->pipe->create_sampler_state(r->pipe, &sampler);
- }
-
- /* Position element */
- vertex_elems[0].src_offset = 0;
- vertex_elems[0].instance_divisor = 0;
- vertex_elems[0].vertex_buffer_index = 0;
- vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Luma, texcoord element */
- vertex_elems[1].src_offset = sizeof(struct vertex2f);
- vertex_elems[1].instance_divisor = 0;
- vertex_elems[1].vertex_buffer_index = 0;
- vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Chroma Cr texcoord element */
- vertex_elems[2].src_offset = sizeof(struct vertex2f) * 2;
- vertex_elems[2].instance_divisor = 0;
- vertex_elems[2].vertex_buffer_index = 0;
- vertex_elems[2].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Chroma Cb texcoord element */
- vertex_elems[3].src_offset = sizeof(struct vertex2f) * 3;
- vertex_elems[3].instance_divisor = 0;
- vertex_elems[3].vertex_buffer_index = 0;
- vertex_elems[3].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* First ref surface top field texcoord element */
- vertex_elems[4].src_offset = 0;
- vertex_elems[4].instance_divisor = 0;
- vertex_elems[4].vertex_buffer_index = 1;
- vertex_elems[4].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* First ref surface bottom field texcoord element */
- vertex_elems[5].src_offset = sizeof(struct vertex2f);
- vertex_elems[5].instance_divisor = 0;
- vertex_elems[5].vertex_buffer_index = 1;
- vertex_elems[5].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Second ref surface top field texcoord element */
- vertex_elems[6].src_offset = 0;
- vertex_elems[6].instance_divisor = 0;
- vertex_elems[6].vertex_buffer_index = 2;
- vertex_elems[6].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* Second ref surface bottom field texcoord element */
- vertex_elems[7].src_offset = sizeof(struct vertex2f);
- vertex_elems[7].instance_divisor = 0;
- vertex_elems[7].vertex_buffer_index = 2;
- vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT;
-
- /* need versions with 4,6 and 8 vertex elems */
- r->vertex_elems[0] = r->pipe->create_vertex_elements_state(r->pipe, 4, vertex_elems);
- r->vertex_elems[1] = r->pipe->create_vertex_elements_state(r->pipe, 6, vertex_elems);
- r->vertex_elems[2] = r->pipe->create_vertex_elements_state(r->pipe, 8, vertex_elems);
-
- return true;
-}
-
-static void
-cleanup_pipe_state(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- for (i = 0; i < 5; ++i)
- r->pipe->delete_sampler_state(r->pipe, r->samplers.all[i]);
- for (i = 0; i < 3; i++)
- r->pipe->delete_vertex_elements_state(r->pipe, r->vertex_elems[i]);
-}
-
-static bool
-init_shaders(struct vl_mpeg12_mc_renderer *r)
-{
- assert(r);
-
- create_intra_vert_shader(r);
- create_intra_frag_shader(r);
- create_frame_pred_vert_shader(r);
- create_frame_pred_frag_shader(r);
- create_frame_bi_pred_vert_shader(r);
- create_frame_bi_pred_frag_shader(r);
-
- return true;
-}
-
-static void
-cleanup_shaders(struct vl_mpeg12_mc_renderer *r)
-{
- assert(r);
-
- r->pipe->delete_vs_state(r->pipe, r->i_vs);
- r->pipe->delete_fs_state(r->pipe, r->i_fs);
- r->pipe->delete_vs_state(r->pipe, r->p_vs[0]);
- r->pipe->delete_fs_state(r->pipe, r->p_fs[0]);
- r->pipe->delete_vs_state(r->pipe, r->b_vs[0]);
- r->pipe->delete_fs_state(r->pipe, r->b_fs[0]);
-}
-
-static bool
-init_buffers(struct vl_mpeg12_mc_renderer *r)
-{
- struct pipe_texture template;
-
- const unsigned mbw =
- align(r->picture_width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH;
- const unsigned mbh =
- align(r->picture_height, MACROBLOCK_HEIGHT) / MACROBLOCK_HEIGHT;
-
- unsigned i;
-
- assert(r);
-
- r->macroblocks_per_batch =
- mbw * (r->bufmode == VL_MPEG12_MC_RENDERER_BUFFER_PICTURE ? mbh : 1);
- r->num_macroblocks = 0;
- r->macroblock_buf = MALLOC(r->macroblocks_per_batch * sizeof(struct pipe_mpeg12_macroblock));
-
- memset(&template, 0, sizeof(struct pipe_texture));
- template.target = PIPE_TEXTURE_2D;
- /* TODO: Accomodate HW that can't do this and also for cases when this isn't precise enough */
- template.format = PIPE_FORMAT_R16_SNORM;
- template.last_level = 0;
- template.width0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_width) : r->picture_width;
- template.height0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_height) : r->picture_height;
- template.depth0 = 1;
- template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_DYNAMIC;
-
- r->textures.individual.y = r->pipe->screen->texture_create(r->pipe->screen, &template);
-
- if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420) {
- template.width0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_width / 2) :
- r->picture_width / 2;
- template.height0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_height / 2) :
- r->picture_height / 2;
- }
- else if (r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_422)
- template.height0 = r->pot_buffers ?
- util_next_power_of_two(r->picture_height / 2) :
- r->picture_height / 2;
-
- r->textures.individual.cb =
- r->pipe->screen->texture_create(r->pipe->screen, &template);
- r->textures.individual.cr =
- r->pipe->screen->texture_create(r->pipe->screen, &template);
-
- r->vertex_bufs.individual.ycbcr.stride = sizeof(struct vertex2f) * 4;
- r->vertex_bufs.individual.ycbcr.max_index = 24 * r->macroblocks_per_batch - 1;
- r->vertex_bufs.individual.ycbcr.buffer_offset = 0;
- r->vertex_bufs.individual.ycbcr.buffer = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex2f) * 4 * 24 * r->macroblocks_per_batch
- );
-
- for (i = 1; i < 3; ++i) {
- r->vertex_bufs.all[i].stride = sizeof(struct vertex2f) * 2;
- r->vertex_bufs.all[i].max_index = 24 * r->macroblocks_per_batch - 1;
- r->vertex_bufs.all[i].buffer_offset = 0;
- r->vertex_bufs.all[i].buffer = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex2f) * 2 * 24 * r->macroblocks_per_batch
- );
- }
-
- r->vs_const_buf = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_CONSTANT | PIPE_BUFFER_USAGE_DISCARD,
- sizeof(struct vertex_shader_consts)
- );
-
- r->fs_const_buf = pipe_buffer_create
- (
- r->pipe->screen,
- DEFAULT_BUF_ALIGNMENT,
- PIPE_BUFFER_USAGE_CONSTANT, sizeof(struct fragment_shader_consts)
- );
-
- memcpy
- (
- pipe_buffer_map(r->pipe->screen, r->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
- &fs_consts, sizeof(struct fragment_shader_consts)
- );
-
- pipe_buffer_unmap(r->pipe->screen, r->fs_const_buf);
-
- return true;
-}
-
-static void
-cleanup_buffers(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned i;
-
- assert(r);
-
- pipe_buffer_reference(&r->vs_const_buf, NULL);
- pipe_buffer_reference(&r->fs_const_buf, NULL);
-
- for (i = 0; i < 3; ++i)
- pipe_buffer_reference(&r->vertex_bufs.all[i].buffer, NULL);
-
- for (i = 0; i < 3; ++i)
- pipe_texture_reference(&r->textures.all[i], NULL);
-
- FREE(r->macroblock_buf);
-}
-
-static enum MACROBLOCK_TYPE
-get_macroblock_type(struct pipe_mpeg12_macroblock *mb)
-{
- assert(mb);
-
- switch (mb->mb_type) {
- case PIPE_MPEG12_MACROBLOCK_TYPE_INTRA:
- return MACROBLOCK_TYPE_INTRA;
- case PIPE_MPEG12_MACROBLOCK_TYPE_FWD:
- return mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME ?
- MACROBLOCK_TYPE_FWD_FRAME_PRED : MACROBLOCK_TYPE_FWD_FIELD_PRED;
- case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
- return mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME ?
- MACROBLOCK_TYPE_BKWD_FRAME_PRED : MACROBLOCK_TYPE_BKWD_FIELD_PRED;
- case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
- return mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME ?
- MACROBLOCK_TYPE_BI_FRAME_PRED : MACROBLOCK_TYPE_BI_FIELD_PRED;
- default:
- assert(0);
- }
-
- /* Unreachable */
- return -1;
-}
-
-/* XXX: One of these days this will have to be killed with fire */
-#define SET_BLOCK(vb, cbp, mbx, mby, unitx, unity, ofsx, ofsy, hx, hy, lm, cbm, crm, use_zb, zb) \
- do { \
- (vb)[0].pos.x = (mbx) * (unitx) + (ofsx); (vb)[0].pos.y = (mby) * (unity) + (ofsy); \
- (vb)[1].pos.x = (mbx) * (unitx) + (ofsx); (vb)[1].pos.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].pos.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].pos.y = (mby) * (unity) + (ofsy); \
- (vb)[3].pos.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].pos.y = (mby) * (unity) + (ofsy); \
- (vb)[4].pos.x = (mbx) * (unitx) + (ofsx); (vb)[4].pos.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].pos.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].pos.y = (mby) * (unity) + (ofsy) + (hy); \
- \
- if (!use_zb || (cbp) & (lm)) \
- { \
- (vb)[0].luma_tc.x = (mbx) * (unitx) + (ofsx); (vb)[0].luma_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[1].luma_tc.x = (mbx) * (unitx) + (ofsx); (vb)[1].luma_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].luma_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].luma_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[3].luma_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].luma_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[4].luma_tc.x = (mbx) * (unitx) + (ofsx); (vb)[4].luma_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].luma_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].luma_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- } \
- else \
- { \
- (vb)[0].luma_tc.x = (zb)[0].x; (vb)[0].luma_tc.y = (zb)[0].y; \
- (vb)[1].luma_tc.x = (zb)[0].x; (vb)[1].luma_tc.y = (zb)[0].y + (hy); \
- (vb)[2].luma_tc.x = (zb)[0].x + (hx); (vb)[2].luma_tc.y = (zb)[0].y; \
- (vb)[3].luma_tc.x = (zb)[0].x + (hx); (vb)[3].luma_tc.y = (zb)[0].y; \
- (vb)[4].luma_tc.x = (zb)[0].x; (vb)[4].luma_tc.y = (zb)[0].y + (hy); \
- (vb)[5].luma_tc.x = (zb)[0].x + (hx); (vb)[5].luma_tc.y = (zb)[0].y + (hy); \
- } \
- \
- if (!use_zb || (cbp) & (cbm)) \
- { \
- (vb)[0].cb_tc.x = (mbx) * (unitx) + (ofsx); (vb)[0].cb_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[1].cb_tc.x = (mbx) * (unitx) + (ofsx); (vb)[1].cb_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].cb_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].cb_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[3].cb_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].cb_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[4].cb_tc.x = (mbx) * (unitx) + (ofsx); (vb)[4].cb_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].cb_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].cb_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- } \
- else \
- { \
- (vb)[0].cb_tc.x = (zb)[1].x; (vb)[0].cb_tc.y = (zb)[1].y; \
- (vb)[1].cb_tc.x = (zb)[1].x; (vb)[1].cb_tc.y = (zb)[1].y + (hy); \
- (vb)[2].cb_tc.x = (zb)[1].x + (hx); (vb)[2].cb_tc.y = (zb)[1].y; \
- (vb)[3].cb_tc.x = (zb)[1].x + (hx); (vb)[3].cb_tc.y = (zb)[1].y; \
- (vb)[4].cb_tc.x = (zb)[1].x; (vb)[4].cb_tc.y = (zb)[1].y + (hy); \
- (vb)[5].cb_tc.x = (zb)[1].x + (hx); (vb)[5].cb_tc.y = (zb)[1].y + (hy); \
- } \
- \
- if (!use_zb || (cbp) & (crm)) \
- { \
- (vb)[0].cr_tc.x = (mbx) * (unitx) + (ofsx); (vb)[0].cr_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[1].cr_tc.x = (mbx) * (unitx) + (ofsx); (vb)[1].cr_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[2].cr_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[2].cr_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[3].cr_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[3].cr_tc.y = (mby) * (unity) + (ofsy); \
- (vb)[4].cr_tc.x = (mbx) * (unitx) + (ofsx); (vb)[4].cr_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- (vb)[5].cr_tc.x = (mbx) * (unitx) + (ofsx) + (hx); (vb)[5].cr_tc.y = (mby) * (unity) + (ofsy) + (hy); \
- } \
- else \
- { \
- (vb)[0].cr_tc.x = (zb)[2].x; (vb)[0].cr_tc.y = (zb)[2].y; \
- (vb)[1].cr_tc.x = (zb)[2].x; (vb)[1].cr_tc.y = (zb)[2].y + (hy); \
- (vb)[2].cr_tc.x = (zb)[2].x + (hx); (vb)[2].cr_tc.y = (zb)[2].y; \
- (vb)[3].cr_tc.x = (zb)[2].x + (hx); (vb)[3].cr_tc.y = (zb)[2].y; \
- (vb)[4].cr_tc.x = (zb)[2].x; (vb)[4].cr_tc.y = (zb)[2].y + (hy); \
- (vb)[5].cr_tc.x = (zb)[2].x + (hx); (vb)[5].cr_tc.y = (zb)[2].y + (hy); \
- } \
- } while (0)
-
-static void
-gen_macroblock_verts(struct vl_mpeg12_mc_renderer *r,
- struct pipe_mpeg12_macroblock *mb, unsigned pos,
- struct vert_stream_0 *ycbcr_vb, struct vertex2f **ref_vb)
-{
- struct vertex2f mo_vec[2];
-
- unsigned i;
-
- assert(r);
- assert(mb);
- assert(ycbcr_vb);
- assert(pos < r->macroblocks_per_batch);
-
- mo_vec[1].x = 0;
- mo_vec[1].y = 0;
-
- switch (mb->mb_type) {
- case PIPE_MPEG12_MACROBLOCK_TYPE_BI:
- {
- struct vertex2f *vb;
-
- assert(ref_vb && ref_vb[1]);
-
- vb = ref_vb[1] + pos * 2 * 24;
-
- mo_vec[0].x = mb->pmv[0][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[0].y = mb->pmv[0][1][1] * 0.5f * r->surface_tex_inv_size.y;
-
- if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- }
- }
- else {
- mo_vec[1].x = mb->pmv[1][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[1].y = mb->pmv[1][1][1] * 0.5f * r->surface_tex_inv_size.y;
-
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- vb[i + 1].x = mo_vec[1].x;
- vb[i + 1].y = mo_vec[1].y;
- }
- }
-
- /* fall-through */
- }
- case PIPE_MPEG12_MACROBLOCK_TYPE_FWD:
- case PIPE_MPEG12_MACROBLOCK_TYPE_BKWD:
- {
- struct vertex2f *vb;
-
- assert(ref_vb && ref_vb[0]);
-
- vb = ref_vb[0] + pos * 2 * 24;
-
- if (mb->mb_type == PIPE_MPEG12_MACROBLOCK_TYPE_BKWD) {
- mo_vec[0].x = mb->pmv[0][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[0].y = mb->pmv[0][1][1] * 0.5f * r->surface_tex_inv_size.y;
-
- if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FIELD) {
- mo_vec[1].x = mb->pmv[1][1][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[1].y = mb->pmv[1][1][1] * 0.5f * r->surface_tex_inv_size.y;
- }
- }
- else {
- mo_vec[0].x = mb->pmv[0][0][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[0].y = mb->pmv[0][0][1] * 0.5f * r->surface_tex_inv_size.y;
-
- if (mb->mo_type == PIPE_MPEG12_MOTION_TYPE_FIELD) {
- mo_vec[1].x = mb->pmv[1][0][0] * 0.5f * r->surface_tex_inv_size.x;
- mo_vec[1].y = mb->pmv[1][0][1] * 0.5f * r->surface_tex_inv_size.y;
- }
- }
-
- if (mb->mb_type == PIPE_MPEG12_MOTION_TYPE_FRAME) {
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- }
- }
- else {
- for (i = 0; i < 24 * 2; i += 2) {
- vb[i].x = mo_vec[0].x;
- vb[i].y = mo_vec[0].y;
- vb[i + 1].x = mo_vec[1].x;
- vb[i + 1].y = mo_vec[1].y;
- }
- }
-
- /* fall-through */
- }
- case PIPE_MPEG12_MACROBLOCK_TYPE_INTRA:
- {
- const struct vertex2f unit =
- {
- r->surface_tex_inv_size.x * MACROBLOCK_WIDTH,
- r->surface_tex_inv_size.y * MACROBLOCK_HEIGHT
- };
- const struct vertex2f half =
- {
- r->surface_tex_inv_size.x * (MACROBLOCK_WIDTH / 2),
- r->surface_tex_inv_size.y * (MACROBLOCK_HEIGHT / 2)
- };
- const bool use_zb = r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE;
-
- struct vert_stream_0 *vb = ycbcr_vb + pos * 24;
-
- SET_BLOCK(vb, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, 0, 0, half.x, half.y,
- 32, 2, 1, use_zb, r->zero_block);
-
- SET_BLOCK(vb + 6, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, half.x, 0, half.x, half.y,
- 16, 2, 1, use_zb, r->zero_block);
-
- SET_BLOCK(vb + 12, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, 0, half.y, half.x, half.y,
- 8, 2, 1, use_zb, r->zero_block);
-
- SET_BLOCK(vb + 18, mb->cbp, mb->mbx, mb->mby,
- unit.x, unit.y, half.x, half.y, half.x, half.y,
- 4, 2, 1, use_zb, r->zero_block);
-
- break;
- }
- default:
- assert(0);
- }
-}
-
-static void
-gen_macroblock_stream(struct vl_mpeg12_mc_renderer *r,
- unsigned *num_macroblocks)
-{
- unsigned offset[NUM_MACROBLOCK_TYPES];
- struct vert_stream_0 *ycbcr_vb;
- struct vertex2f *ref_vb[2];
- unsigned i;
-
- assert(r);
- assert(num_macroblocks);
-
- for (i = 0; i < r->num_macroblocks; ++i) {
- enum MACROBLOCK_TYPE mb_type = get_macroblock_type(&r->macroblock_buf[i]);
- ++num_macroblocks[mb_type];
- }
-
- offset[0] = 0;
-
- for (i = 1; i < NUM_MACROBLOCK_TYPES; ++i)
- offset[i] = offset[i - 1] + num_macroblocks[i - 1];
-
- ycbcr_vb = (struct vert_stream_0 *)pipe_buffer_map
- (
- r->pipe->screen,
- r->vertex_bufs.individual.ycbcr.buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- for (i = 0; i < 2; ++i)
- ref_vb[i] = (struct vertex2f *)pipe_buffer_map
- (
- r->pipe->screen,
- r->vertex_bufs.individual.ref[i].buffer,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- for (i = 0; i < r->num_macroblocks; ++i) {
- enum MACROBLOCK_TYPE mb_type = get_macroblock_type(&r->macroblock_buf[i]);
-
- gen_macroblock_verts(r, &r->macroblock_buf[i], offset[mb_type],
- ycbcr_vb, ref_vb);
-
- ++offset[mb_type];
- }
-
- pipe_buffer_unmap(r->pipe->screen, r->vertex_bufs.individual.ycbcr.buffer);
- for (i = 0; i < 2; ++i)
- pipe_buffer_unmap(r->pipe->screen, r->vertex_bufs.individual.ref[i].buffer);
-}
-
-static void
-flush(struct vl_mpeg12_mc_renderer *r)
-{
- unsigned num_macroblocks[NUM_MACROBLOCK_TYPES] = { 0 };
- unsigned vb_start = 0;
- struct vertex_shader_consts *vs_consts;
- unsigned i;
-
- assert(r);
- assert(r->num_macroblocks == r->macroblocks_per_batch);
-
- gen_macroblock_stream(r, num_macroblocks);
-
- r->fb_state.cbufs[0] = r->pipe->screen->get_tex_surface
- (
- r->pipe->screen, r->surface,
- 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE
- );
-
- r->pipe->set_framebuffer_state(r->pipe, &r->fb_state);
- r->pipe->set_viewport_state(r->pipe, &r->viewport);
- r->pipe->set_scissor_state(r->pipe, &r->scissor);
-
- vs_consts = pipe_buffer_map
- (
- r->pipe->screen, r->vs_const_buf,
- PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
- );
-
- vs_consts->denorm.x = r->surface->width0;
- vs_consts->denorm.y = r->surface->height0;
-
- pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf);
-
- r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0,
- r->vs_const_buf);
- r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_FRAGMENT, 0,
- r->fs_const_buf);
-
- if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[0]);
- r->pipe->set_fragment_sampler_textures(r->pipe, 3, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 3, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->i_vs);
- r->pipe->bind_fs_state(r->pipe, r->i_fs);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_INTRA] * 24;
- }
-
- if (num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->past;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FRAME_PRED] * 24;
- }
-
- if (false /*num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] > 0 */ ) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->past;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_FWD_FIELD_PRED] * 24;
- }
-
- if (num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[0]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[0]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FRAME_PRED] * 24;
- }
-
- if (false /*num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] > 0 */ ) {
- r->pipe->set_vertex_buffers(r->pipe, 2, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[1]);
- r->textures.individual.ref[0] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 4, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 4, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->p_vs[1]);
- r->pipe->bind_fs_state(r->pipe, r->p_fs[1]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BKWD_FIELD_PRED] * 24;
- }
-
- if (num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] > 0) {
- r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[2]);
- r->textures.individual.ref[0] = r->past;
- r->textures.individual.ref[1] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->b_vs[0]);
- r->pipe->bind_fs_state(r->pipe, r->b_fs[0]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FRAME_PRED] * 24;
- }
-
- if (false /*num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] > 0 */ ) {
- r->pipe->set_vertex_buffers(r->pipe, 3, r->vertex_bufs.all);
- r->pipe->bind_vertex_elements_state(r->pipe, r->vertex_elems[2]);
- r->textures.individual.ref[0] = r->past;
- r->textures.individual.ref[1] = r->future;
- r->pipe->set_fragment_sampler_textures(r->pipe, 5, r->textures.all);
- r->pipe->bind_fragment_sampler_states(r->pipe, 5, r->samplers.all);
- r->pipe->bind_vs_state(r->pipe, r->b_vs[1]);
- r->pipe->bind_fs_state(r->pipe, r->b_fs[1]);
-
- r->pipe->draw_arrays(r->pipe, PIPE_PRIM_TRIANGLES, vb_start,
- num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24);
- vb_start += num_macroblocks[MACROBLOCK_TYPE_BI_FIELD_PRED] * 24;
- }
-
- r->pipe->flush(r->pipe, PIPE_FLUSH_RENDER_CACHE, r->fence);
- pipe_surface_reference(&r->fb_state.cbufs[0], NULL);
-
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE)
- for (i = 0; i < 3; ++i)
- r->zero_block[i].x = ZERO_BLOCK_NIL;
-
- r->num_macroblocks = 0;
-}
-
-static void
-grab_frame_coded_block(short *src, short *dst, unsigned dst_pitch)
-{
- unsigned y;
-
- assert(src);
- assert(dst);
-
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- memcpy(dst + y * dst_pitch, src + y * BLOCK_WIDTH, BLOCK_WIDTH * 2);
-}
-
-static void
-grab_field_coded_block(short *src, short *dst, unsigned dst_pitch)
-{
- unsigned y;
-
- assert(src);
- assert(dst);
-
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- memcpy(dst + y * dst_pitch * 2, src + y * BLOCK_WIDTH, BLOCK_WIDTH * 2);
-}
-
-static void
-fill_zero_block(short *dst, unsigned dst_pitch)
-{
- unsigned y;
-
- assert(dst);
-
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- memset(dst + y * dst_pitch, 0, BLOCK_WIDTH * 2);
-}
-
-static void
-grab_blocks(struct vl_mpeg12_mc_renderer *r, unsigned mbx, unsigned mby,
- enum pipe_mpeg12_dct_type dct_type, unsigned cbp, short *blocks)
-{
- unsigned tex_pitch;
- short *texels;
- unsigned tb = 0, sb = 0;
- unsigned mbpx = mbx * MACROBLOCK_WIDTH, mbpy = mby * MACROBLOCK_HEIGHT;
- unsigned x, y;
-
- assert(r);
- assert(blocks);
-
- tex_pitch = r->tex_transfer[0]->stride / util_format_get_blocksize(r->tex_transfer[0]->texture->format);
- texels = r->texels[0] + mbpy * tex_pitch + mbpx;
-
- for (y = 0; y < 2; ++y) {
- for (x = 0; x < 2; ++x, ++tb) {
- if ((cbp >> (5 - tb)) & 1) {
- if (dct_type == PIPE_MPEG12_DCT_TYPE_FRAME) {
- grab_frame_coded_block(blocks + sb * BLOCK_WIDTH * BLOCK_HEIGHT,
- texels + y * tex_pitch * BLOCK_WIDTH +
- x * BLOCK_WIDTH, tex_pitch);
- }
- else {
- grab_field_coded_block(blocks + sb * BLOCK_WIDTH * BLOCK_HEIGHT,
- texels + y * tex_pitch + x * BLOCK_WIDTH,
- tex_pitch);
- }
-
- ++sb;
- }
- else if (r->eb_handling != VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE) {
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL ||
- ZERO_BLOCK_IS_NIL(r->zero_block[0])) {
- fill_zero_block(texels + y * tex_pitch * BLOCK_WIDTH + x * BLOCK_WIDTH, tex_pitch);
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE) {
- r->zero_block[0].x = (mbpx + x * 8) * r->surface_tex_inv_size.x;
- r->zero_block[0].y = (mbpy + y * 8) * r->surface_tex_inv_size.y;
- }
- }
- }
- }
- }
-
- /* TODO: Implement 422, 444 */
- assert(r->chroma_format == PIPE_VIDEO_CHROMA_FORMAT_420);
-
- mbpx /= 2;
- mbpy /= 2;
-
- for (tb = 0; tb < 2; ++tb) {
- tex_pitch = r->tex_transfer[tb + 1]->stride / util_format_get_blocksize(r->tex_transfer[tb + 1]->texture->format);
- texels = r->texels[tb + 1] + mbpy * tex_pitch + mbpx;
-
- if ((cbp >> (1 - tb)) & 1) {
- grab_frame_coded_block(blocks + sb * BLOCK_WIDTH * BLOCK_HEIGHT, texels, tex_pitch);
- ++sb;
- }
- else if (r->eb_handling != VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE) {
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL ||
- ZERO_BLOCK_IS_NIL(r->zero_block[tb + 1])) {
- fill_zero_block(texels, tex_pitch);
- if (r->eb_handling == VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE) {
- r->zero_block[tb + 1].x = (mbpx << 1) * r->surface_tex_inv_size.x;
- r->zero_block[tb + 1].y = (mbpy << 1) * r->surface_tex_inv_size.y;
- }
- }
- }
- }
-}
-
-static void
-grab_macroblock(struct vl_mpeg12_mc_renderer *r,
- struct pipe_mpeg12_macroblock *mb)
-{
- assert(r);
- assert(mb);
- assert(r->num_macroblocks < r->macroblocks_per_batch);
-
- memcpy(&r->macroblock_buf[r->num_macroblocks], mb,
- sizeof(struct pipe_mpeg12_macroblock));
-
- grab_blocks(r, mb->mbx, mb->mby, mb->dct_type, mb->cbp, mb->blocks);
-
- ++r->num_macroblocks;
-}
-
-bool
-vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
- struct pipe_context *pipe,
- unsigned picture_width,
- unsigned picture_height,
- enum pipe_video_chroma_format chroma_format,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
- enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
- bool pot_buffers)
-{
- unsigned i;
-
- assert(renderer);
- assert(pipe);
- /* TODO: Implement other policies */
- assert(bufmode == VL_MPEG12_MC_RENDERER_BUFFER_PICTURE);
- /* TODO: Implement this */
- /* XXX: XFER_ALL sampling issue at block edges when using bilinear filtering */
- assert(eb_handling != VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE);
- /* TODO: Non-pot buffers untested, probably doesn't work without changes to texcoord generation, vert shader, etc */
- assert(pot_buffers);
-
- memset(renderer, 0, sizeof(struct vl_mpeg12_mc_renderer));
-
- renderer->pipe = pipe;
- renderer->picture_width = picture_width;
- renderer->picture_height = picture_height;
- renderer->chroma_format = chroma_format;
- renderer->bufmode = bufmode;
- renderer->eb_handling = eb_handling;
- renderer->pot_buffers = pot_buffers;
-
- if (!init_pipe_state(renderer))
- return false;
- if (!init_shaders(renderer)) {
- cleanup_pipe_state(renderer);
- return false;
- }
- if (!init_buffers(renderer)) {
- cleanup_shaders(renderer);
- cleanup_pipe_state(renderer);
- return false;
- }
-
- renderer->surface = NULL;
- renderer->past = NULL;
- renderer->future = NULL;
- for (i = 0; i < 3; ++i)
- renderer->zero_block[i].x = ZERO_BLOCK_NIL;
- renderer->num_macroblocks = 0;
-
- xfer_buffers_map(renderer);
-
- return true;
-}
-
-void
-vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer)
-{
- assert(renderer);
-
- xfer_buffers_unmap(renderer);
-
- cleanup_pipe_state(renderer);
- cleanup_shaders(renderer);
- cleanup_buffers(renderer);
-}
-
-void
-vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer
- *renderer,
- struct pipe_texture *surface,
- struct pipe_texture *past,
- struct pipe_texture *future,
- unsigned num_macroblocks,
- struct pipe_mpeg12_macroblock
- *mpeg12_macroblocks,
- struct pipe_fence_handle **fence)
-{
- bool new_surface = false;
-
- assert(renderer);
- assert(surface);
- assert(num_macroblocks);
- assert(mpeg12_macroblocks);
-
- if (renderer->surface) {
- if (surface != renderer->surface) {
- if (renderer->num_macroblocks > 0) {
- xfer_buffers_unmap(renderer);
- flush(renderer);
- }
-
- new_surface = true;
- }
-
- /* If the surface we're rendering hasn't changed the ref frames shouldn't change. */
- assert(surface != renderer->surface || renderer->past == past);
- assert(surface != renderer->surface || renderer->future == future);
- }
- else
- new_surface = true;
-
- if (new_surface) {
- renderer->surface = surface;
- renderer->past = past;
- renderer->future = future;
- renderer->fence = fence;
- renderer->surface_tex_inv_size.x = 1.0f / surface->width0;
- renderer->surface_tex_inv_size.y = 1.0f / surface->height0;
- }
-
- while (num_macroblocks) {
- unsigned left_in_batch = renderer->macroblocks_per_batch - renderer->num_macroblocks;
- unsigned num_to_submit = MIN2(num_macroblocks, left_in_batch);
- unsigned i;
-
- for (i = 0; i < num_to_submit; ++i) {
- assert(mpeg12_macroblocks[i].base.codec == PIPE_VIDEO_CODEC_MPEG12);
- grab_macroblock(renderer, &mpeg12_macroblocks[i]);
- }
-
- num_macroblocks -= num_to_submit;
-
- if (renderer->num_macroblocks == renderer->macroblocks_per_batch) {
- xfer_buffers_unmap(renderer);
- flush(renderer);
- xfer_buffers_map(renderer);
- /* Next time we get this surface it may have new ref frames */
- renderer->surface = NULL;
- }
- }
-}
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h b/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
deleted file mode 100644
index a11a3e7307..0000000000
--- a/src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_mpeg12_mc_renderer_h
-#define vl_mpeg12_mc_renderer_h
-
-#include <pipe/p_compiler.h>
-#include <pipe/p_state.h>
-#include <pipe/p_video_state.h>
-
-struct pipe_context;
-struct pipe_video_surface;
-struct pipe_macroblock;
-
-/* A slice is video-width (rounded up to a multiple of macroblock width) x macroblock height */
-enum VL_MPEG12_MC_RENDERER_BUFFER_MODE
-{
- VL_MPEG12_MC_RENDERER_BUFFER_SLICE, /* Saves memory at the cost of smaller batches */
- VL_MPEG12_MC_RENDERER_BUFFER_PICTURE /* Larger batches, more memory */
-};
-
-enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK
-{
- VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ALL, /* Waste of memory bandwidth */
- VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE, /* Can only do point-filtering when interpolating subsampled chroma channels */
- VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_NONE /* Needs conditional texel fetch! */
-};
-
-struct vl_mpeg12_mc_renderer
-{
- struct pipe_context *pipe;
- unsigned picture_width;
- unsigned picture_height;
- enum pipe_video_chroma_format chroma_format;
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode;
- enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling;
- bool pot_buffers;
- unsigned macroblocks_per_batch;
-
- struct pipe_viewport_state viewport;
- struct pipe_scissor_state scissor;
- struct pipe_buffer *vs_const_buf;
- struct pipe_buffer *fs_const_buf;
- struct pipe_framebuffer_state fb_state;
- void *vertex_elems[3];
-
- union
- {
- void *all[5];
- struct { void *y, *cb, *cr, *ref[2]; } individual;
- } samplers;
-
- void *i_vs, *p_vs[2], *b_vs[2];
- void *i_fs, *p_fs[2], *b_fs[2];
-
- union
- {
- struct pipe_texture *all[5];
- struct { struct pipe_texture *y, *cb, *cr, *ref[2]; } individual;
- } textures;
-
- union
- {
- struct pipe_vertex_buffer all[3];
- struct { struct pipe_vertex_buffer ycbcr, ref[2]; } individual;
- } vertex_bufs;
-
- struct pipe_texture *surface, *past, *future;
- struct pipe_fence_handle **fence;
- unsigned num_macroblocks;
- struct pipe_mpeg12_macroblock *macroblock_buf;
- struct pipe_transfer *tex_transfer[3];
- short *texels[3];
- struct { float x, y; } surface_tex_inv_size;
- struct { float x, y; } zero_block[3];
-};
-
-bool vl_mpeg12_mc_renderer_init(struct vl_mpeg12_mc_renderer *renderer,
- struct pipe_context *pipe,
- unsigned picture_width,
- unsigned picture_height,
- enum pipe_video_chroma_format chroma_format,
- enum VL_MPEG12_MC_RENDERER_BUFFER_MODE bufmode,
- enum VL_MPEG12_MC_RENDERER_EMPTY_BLOCK eb_handling,
- bool pot_buffers);
-
-void vl_mpeg12_mc_renderer_cleanup(struct vl_mpeg12_mc_renderer *renderer);
-
-void vl_mpeg12_mc_renderer_render_macroblocks(struct vl_mpeg12_mc_renderer *renderer,
- struct pipe_texture *surface,
- struct pipe_texture *past,
- struct pipe_texture *future,
- unsigned num_macroblocks,
- struct pipe_mpeg12_macroblock *mpeg12_macroblocks,
- struct pipe_fence_handle **fence);
-
-#endif /* vl_mpeg12_mc_renderer_h */
diff --git a/src/gallium/auxiliary/vl/vl_shader_build.c b/src/gallium/auxiliary/vl/vl_shader_build.c
deleted file mode 100644
index d011ef97bd..0000000000
--- a/src/gallium/auxiliary/vl/vl_shader_build.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "vl_shader_build.h"
-#include <assert.h>
-#include <tgsi/tgsi_parse.h>
-#include <tgsi/tgsi_build.h>
-
-struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl.Declaration.File = TGSI_FILE_INPUT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_interpolated_input
-(
- unsigned int name,
- unsigned int index,
- unsigned int first,
- unsigned int last,
- int interpolation
-)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- assert
- (
- interpolation == TGSI_INTERPOLATE_CONSTANT ||
- interpolation == TGSI_INTERPOLATE_LINEAR ||
- interpolation == TGSI_INTERPOLATE_PERSPECTIVE
- );
-
- decl.Declaration.File = TGSI_FILE_INPUT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Declaration.Interpolate = interpolation;;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl.Declaration.File = TGSI_FILE_CONSTANT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl.Declaration.File = TGSI_FILE_OUTPUT;
- decl.Declaration.Semantic = 1;
- decl.Semantic.Name = name;
- decl.Semantic.Index = index;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last)
-{
- struct tgsi_full_declaration decl = tgsi_default_full_declaration();
-
- decl = tgsi_default_full_declaration();
- decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.Range.First = first;
- decl.Range.Last = last;
-
- return decl;
-}
-
-struct tgsi_full_instruction vl_inst2
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src_file,
- unsigned int src_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = opcode;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 1;
- inst.Src[0].Register.File = src_file;
- inst.Src[0].Register.Index = src_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_inst3
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = opcode;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 2;
- inst.Src[0].Register.File = src1_file;
- inst.Src[0].Register.Index = src1_index;
- inst.Src[1].Register.File = src2_file;
- inst.Src[1].Register.Index = src2_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_tex
-(
- int tex,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = TGSI_OPCODE_TEX;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 2;
- inst.Instruction.Texture = 1;
- inst.Texture.Texture = tex;
- inst.Src[0].Register.File = src1_file;
- inst.Src[0].Register.Index = src1_index;
- inst.Src[1].Register.File = src2_file;
- inst.Src[1].Register.Index = src2_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_inst4
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index,
- enum tgsi_file_type src3_file,
- unsigned int src3_index
-)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = opcode;
- inst.Instruction.NumDstRegs = 1;
- inst.Dst[0].Register.File = dst_file;
- inst.Dst[0].Register.Index = dst_index;
- inst.Instruction.NumSrcRegs = 3;
- inst.Src[0].Register.File = src1_file;
- inst.Src[0].Register.Index = src1_index;
- inst.Src[1].Register.File = src2_file;
- inst.Src[1].Register.Index = src2_index;
- inst.Src[2].Register.File = src3_file;
- inst.Src[2].Register.Index = src3_index;
-
- return inst;
-}
-
-struct tgsi_full_instruction vl_end(void)
-{
- struct tgsi_full_instruction inst = tgsi_default_full_instruction();
-
- inst.Instruction.Opcode = TGSI_OPCODE_END;
- inst.Instruction.NumDstRegs = 0;
- inst.Instruction.NumSrcRegs = 0;
-
- return inst;
-}
diff --git a/src/gallium/auxiliary/vl/vl_shader_build.h b/src/gallium/auxiliary/vl/vl_shader_build.h
deleted file mode 100644
index 5da71f8e13..0000000000
--- a/src/gallium/auxiliary/vl/vl_shader_build.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_shader_build_h
-#define vl_shader_build_h
-
-#include <pipe/p_shader_tokens.h>
-
-struct tgsi_full_declaration vl_decl_input(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_interpolated_input
-(
- unsigned int name,
- unsigned int index,
- unsigned int first,
- unsigned int last,
- int interpolation
-);
-struct tgsi_full_declaration vl_decl_constants(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_output(unsigned int name, unsigned int index, unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_temps(unsigned int first, unsigned int last);
-struct tgsi_full_declaration vl_decl_samplers(unsigned int first, unsigned int last);
-struct tgsi_full_instruction vl_inst2
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src_file,
- unsigned int src_index
-);
-struct tgsi_full_instruction vl_inst3
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-);
-struct tgsi_full_instruction vl_tex
-(
- int tex,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index
-);
-struct tgsi_full_instruction vl_inst4
-(
- int opcode,
- enum tgsi_file_type dst_file,
- unsigned int dst_index,
- enum tgsi_file_type src1_file,
- unsigned int src1_index,
- enum tgsi_file_type src2_file,
- unsigned int src2_index,
- enum tgsi_file_type src3_file,
- unsigned int src3_index
-);
-struct tgsi_full_instruction vl_end(void);
-
-#endif
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index 2b0941010b..7439d10097 100644
--- a/src/gallium/docs/source/context.rst
+++ b/src/gallium/docs/source/context.rst
@@ -239,9 +239,7 @@ Flushing
Resource Busy Queries
^^^^^^^^^^^^^^^^^^^^^
-``is_texture_referenced``
-
-``is_buffer_referenced``
+``is_resource_referenced``
@@ -265,3 +263,51 @@ The interfaces to these calls are likely to change to make it easier
for a driver to batch multiple blits with the same source and
destination.
+
+Transfers
+^^^^^^^^^
+
+These methods are used to get data to/from a resource.
+
+``get_transfer`` creates a transfer object.
+
+``transfer_destroy`` destroys the transfer object. May cause
+data to be written to the resource at this point.
+
+``transfer_map`` creates a memory mapping for the transfer object.
+The returned map points to the start of the mapped range according to
+the box region, not the beginning of the resource.
+
+.. _transfer_flush_region:
+``transfer_flush_region`` If a transfer was created with TRANFER_FLUSH_EXPLICIT,
+only the region specified is guaranteed to be written to. This is relative to
+the mapped range, not the beginning of the resource.
+
+``transfer_unmap`` remove the memory mapping for the transfer object.
+Any pointers into the map should be considered invalid and discarded.
+
+``transfer_inline_write`` performs a simplified transfer for simple writes.
+Basically get_transfer, transfer_map, data write, transfer_unmap, and
+transfer_destroy all in one.
+
+.. _pipe_transfer:
+
+PIPE_TRANSFER
+^^^^^^^^^^^^^
+
+These flags control the behavior of a transfer object.
+
+* ``READ``: resource contents are read at transfer create time.
+* ``WRITE``: resource contents will be written back at transfer destroy time.
+* ``MAP_DIRECTLY``: a transfer should directly map the resource. May return
+ NULL if not supported.
+* ``DISCARD``: The memory within the mapped region is discarded.
+ Cannot be used with ``READ``.
+* ``DONTBLOCK``: Fail if the resource cannot be mapped immediately.
+* ``UNSYNCHRONIZED``: Do not synchronize pending operations on the resource
+ when mapping. The interaction of any writes to the map and any
+ operations pending on the resource are undefined. Cannot be used with
+ ``READ``.
+* ``FLUSH_EXPLICIT``: Written ranges will be notified later with
+ :ref:`transfer_flush_region`. Cannot be used with
+ ``READ``.
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index e78634e59e..b6efd1d40c 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -103,59 +103,47 @@ For backwards compatibility, one-dimensional access to CONST register
file is still supported. In that case, the constbuf index is assumed
to be 0.
-.. _pipe_buffer_usage:
+.. _pipe_bind:
-PIPE_BUFFER_USAGE
-^^^^^^^^^^^^^^^^^
+PIPE_BIND
+^^^^^^^^^
-These flags control buffer creation. Buffers may only have one role, so
-care should be taken to not allocate a buffer with the wrong usage.
-
-* ``PIXEL``: This is the flag to use for all textures.
-* ``VERTEX``: A vertex buffer.
-* ``INDEX``: An element buffer.
-* ``CONSTANT``: A buffer of shader constants.
-
-Buffers are inevitably abstracting the pipe's underlying memory management,
-so many of their usage flags can be used to direct the way the buffer is
-handled.
-
-* ``CPU_READ``, ``CPU_WRITE``: Whether the user will map and, in the case of
- the latter, write to, the buffer. The convenience flag ``CPU_READ_WRITE`` is
- available to signify a read/write buffer.
-* ``GPU_READ``, ``GPU_WRITE``: Whether the driver will internally need to
- read from or write to the buffer. The latter will only happen if the buffer
- is made into a render target.
-* ``DISCARD``: When set on a map, the contents of the map will be discarded
- beforehand. Cannot be used with ``CPU_READ``.
-* ``DONTBLOCK``: When set on a map, the map will fail if the buffer cannot be
- mapped immediately.
-* ``UNSYNCHRONIZED``: When set on a map, any outstanding operations on the
- buffer will be ignored. The interaction of any writes to the map and any
- operations pending with the buffer are undefined. Cannot be used with
- ``CPU_READ``.
-* ``FLUSH_EXPLICIT``: When set on a map, written ranges of the map require
- explicit flushes using :ref:`buffer_flush_mapped_range`. Requires
- ``CPU_WRITE``.
-
-.. _pipe_texture_usage:
-
-PIPE_TEXTURE_USAGE
-^^^^^^^^^^^^^^^^^^
-
-These flags determine the possible roles a texture may be used for during its
-lifetime. Texture usage flags are cumulative and may be combined to create a
-texture that can be used as multiple things.
+These flags control resource creation. Resources may be used in different roles
+during their lifecycle. Bind flags are cumulative and may be combined to create
+a resource which can be used as multiple things.
+Depending on the pipe driver's memory management, depending on these bind flags
+resources might be created and handled quite differently.
* ``RENDER_TARGET``: A color buffer or pixel buffer which will be rendered to.
* ``DISPLAY_TARGET``: A sharable buffer that can be given to another process.
-* ``PRIMARY``: A front color buffer or scanout buffer.
* ``DEPTH_STENCIL``: A depth (Z) buffer or stencil buffer. Gallium does
not explicitly provide for stencil-only buffers, so any stencil buffer
validated here is implicitly also a depth buffer.
-* ``SAMPLER``: A texture that may be sampled from in a fragment or vertex
+* ``SAMPLER_VIEW``: A texture that may be sampled from in a fragment or vertex
shader.
-* ``DYNAMIC``: A texture that will be mapped frequently.
+* ``VERTEX_BUFFER``: A vertex buffer.
+* ``INDEX_BUFFER``: An element buffer.
+* ``CONSTANT_BUFFER``: A buffer of shader constants.
+* ``BLIT_SOURCE``: A blit source, as given to surface_copy.
+* ``BLIT_DESTINATION``: A blit destination, as given to surface_copy and surface_fill.
+* ``TRANSFER_WRITE``: A transfer object which will be written to.
+* ``TRANSFER_READ``: A transfer object which will be read from.
+* ``CUSTOM``:
+* ``SCANOUT``: A front color buffer or scanout buffer.
+* ``SHARED``:
+
+.. _pipe_usage:
+
+PIPE_USAGE
+^^^^^^^^^^
+
+The PIPE_USAGE enums are hints about the expected lifecycle of a resource.
+* ``DEFAULT``: Expect many uploads to the resource, intermixed with draws.
+* ``DYNAMIC``: Expect many uploads to the resource, intermixed with draws.
+* ``STATIC``: Same as immutable (?)
+* ``IMMUTABLE``: Resource will not be changed after first upload.
+* ``STREAM``: Upload will be followed by draw, followed by upload, ...
+
PIPE_TEXTURE_GEOM
@@ -218,64 +206,23 @@ is_format_supported
See if a format can be used in a specific manner.
-**usage** is a bitmask of :ref:`PIPE_TEXTURE_USAGE` flags.
+**tex_usage** is a bitmask of :ref:`PIPE_BIND` flags.
Returns TRUE if all usages can be satisfied.
-.. note::
-
- ``PIPE_TEXTURE_USAGE_DYNAMIC`` is not a valid usage.
-.. _texture_create:
+.. _resource_create:
-texture_create
+resource_create
^^^^^^^^^^^^^^
-Given a template of texture setup, create a buffer and texture.
+Given a template of texture setup, create a resource.
+The way a resource may be used is specifed by bind flags, :ref:`pipe_bind`.
+and hints are used to indicate to the driver what access pattern might be
+likely, :ref:`pipe_usage`.
-texture_blanket
+resource_destroy
^^^^^^^^^^^^^^^
-Like :ref:`texture_create`, but use a supplied buffer instead of creating a
-new one.
-
-texture_destroy
-^^^^^^^^^^^^^^^
-
-Destroy a texture. The buffer backing the texture is destroyed if it has no
-more references.
-
-buffer_map
-^^^^^^^^^^
-
-Map a buffer into memory.
-
-**usage** is a bitmask of :ref:`PIPE_BUFFER_USAGE` flags.
-
-Returns a pointer to the map, or NULL if the mapping failed.
-
-buffer_map_range
-^^^^^^^^^^^^^^^^
-
-Map a range of a buffer into memory.
-
-The returned map is always relative to the beginning of the buffer, not the
-beginning of the mapped range.
-
-.. _buffer_flush_mapped_range:
-
-buffer_flush_mapped_range
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Flush a range of mapped memory into a buffer.
-
-The buffer must have been mapped with ``PIPE_BUFFER_USAGE_FLUSH_EXPLICIT``.
-
-**usage** is a bitmask of :ref:`PIPE_BUFFER_USAGE` flags.
-
-buffer_unmap
-^^^^^^^^^^^^
-
-Unmap a buffer from memory.
+Destroy a resource. A resource is destroyed if it has no more references.
-Any pointers into the map should be considered invalid and discarded.
diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile
index 8769b826b5..c92f8e5cba 100644
--- a/src/gallium/drivers/cell/ppu/Makefile
+++ b/src/gallium/drivers/cell/ppu/Makefile
@@ -21,7 +21,6 @@ SPU_CODE_MODULE = ../spu/g3d_spu.a
SOURCES = \
cell_batch.c \
- cell_buffer.c \
cell_clear.c \
cell_context.c \
cell_draw_arrays.c \
diff --git a/src/gallium/drivers/cell/ppu/cell_buffer.c b/src/gallium/drivers/cell/ppu/cell_buffer.c
deleted file mode 100644
index f56a28d62e..0000000000
--- a/src/gallium/drivers/cell/ppu/cell_buffer.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_math.h"
-
-#include "cell_screen.h"
-#include "cell_buffer.h"
-
-
-static void *
-cell_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- struct cell_buffer *cell_buf = cell_buffer(buf);
- return cell_buf->data;
-}
-
-
-static void
-cell_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
-{
-}
-
-
-static void
-cell_buffer_destroy(struct pipe_buffer *buf)
-{
- struct cell_buffer *sbuf = cell_buffer(buf);
-
- if (!sbuf->userBuffer)
- align_free(sbuf->data);
-
- FREE(sbuf);
-}
-
-
-static struct pipe_buffer *
-cell_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct cell_buffer *buffer = CALLOC_STRUCT(cell_buffer);
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.screen = screen;
- buffer->base.alignment = MAX2(alignment, 16);
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- buffer->data = align_malloc(size, alignment);
-
- return &buffer->base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-cell_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct cell_buffer *buffer;
-
- buffer = CALLOC_STRUCT(cell_buffer);
- if(!buffer)
- return NULL;
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.screen = screen;
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
-
- return &buffer->base;
-}
-
-
-void
-cell_init_screen_buffer_funcs(struct pipe_screen *screen)
-{
- screen->buffer_create = cell_buffer_create;
- screen->user_buffer_create = cell_user_buffer_create;
- screen->buffer_map = cell_buffer_map;
- screen->buffer_unmap = cell_buffer_unmap;
- screen->buffer_destroy = cell_buffer_destroy;
-}
diff --git a/src/gallium/drivers/cell/ppu/cell_buffer.h b/src/gallium/drivers/cell/ppu/cell_buffer.h
deleted file mode 100644
index ef0a8a70e5..0000000000
--- a/src/gallium/drivers/cell/ppu/cell_buffer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef SP_BUFFER_H
-#define SP_BUFFER_H
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-
-struct cell_buffer
-{
- struct pipe_buffer base;
- boolean userBuffer; /** Is this a user-space buffer? */
- void *data;
-};
-
-
-/** Cast wrapper */
-static INLINE struct cell_buffer *
-cell_buffer( struct pipe_buffer *buf )
-{
- return (struct cell_buffer *)buf;
-}
-
-
-void
-cell_init_screen_buffer_funcs(struct pipe_screen *screen);
-
-
-#endif /* SP_BUFFER_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index f6cb1fc9be..49cece58b8 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -99,8 +99,8 @@ static const struct debug_named_value cell_debug_flags[] = {
};
static unsigned int
-cell_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
+cell_is_resource_referenced( struct pipe_context *pipe,
+ struct pipe_resource *texture,
unsigned face, unsigned level)
{
/**
@@ -110,16 +110,6 @@ cell_is_texture_referenced( struct pipe_context *pipe,
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
-static unsigned int
-cell_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /**
- * FIXME: Optimize.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
struct pipe_context *
cell_create_context(struct pipe_screen *screen,
@@ -144,8 +134,7 @@ cell_create_context(struct pipe_screen *screen,
cell->pipe.clear = cell_clear;
cell->pipe.flush = cell_flush;
- cell->pipe.is_texture_referenced = cell_is_texture_referenced;
- cell->pipe.is_buffer_referenced = cell_is_buffer_referenced;
+ cell->pipe.is_resource_referenced = cell_is_resource_referenced;
#if 0
cell->pipe.begin_query = cell_begin_query;
diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h
index f7e2284445..07b6eebc69 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.h
+++ b/src/gallium/drivers/cell/ppu/cell_context.h
@@ -122,11 +122,11 @@ struct cell_context
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
- struct pipe_buffer *constants[2];
+ struct pipe_resource *constants[2];
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct cell_texture *texture[PIPE_MAX_SAMPLERS];
+ struct cell_resource *texture[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
uint num_textures;
struct pipe_viewport_state viewport;
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
index 15d4e8338f..80e94a79df 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
@@ -39,7 +39,7 @@
#include "cell_draw_arrays.h"
#include "cell_state.h"
#include "cell_flush.h"
-#include "cell_buffer.h"
+#include "cell_texture.h"
#include "draw/draw_context.h"
@@ -57,7 +57,7 @@
*/
static void
cell_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
@@ -78,12 +78,12 @@ cell_draw_range_elements(struct pipe_context *pipe,
* Map vertex buffers
*/
for (i = 0; i < cell->num_vertex_buffers; i++) {
- void *buf = cell_buffer(cell->vertex_buffer[i].buffer)->data;
+ void *buf = cell_resource(cell->vertex_buffer[i].buffer)->data;
draw_set_mapped_vertex_buffer(draw, i, buf);
}
/* Map index buffer, if present */
if (indexBuffer) {
- void *mapped_indexes = cell_buffer(indexBuffer)->data;
+ void *mapped_indexes = cell_resource(indexBuffer)->data;
draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
}
else {
@@ -116,7 +116,7 @@ cell_draw_range_elements(struct pipe_context *pipe,
static void
cell_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
diff --git a/src/gallium/drivers/cell/ppu/cell_fence.c b/src/gallium/drivers/cell/ppu/cell_fence.c
index 035ef41b89..eac798e8cf 100644
--- a/src/gallium/drivers/cell/ppu/cell_fence.c
+++ b/src/gallium/drivers/cell/ppu/cell_fence.c
@@ -82,7 +82,7 @@ cell_fence_finish(const struct cell_context *cell,
struct cell_buffer_node
{
- struct pipe_buffer *buffer;
+ struct pipe_resource *buffer;
struct cell_buffer_node *next;
};
@@ -90,12 +90,12 @@ struct cell_buffer_node
static void
cell_add_buffer_to_list(struct cell_context *cell,
struct cell_buffer_list *list,
- struct pipe_buffer *buffer)
+ struct pipe_resource *buffer)
{
struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node);
/* create new list node which references the buffer, insert at head */
if (node) {
- pipe_buffer_reference(&node->buffer, buffer);
+ pipe_resource_reference(&node->buffer, buffer);
node->next = list->head;
list->head = node;
}
@@ -129,7 +129,7 @@ cell_free_fenced_buffers(struct cell_context *cell,
if (node->buffer->reference.count == 1)
printf(" Delete!\n");
#endif
- pipe_buffer_reference(&node->buffer, NULL);
+ pipe_resource_reference(&node->buffer, NULL);
FREE(node);
node = next;
}
@@ -150,7 +150,7 @@ cell_add_fenced_textures(struct cell_context *cell)
uint i;
for (i = 0; i < cell->num_textures; i++) {
- struct cell_texture *ct = cell->texture[i];
+ struct cell_resource *ct = cell->texture[i];
if (ct) {
#if 0
printf("Adding texture %p buffer %p to list\n",
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 059ce8597b..8c975c6ae2 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -271,12 +271,12 @@ cell_set_fragment_sampler_views(struct pipe_context *pipe,
struct pipe_sampler_view *old_view = cell->fragment_sampler_views[i];
if (old_view != new_view) {
- struct pipe_texture *new_tex = new_view ? new_view->texture : NULL;
+ struct pipe_resource *new_tex = new_view ? new_view->texture : NULL;
pipe_sampler_view_reference(&cell->fragment_sampler_views[i],
views[i]);
- pipe_texture_reference((struct pipe_texture **) &cell->texture[i],
- (struct pipe_texture *) new_tex);
+ pipe_resource_reference((struct pipe_resource **) &cell->texture[i],
+ (struct pipe_resource *) new_tex);
changed |= (1 << i);
}
@@ -293,7 +293,7 @@ cell_set_fragment_sampler_views(struct pipe_context *pipe,
static struct pipe_sampler_view *
cell_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -302,7 +302,7 @@ cell_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}
@@ -314,7 +314,7 @@ static void
cell_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
@@ -333,7 +333,7 @@ cell_map_surfaces(struct cell_context *cell)
for (i = 0; i < 1; i++) {
struct pipe_surface *ps = cell->framebuffer.cbufs[i];
if (ps) {
- struct cell_texture *ct = cell_texture(ps->texture);
+ struct cell_resource *ct = cell_resource(ps->texture);
#if 0
cell->cbuf_map[i] = screen->buffer_map(screen,
ct->buffer,
@@ -348,7 +348,7 @@ cell_map_surfaces(struct cell_context *cell)
{
struct pipe_surface *ps = cell->framebuffer.zsbuf;
if (ps) {
- struct cell_texture *ct = cell_texture(ps->texture);
+ struct cell_resource *ct = cell_resource(ps->texture);
#if 0
cell->zsbuf_map = screen->buffer_map(screen,
ct->buffer,
@@ -374,7 +374,7 @@ cell_unmap_surfaces(struct cell_context *cell)
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
struct pipe_surface *ps = cell->framebuffer.cbufs[i];
if (ps && cell->cbuf_map[i]) {
- /*struct cell_texture *ct = cell_texture(ps->texture);*/
+ /*struct cell_resource *ct = cell_resource(ps->texture);*/
assert(ps->texture);
/*assert(ct->buffer);*/
@@ -386,7 +386,7 @@ cell_unmap_surfaces(struct cell_context *cell)
{
struct pipe_surface *ps = cell->framebuffer.zsbuf;
if (ps && cell->zsbuf_map) {
- /*struct cell_texture *ct = cell_texture(ps->texture);*/
+ /*struct cell_resource *ct = cell_resource(ps->texture);*/
/*screen->buffer_unmap(screen, ct->buffer);*/
cell->zsbuf_map = NULL;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c
index aaa16945c5..b4fd8d7235 100644
--- a/src/gallium/drivers/cell/ppu/cell_screen.c
+++ b/src/gallium/drivers/cell/ppu/cell_screen.c
@@ -35,7 +35,6 @@
#include "cell_context.h"
#include "cell_screen.h"
#include "cell_texture.h"
-#include "cell_buffer.h"
#include "cell_public.h"
#include "state_tracker/sw_winsys.h"
@@ -138,12 +137,11 @@ cell_is_format_supported( struct pipe_screen *screen,
unsigned tex_usage,
unsigned geom_flags )
{
-
struct sw_winsys *winsys = cell_screen(screen)->winsys;
- if (tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) {
+ if (tex_usage & (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) {
if (!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
return FALSE;
}
@@ -201,7 +199,6 @@ cell_create_screen(struct sw_winsys *winsys)
screen->base.context_create = cell_create_context;
cell_init_screen_texture_funcs(&screen->base);
- cell_init_screen_buffer_funcs(&screen->base);
return &screen->base;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c
index 424e2628a9..bb11c68fa2 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_emit.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c
@@ -241,7 +241,7 @@ cell_emit_state(struct cell_context *cell)
if (cell->dirty & (CELL_NEW_FS_CONSTANTS)) {
const uint shader = PIPE_SHADER_FRAGMENT;
- const uint num_const = cell->constants[shader]->size / sizeof(float);
+ const uint num_const = cell->constants[shader]->width0 / sizeof(float);
uint i, j;
float *buf = cell_batch_alloc16(cell, ROUNDUP16(32 + num_const * sizeof(float)));
uint32_t *ibuf = (uint32_t *) buf;
@@ -293,7 +293,7 @@ cell_emit_state(struct cell_context *cell)
texture->opcode[0] = CELL_CMD_STATE_TEXTURE;
texture->unit = i;
if (cell->texture[i]) {
- struct cell_texture *ct = cell->texture[i];
+ struct cell_resource *ct = cell->texture[i];
uint level;
for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
texture->start[level] = (ct->mapped +
diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index 9e29ddc2d4..ddf1477268 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -34,7 +34,7 @@
#include "cell_context.h"
#include "cell_state.h"
#include "cell_gen_fp.h"
-#include "cell_buffer.h"
+#include "cell_texture.h"
/** cast wrapper */
@@ -183,11 +183,11 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs)
static void
cell_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *constants)
+ struct pipe_resource *constants)
{
struct cell_context *cell = cell_context(pipe);
- unsigned size = constants ? constants->size : 0;
- const void *data = constants ? cell_buffer(constants)->data : NULL;
+ unsigned size = constants ? constants->width0 : 0;
+ const void *data = constants ? cell_resource(constants)->data : NULL;
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
@@ -198,7 +198,7 @@ cell_set_constant_buffer(struct pipe_context *pipe,
draw_flush(cell->draw);
/* note: reference counting */
- pipe_buffer_reference(&cell->constants[shader], constants);
+ pipe_resource_reference(&cell->constants[shader], constants);
if(shader == PIPE_SHADER_VERTEX) {
draw_set_mapped_constant_buffer(cell->draw, PIPE_SHADER_VERTEX, 0,
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 6d746ebe0a..8a379154d1 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -42,17 +42,17 @@
#include "cell_context.h"
#include "cell_screen.h"
#include "cell_state.h"
-#include "cell_texture.h"
+#include "cell_resource.h"
#include "state_tracker/sw_winsys.h"
static boolean
-cell_texture_layout(struct pipe_screen *screen,
- struct cell_texture *ct)
+cell_resource_layout(struct pipe_screen *screen,
+ struct cell_resource *ct)
{
- struct pipe_texture *pt = &ct->base;
+ struct pipe_resource *pt = &ct->base;
unsigned level;
unsigned width = pt->width0;
unsigned height = pt->height0;
@@ -98,14 +98,14 @@ cell_texture_layout(struct pipe_screen *screen,
*/
static boolean
cell_displaytarget_layout(struct pipe_screen *screen,
- struct cell_texture * ct)
+ struct cell_resource * ct)
{
struct sw_winsys *winsys = cell_screen(screen)->winsys;
/* Round up the surface size to a multiple of the tile size?
*/
ct->dt = winsys->displaytarget_create(winsys,
- ct->base.tex_usage,
+ ct->base.bind,
ct->base.format,
ct->base.width0,
ct->base.height0,
@@ -115,11 +115,11 @@ cell_displaytarget_layout(struct pipe_screen *screen,
return ct->dt != NULL;
}
-static struct pipe_texture *
-cell_texture_create(struct pipe_screen *screen,
- const struct pipe_texture *templat)
+static struct pipe_resource *
+cell_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *templat)
{
- struct cell_texture *ct = CALLOC_STRUCT(cell_texture);
+ struct cell_resource *ct = CALLOC_STRUCT(cell_resource);
if (!ct)
return NULL;
@@ -130,14 +130,14 @@ cell_texture_create(struct pipe_screen *screen,
/* Create both a displaytarget (linear) and regular texture
* (twiddled). Convert twiddled->linear at flush_frontbuffer time.
*/
- if (ct->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) {
+ if (ct->base.bind & (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) {
if (!cell_displaytarget_layout(screen, ct))
goto fail;
}
- if (!cell_texture_layout(screen, ct))
+ if (!cell_resource_layout(screen, ct))
goto fail;
return &ct->base;
@@ -155,18 +155,19 @@ fail:
static void
-cell_texture_destroy(struct pipe_texture *pt)
+cell_resource_destroy(struct pipe_resource *pt)
{
struct cell_screen *screen = cell_screen(pt->screen);
struct sw_winsys *winsys = screen->winsys;
- struct cell_texture *ct = cell_texture(pt);
+ struct cell_resource *ct = cell_resource(pt);
if (ct->dt) {
/* display target */
winsys->displaytarget_destroy(winsys, ct->dt);
}
-
- align_free(ct->data);
+ else if (!ct->userBuffer) {
+ align_free(ct->data);
+ }
FREE(ct);
}
@@ -304,17 +305,17 @@ untwiddle_image_uint(uint w, uint h, uint tile_size, uint *dst,
static struct pipe_surface *
cell_get_tex_surface(struct pipe_screen *screen,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned face, unsigned level, unsigned zslice,
unsigned usage)
{
- struct cell_texture *ct = cell_texture(pt);
+ struct cell_resource *ct = cell_resource(pt);
struct pipe_surface *ps;
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
pipe_reference_init(&ps->reference, 1);
- pipe_texture_reference(&ps->texture, pt);
+ pipe_resource_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = u_minify(pt->width0, level);
ps->height = u_minify(pt->height0, level);
@@ -345,7 +346,7 @@ cell_get_tex_surface(struct pipe_screen *screen,
static void
cell_tex_surface_destroy(struct pipe_surface *surf)
{
- pipe_texture_reference(&surf->texture, NULL);
+ pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
}
@@ -356,46 +357,48 @@ cell_tex_surface_destroy(struct pipe_surface *surf)
* back out for glGetTexImage).
*/
static struct pipe_transfer *
-cell_get_tex_transfer(struct pipe_context *ctx,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
+cell_get_transfer(struct pipe_context *ctx,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
- struct cell_texture *ct = cell_texture(texture);
+ struct cell_resource *ct = cell_resource(resource);
struct cell_transfer *ctrans;
+ enum pipe_format *format = resource->format;
+
+ assert(resource);
+ assert(level <= resource->last_level);
- assert(texture);
- assert(level <= texture->last_level);
+ /* make sure the requested region is in the image bounds */
+ assert(box->x + box->width <= u_minify(resource->width0, sr.level));
+ assert(box->y + box->height <= u_minify(resource->height0, sr.level));
+ assert(box->z + box->depth <= u_minify(resource->depth0, sr.level));
ctrans = CALLOC_STRUCT(cell_transfer);
if (ctrans) {
struct pipe_transfer *pt = &ctrans->base;
- pipe_texture_reference(&pt->texture, texture);
- pt->x = x;
- pt->y = y;
- pt->width = w;
- pt->height = h;
- pt->stride = ct->stride[level];
+ pipe_resource_reference(&pt->resource, resource);
+ pt->sr = sr;
pt->usage = usage;
- pt->face = face;
- pt->level = level;
- pt->zslice = zslice;
+ pt->box = *box;
+ pt->stride = ct->stride[sr.level];
- ctrans->offset = ct->level_offset[level];
+ ctrans->offset = ct->level_offset[sr.level];
- if (texture->target == PIPE_TEXTURE_CUBE) {
- unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
- ctrans->offset += face * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
+ if (resource->target == PIPE_TEXTURE_CUBE) {
+ unsigned h_tile = align(u_minify(resource->height0, sr.level), TILE_SIZE);
+ ctrans->offset += sr.face * util_format_get_nblocksy(format, h_tile) * pt->stride;
}
- else if (texture->target == PIPE_TEXTURE_3D) {
- unsigned h_tile = align(u_minify(texture->height0, level), TILE_SIZE);
- ctrans->offset += zslice * util_format_get_nblocksy(texture->format, h_tile) * pt->stride;
+ else if (resource->target == PIPE_TEXTURE_3D) {
+ unsigned h_tile = align(u_minify(resource->height0, sr.level), TILE_SIZE);
+ ctrans->offset += box->z * util_format_get_nblocksy(format, h_tile) * pt->stride;
}
else {
- assert(face == 0);
- assert(zslice == 0);
+ assert(sr.face == 0);
+ assert(box->z == 0);
}
+
return pt;
}
return NULL;
@@ -403,15 +406,15 @@ cell_get_tex_transfer(struct pipe_context *ctx,
static void
-cell_tex_transfer_destroy(struct pipe_context *ctx, struct pipe_transfer *t)
+cell_transfer_destroy(struct pipe_context *ctx, struct pipe_transfer *t)
{
struct cell_transfer *transfer = cell_transfer(t);
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For cell, nothing to do.
*/
- assert (transfer->base.texture);
- pipe_texture_reference(&transfer->base.texture, NULL);
+ assert (transfer->base.resource);
+ pipe_resource_reference(&transfer->base.resource, NULL);
FREE(transfer);
}
@@ -423,44 +426,63 @@ static void *
cell_transfer_map(struct pipe_context *ctx, struct pipe_transfer *transfer)
{
struct cell_transfer *ctrans = cell_transfer(transfer);
- struct pipe_texture *pt = transfer->texture;
- struct cell_texture *ct = cell_texture(pt);
- const uint level = ctrans->base.level;
- const uint texWidth = u_minify(pt->width0, level);
- const uint texHeight = u_minify(pt->height0, level);
- const uint stride = ct->stride[level];
- unsigned size;
+ struct pipe_resource *pt = transfer->resource;
+ struct cell_resource *ct = cell_resource(pt);
- assert(transfer->texture);
+ assert(transfer->resource);
if (ct->mapped == NULL) {
ct->mapped = ct->data;
}
- /*
- * Create a buffer of ordinary memory for the linear texture.
- * This is the memory that the user will read/write.
+
+ /* Better test would be resource->is_linear
*/
- size = util_format_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
- util_format_get_nblocksy(pt->format, align(texHeight, TILE_SIZE));
-
- ctrans->map = align_malloc(size, 16);
- if (!ctrans->map)
- return NULL; /* out of memory */
-
- if (transfer->usage & PIPE_TRANSFER_READ) {
- /* need to untwiddle the texture to make a linear version */
- const uint bpp = util_format_get_blocksize(ct->base.format);
- if (bpp == 4) {
- const uint *src = (uint *) (ct->mapped + ctrans->offset);
- uint *dst = ctrans->map;
- untwiddle_image_uint(texWidth, texHeight, TILE_SIZE,
- dst, stride, src);
- }
- else {
- // xxx fix
+ if (transfer->resource->target != PIPE_BUFFER) {
+ const uint level = ctrans->base.sr.level;
+ const uint texWidth = u_minify(pt->width0, level);
+ const uint texHeight = u_minify(pt->height0, level);
+ unsigned size;
+
+
+ /*
+ * Create a buffer of ordinary memory for the linear texture.
+ * This is the memory that the user will read/write.
+ */
+ size = (util_format_get_stride(pt->format, align(texWidth, TILE_SIZE)) *
+ util_format_get_nblocksy(pt->format, align(texHeight, TILE_SIZE)));
+
+ ctrans->map = align_malloc(size, 16);
+ if (!ctrans->map)
+ return NULL; /* out of memory */
+
+ if (transfer->usage & PIPE_TRANSFER_READ) {
+ /* Textures always stored twiddled, need to untwiddle the
+ * texture to make a linear version.
+ */
+ const uint bpp = util_format_get_blocksize(ct->base.format);
+ if (bpp == 4) {
+ const uint *src = (uint *) (ct->mapped + ctrans->offset);
+ uint *dst = ctrans->map;
+ untwiddle_image_uint(texWidth, texHeight, TILE_SIZE,
+ dst, transfer->stride, src);
+ }
+ else {
+ // xxx fix
+ }
}
}
+ else {
+ unsigned stride = transfer->stride;
+ enum pipe_format format = pt->format;
+ unsigned blocksize = util_format_get_blocksize(format);
+
+ ctrans->map = (ct->mapped +
+ ctrans->offset +
+ ctrans->base.box.y / util_format_get_blockheight(format) * stride +
+ ctrans->base.box.x / util_format_get_blockwidth(format) * blocksize);
+ }
+
return ctrans->map;
}
@@ -476,9 +498,9 @@ cell_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer)
{
struct cell_transfer *ctrans = cell_transfer(transfer);
- struct pipe_texture *pt = transfer->texture;
- struct cell_texture *ct = cell_texture(pt);
- const uint level = ctrans->base.level;
+ struct pipe_resource *pt = transfer->resource;
+ struct cell_resource *ct = cell_resource(pt);
+ const uint level = ctrans->base.sr.level;
const uint texWidth = u_minify(pt->width0, level);
const uint texHeight = u_minify(pt->height0, level);
const uint stride = ct->stride[level];
@@ -488,22 +510,28 @@ cell_transfer_unmap(struct pipe_context *ctx,
return;
}
- if (transfer->usage & PIPE_TRANSFER_WRITE) {
- /* The user wrote new texture data into the mapped buffer.
- * We need to convert the new linear data into the twiddled/tiled format.
- */
- const uint bpp = util_format_get_blocksize(ct->base.format);
- if (bpp == 4) {
- const uint *src = ctrans->map;
- uint *dst = (uint *) (ct->mapped + ctrans->offset);
- twiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst, stride, src);
- }
- else {
- // xxx fix
+ if (pt->target != PIPE_BUFFER) {
+ if (transfer->usage & PIPE_TRANSFER_WRITE) {
+ /* The user wrote new texture data into the mapped buffer.
+ * We need to convert the new linear data into the twiddled/tiled format.
+ */
+ const uint bpp = util_format_get_blocksize(ct->base.format);
+ if (bpp == 4) {
+ const uint *src = ctrans->map;
+ uint *dst = (uint *) (ct->mapped + ctrans->offset);
+ twiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst, stride, src);
+ }
+ else {
+ // xxx fix
+ }
}
+
+ align_free(ctrans->map);
+ }
+ else {
+ /* nothing to do */
}
- align_free(ctrans->map);
ctrans->map = NULL;
}
@@ -525,7 +553,7 @@ cell_flush_frontbuffer(struct pipe_screen *_screen,
{
struct cell_screen *screen = cell_screen(_screen);
struct sw_winsys *winsys = screen->winsys;
- struct cell_texture *ct = cell_texture(surface->texture);
+ struct cell_resource *ct = cell_resource(surface->texture);
if (!ct->dt)
return;
@@ -534,8 +562,8 @@ cell_flush_frontbuffer(struct pipe_screen *_screen,
*/
{
unsigned *map = winsys->displaytarget_map(winsys, ct->dt,
- (PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE));
+ (PIPE_TRANSFER_READ |
+ PIPE_TRANSFER_WRITE));
unsigned *src = (unsigned *)(ct->data + ct->level_offset[surface->level]);
untwiddle_image_uint(surface->width,
@@ -552,11 +580,48 @@ cell_flush_frontbuffer(struct pipe_screen *_screen,
}
+
+/**
+ * Create buffer which wraps user-space data.
+ */
+static struct pipe_resource *
+cell_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind_flags)
+{
+ struct cell_resource *buffer;
+
+ buffer = CALLOC_STRUCT(cell_resource);
+ if(!buffer)
+ return NULL;
+
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.screen = screen;
+ buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */
+ buffer->base.bind = PIPE_BIND_TRANSFER_READ | bind_flags;
+ buffer->base._usage = PIPE_USAGE_IMMUTABLE;
+ buffer->base.flags = 0;
+ buffer->base.width0 = bytes;
+ buffer->base.height0 = 1;
+ buffer->base.depth0 = 1;
+ buffer->userBuffer = TRUE;
+ buffer->data = ptr;
+
+ return &buffer->base;
+}
+
+
+
+
void
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
- screen->texture_create = cell_texture_create;
- screen->texture_destroy = cell_texture_destroy;
+ screen->resource_create = cell_resource_create;
+ screen->resource_destroy = cell_resource_destroy;
+ screen->resource_from_handle = cell_resource_from_handle;
+ screen->resource_get_handle = cell_resource_get_handle;
+ screen->user_buffer_create = cell_user_buffer_create;
screen->get_tex_surface = cell_get_tex_surface;
screen->tex_surface_destroy = cell_tex_surface_destroy;
@@ -565,10 +630,13 @@ cell_init_screen_texture_funcs(struct pipe_screen *screen)
}
void
-cell_init_texture_transfer_funcs(struct cell_context *cell)
+cell_init_transfer_funcs(struct cell_context *cell)
{
- cell->pipe.get_tex_transfer = cell_get_tex_transfer;
- cell->pipe.tex_transfer_destroy = cell_tex_transfer_destroy;
+ cell->pipe.get_transfer = cell_get_transfer;
+ cell->pipe.transfer_destroy = cell_transfer_destroy;
cell->pipe.transfer_map = cell_transfer_map;
cell->pipe.transfer_unmap = cell_transfer_unmap;
+
+ cell->pipe.transfer_flush_region = u_default_transfer_flush_region;
+ cell->pipe.transfer_inline_write = u_default_transfer_inline_write;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index ac0b916775..bd8224b3b7 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -31,21 +31,21 @@
#include "cell/common.h"
struct cell_context;
-struct pipe_texture;
+struct pipe_resource;
/**
- * Subclass of pipe_texture
+ * Subclass of pipe_resource
*/
-struct cell_texture
+struct cell_resource
{
- struct pipe_texture base;
+ struct pipe_resource base;
unsigned long level_offset[CELL_MAX_TEXTURE_LEVELS];
unsigned long stride[CELL_MAX_TEXTURE_LEVELS];
/**
- * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET
+ * Display target, for textures with the PIPE_BIND_DISPLAY_TARGET
* usage.
*/
struct sw_displaytarget *dt;
@@ -55,6 +55,7 @@ struct cell_texture
* Malloc'ed data for regular textures, or a mapping to dt above.
*/
void *data;
+ boolean userBuffer;
/* Size of the linear buffer??
*/
@@ -77,10 +78,10 @@ struct cell_transfer
/** cast wrapper */
-static INLINE struct cell_texture *
-cell_texture(struct pipe_texture *pt)
+static INLINE struct cell_resource *
+cell_resource(struct pipe_resource *pt)
{
- return (struct cell_texture *) pt;
+ return (struct cell_resource *) pt;
}
diff --git a/src/gallium/drivers/cell/spu/spu_exec.h b/src/gallium/drivers/cell/spu/spu_exec.h
index 0ca92af248..da9626024e 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.h
+++ b/src/gallium/drivers/cell/spu/spu_exec.h
@@ -75,7 +75,7 @@ struct softpipe_tile_cache; /**< Opaque to TGSI */
struct spu_sampler
{
const struct pipe_sampler_state *state;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
/** Get samples for four fragments in a quad */
void (*get_samples)(struct spu_sampler *sampler,
const float s[QUAD_SIZE],
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 659e40cbf0..325a100954 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -51,7 +51,7 @@ void failover_fail_over( struct failover_context *failover )
static void failover_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexResource,
unsigned indexSize,
unsigned prim,
unsigned start,
@@ -70,7 +70,7 @@ static void failover_draw_elements( struct pipe_context *pipe,
*/
if (failover->mode == FO_HW) {
failover->hw->draw_elements( failover->hw,
- indexBuffer,
+ indexResource,
indexSize,
prim,
start,
@@ -87,7 +87,7 @@ static void failover_draw_elements( struct pipe_context *pipe,
}
failover->sw->draw_elements( failover->sw,
- indexBuffer,
+ indexResource,
indexSize,
prim,
start,
@@ -109,26 +109,15 @@ static void failover_draw_arrays( struct pipe_context *pipe,
}
static unsigned int
-failover_is_texture_referenced( struct pipe_context *_pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
+failover_is_resource_referenced( struct pipe_context *_pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level)
{
struct failover_context *failover = failover_context( _pipe );
struct pipe_context *pipe = (failover->mode == FO_HW) ?
failover->hw : failover->sw;
- return pipe->is_texture_referenced(pipe, texture, face, level);
-}
-
-static unsigned int
-failover_is_buffer_referenced( struct pipe_context *_pipe,
- struct pipe_buffer *buf)
-{
- struct failover_context *failover = failover_context( _pipe );
- struct pipe_context *pipe = (failover->mode == FO_HW) ?
- failover->hw : failover->sw;
-
- return pipe->is_buffer_referenced(pipe, buf);
+ return pipe->is_resource_referenced(pipe, resource, face, level);
}
struct pipe_context *failover_create( struct pipe_context *hw,
@@ -175,8 +164,7 @@ struct pipe_context *failover_create( struct pipe_context *hw,
#endif
failover->pipe.flush = hw->flush;
- failover->pipe.is_texture_referenced = failover_is_texture_referenced;
- failover->pipe.is_buffer_referenced = failover_is_buffer_referenced;
+ failover->pipe.is_resource_referenced = failover_is_resource_referenced;
failover->dirty = 0;
diff --git a/src/gallium/drivers/failover/fo_context.h b/src/gallium/drivers/failover/fo_context.h
index 73031321d9..88ae5ad60d 100644
--- a/src/gallium/drivers/failover/fo_context.h
+++ b/src/gallium/drivers/failover/fo_context.h
@@ -134,7 +134,7 @@ failover_context( struct pipe_context *pipe )
void
failover_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *buf);
+ struct pipe_resource *resource);
#endif /* FO_CONTEXT_H */
diff --git a/src/gallium/drivers/failover/fo_state.c b/src/gallium/drivers/failover/fo_state.c
index 25c6273570..b682ce6750 100644
--- a/src/gallium/drivers/failover/fo_state.c
+++ b/src/gallium/drivers/failover/fo_state.c
@@ -449,7 +449,7 @@ failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
static struct pipe_sampler_view *
failover_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct fo_sampler_view *view = malloc(sizeof(struct fo_sampler_view));
@@ -461,7 +461,7 @@ failover_create_sampler_view(struct pipe_context *pipe,
view->base = *templ;
view->base.reference.count = 1;
view->base.texture = NULL;
- pipe_texture_reference(&view->base.texture, texture);
+ pipe_resource_reference(&view->base.texture, texture);
view->base.context = pipe;
return &view->base;
@@ -477,7 +477,7 @@ failover_sampler_view_destroy(struct pipe_context *pipe,
failover->sw->sampler_view_destroy(failover->sw, fo_view->sw);
failover->hw->sampler_view_destroy(failover->hw, fo_view->hw);
- pipe_texture_reference(&fo_view->base.texture, NULL);
+ pipe_resource_reference(&fo_view->base.texture, NULL);
free(fo_view);
}
@@ -572,15 +572,15 @@ failover_set_vertex_buffers(struct pipe_context *pipe,
void
failover_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *buf)
+ struct pipe_resource *res)
{
struct failover_context *failover = failover_context(pipe);
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
- failover->sw->set_constant_buffer(failover->sw, shader, index, buf);
- failover->hw->set_constant_buffer(failover->hw, shader, index, buf);
+ failover->sw->set_constant_buffer(failover->sw, shader, index, res);
+ failover->hw->set_constant_buffer(failover->hw, shader, index, res);
}
diff --git a/src/gallium/drivers/i915/Makefile b/src/gallium/drivers/i915/Makefile
index e33c74d02f..2cefe70850 100644
--- a/src/gallium/drivers/i915/Makefile
+++ b/src/gallium/drivers/i915/Makefile
@@ -5,7 +5,6 @@ LIBNAME = i915
C_SOURCES = \
i915_blit.c \
- i915_buffer.c \
i915_clear.c \
i915_flush.c \
i915_context.c \
@@ -20,7 +19,9 @@ C_SOURCES = \
i915_screen.c \
i915_prim_emit.c \
i915_prim_vbuf.c \
- i915_texture.c \
+ i915_resource.c \
+ i915_resource_texture.c \
+ i915_resource_buffer.c \
i915_fpc_emit.c \
i915_fpc_translate.c \
i915_surface.c
diff --git a/src/gallium/drivers/i915/SConscript b/src/gallium/drivers/i915/SConscript
index 5a1c47c88d..7b69681096 100644
--- a/src/gallium/drivers/i915/SConscript
+++ b/src/gallium/drivers/i915/SConscript
@@ -6,7 +6,7 @@ i915 = env.ConvenienceLibrary(
target = 'i915',
source = [
'i915_blit.c',
- 'i915_buffer.c',
+ 'i915_resource_buffer.c',
'i915_clear.c',
'i915_context.c',
'i915_debug.c',
@@ -24,7 +24,8 @@ i915 = env.ConvenienceLibrary(
'i915_state_immediate.c',
'i915_state_sampler.c',
'i915_surface.c',
- 'i915_texture.c',
+ 'i915_resource.c',
+ 'i915_resource_texture.c',
])
Export('i915')
diff --git a/src/gallium/drivers/i915/i915_buffer.c b/src/gallium/drivers/i915/i915_buffer.c
deleted file mode 100644
index 1247de320d..0000000000
--- a/src/gallium/drivers/i915/i915_buffer.c
+++ /dev/null
@@ -1,138 +0,0 @@
-/**************************************************************************
- *
- * Copyright © 2009 Jakob Bornecrantz
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "i915_screen.h"
-#include "i915_buffer.h"
-
-struct i915_winsys_buffer;
-
-struct i915_buffer
-{
- struct pipe_buffer base;
-
- struct i915_winsys_buffer *ibuf; /** hw buffer */
-
- void *data; /**< user and malloc data */
- boolean own; /**< we own the data incase of malloc */
-};
-
-static INLINE struct i915_buffer *
-i915_buffer(struct pipe_buffer *buffer)
-{
- return (struct i915_buffer *)buffer;
-}
-
-static struct pipe_buffer *
-i915_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer);
-
- if (!buf)
- return NULL;
-
- pipe_reference_init(&buf->base.reference, 1);
- buf->base.alignment = alignment;
- buf->base.screen = screen;
- buf->base.usage = usage;
- buf->base.size = size;
- buf->data = MALLOC(size);
- buf->own = TRUE;
-
- if (!buf->data)
- goto err;
-
- return &buf->base;
-
-err:
- FREE(buf);
- return NULL;
-}
-
-static struct pipe_buffer *
-i915_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer);
-
- if (!buf)
- return NULL;
-
- pipe_reference_init(&buf->base.reference, 1);
- buf->base.alignment = 0;
- buf->base.screen = screen;
- buf->base.usage = 0;
- buf->base.size = bytes;
- buf->data = ptr;
- buf->own = FALSE;
-
- return &buf->base;
-}
-
-static void *
-i915_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned usage)
-{
- struct i915_buffer *buf = i915_buffer(buffer);
- assert(!buf->ibuf);
- return buf->data;
-}
-
-static void
-i915_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buffer)
-{
- struct i915_buffer *buf = i915_buffer(buffer);
- assert(!buf->ibuf);
- (void) buf;
-}
-
-static void
-i915_buffer_destroy(struct pipe_buffer *buffer)
-{
- struct i915_buffer *buf = i915_buffer(buffer);
- assert(!buf->ibuf);
-
- if (buf->own)
- FREE(buf->data);
- FREE(buf);
-}
-
-void i915_init_screen_buffer_functions(struct i915_screen *screen)
-{
- screen->base.buffer_create = i915_buffer_create;
- screen->base.user_buffer_create = i915_user_buffer_create;
- screen->base.buffer_map = i915_buffer_map;
- screen->base.buffer_map_range = NULL;
- screen->base.buffer_flush_mapped_range = NULL;
- screen->base.buffer_unmap = i915_buffer_unmap;
- screen->base.buffer_destroy = i915_buffer_destroy;
-}
diff --git a/src/gallium/drivers/i915/i915_buffer.h b/src/gallium/drivers/i915/i915_buffer.h
deleted file mode 100644
index 80fda7c62f..0000000000
--- a/src/gallium/drivers/i915/i915_buffer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/**************************************************************************
- *
- * Copyright © 2009 Jakob Bornecrantz
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef I915_BUFFER_H
-#define I915_BUFFER_H
-
-void i915_init_screen_buffer_functions(struct i915_screen *screen);
-
-#endif
diff --git a/src/gallium/drivers/i915/i915_context.c b/src/gallium/drivers/i915/i915_context.c
index 130519ffa5..4ae5291115 100644
--- a/src/gallium/drivers/i915/i915_context.c
+++ b/src/gallium/drivers/i915/i915_context.c
@@ -28,7 +28,9 @@
#include "i915_context.h"
#include "i915_state.h"
#include "i915_screen.h"
+#include "i915_surface.h"
#include "i915_batch.h"
+#include "i915_resource.h"
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
@@ -44,7 +46,7 @@
static void
i915_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
@@ -61,8 +63,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
* Map vertex buffers
*/
for (i = 0; i < i915->num_vertex_buffers; i++) {
- void *buf = pipe_buffer_map(pipe->screen, i915->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ void *buf = i915_buffer(i915->vertex_buffer[i].buffer)->data;
draw_set_mapped_vertex_buffer(draw, i, buf);
}
@@ -70,8 +71,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
* Map index buffer, if present
*/
if (indexBuffer) {
- void *mapped_indexes = pipe_buffer_map(pipe->screen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ void *mapped_indexes = i915_buffer(indexBuffer)->data;
draw_set_mapped_element_buffer_range(draw, indexSize,
min_index,
max_index,
@@ -95,19 +95,17 @@ i915_draw_range_elements(struct pipe_context *pipe,
* unmap vertex/index buffers
*/
for (i = 0; i < i915->num_vertex_buffers; i++) {
- pipe_buffer_unmap(pipe->screen, i915->vertex_buffer[i].buffer);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (indexBuffer) {
- pipe_buffer_unmap(pipe->screen, indexBuffer);
- draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL);
+ draw_set_mapped_element_buffer(draw, 0, NULL);
}
}
static void
i915_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned prim, unsigned start, unsigned count)
{
@@ -125,37 +123,6 @@ i915_draw_arrays(struct pipe_context *pipe,
}
-/*
- * Is referenced functions
- */
-
-
-static unsigned int
-i915_is_texture_referenced(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- /**
- * FIXME: Return the corrent result. We can't alays return referenced
- * since it causes a double flush within the vbo module.
- */
-#if 0
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-#else
- return 0;
-#endif
-}
-
-static unsigned int
-i915_is_buffer_referenced(struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- /*
- * Since we never expose hardware buffers to the state tracker
- * they can never be referenced, so this isn't a lie
- */
- return 0;
-}
/*
@@ -204,9 +171,6 @@ i915_create_context(struct pipe_screen *screen, void *priv)
i915->base.draw_elements = i915_draw_elements;
i915->base.draw_range_elements = i915_draw_range_elements;
- i915->base.is_texture_referenced = i915_is_texture_referenced;
- i915->base.is_buffer_referenced = i915_is_buffer_referenced;
-
/*
* Create drawing context and plug our rendering stage into it.
*/
@@ -221,7 +185,7 @@ i915_create_context(struct pipe_screen *screen, void *priv)
i915_init_surface_functions(i915);
i915_init_state_functions(i915);
i915_init_flush_functions(i915);
- i915_init_texture_functions(i915);
+ i915_init_resource_functions(i915);
draw_install_aaline_stage(i915->draw, &i915->base);
draw_install_aapoint_stage(i915->draw, &i915->base);
diff --git a/src/gallium/drivers/i915/i915_context.h b/src/gallium/drivers/i915/i915_context.h
index 8df4dce865..acc0ffe037 100644
--- a/src/gallium/drivers/i915/i915_context.h
+++ b/src/gallium/drivers/i915/i915_context.h
@@ -192,35 +192,6 @@ struct i915_velems_state {
struct pipe_vertex_element velem[PIPE_MAX_ATTRIBS];
};
-#define I915_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */
-#define I915_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */
-
-struct i915_texture {
- struct pipe_texture base;
-
- /* Derived from the above:
- */
- unsigned stride;
- unsigned depth_stride; /* per-image on i945? */
- unsigned total_nblocksy;
-
- unsigned sw_tiled; /**< tiled with software flags */
- unsigned hw_tiled; /**< tiled with hardware fences */
-
- unsigned nr_images[I915_MAX_TEXTURE_2D_LEVELS];
-
- /* Explicitly store the offset of each image for each cube face or
- * depth value. Pretty much have to accept that hardware formats
- * are going to be so diverse that there is no unified way to
- * compute the offsets of depth/cube images within a mipmap level,
- * so have to store them as a lookup table:
- */
- unsigned *image_offset[I915_MAX_TEXTURE_2D_LEVELS]; /**< array [depth] of offsets */
-
- /* The data is held here:
- */
- struct i915_winsys_buffer *buffer;
-};
struct i915_context
{
@@ -243,7 +214,7 @@ struct i915_context
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
/* XXX unneded */
- struct pipe_buffer *constants[PIPE_SHADER_TYPES];
+ struct pipe_resource *constants[PIPE_SHADER_TYPES];
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
@@ -333,10 +304,8 @@ void i915_clear( struct pipe_context *pipe, unsigned buffers, const float *rgba,
/***********************************************************************
- * i915_surface.c:
+ *
*/
-void i915_init_surface_functions( struct i915_context *i915 );
-
void i915_init_state_functions( struct i915_context *i915 );
void i915_init_flush_functions( struct i915_context *i915 );
void i915_init_string_functions( struct i915_context *i915 );
@@ -349,10 +318,6 @@ struct pipe_context *i915_create_context(struct pipe_screen *screen,
void *priv);
-/***********************************************************************
- * i915_texture.c
- */
-void i915_init_texture_functions(struct i915_context *i915 );
/***********************************************************************
diff --git a/src/gallium/drivers/i915/i915_resource.c b/src/gallium/drivers/i915/i915_resource.c
new file mode 100644
index 0000000000..499233ceb9
--- /dev/null
+++ b/src/gallium/drivers/i915/i915_resource.c
@@ -0,0 +1,51 @@
+#include "util/u_debug.h"
+
+#include "i915_resource.h"
+#include "i915_context.h"
+#include "i915_screen.h"
+
+
+static struct pipe_resource *
+i915_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ if (template->target == PIPE_BUFFER)
+ return i915_buffer_create(screen, template);
+ else
+ return i915_texture_create(screen, template);
+
+}
+
+static struct pipe_resource *
+i915_resource_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
+{
+ if (template->target == PIPE_BUFFER)
+ return NULL;
+ else
+ return i915_texture_from_handle(screen, template, whandle);
+}
+
+
+void
+i915_init_resource_functions(struct i915_context *i915 )
+{
+ i915->base.is_resource_referenced = u_default_is_resource_referenced;
+ i915->base.get_transfer = u_get_transfer_vtbl;
+ i915->base.transfer_map = u_transfer_map_vtbl;
+ i915->base.transfer_flush_region = u_transfer_flush_region_vtbl;
+ i915->base.transfer_unmap = u_transfer_unmap_vtbl;
+ i915->base.transfer_destroy = u_transfer_destroy_vtbl;
+ i915->base.transfer_inline_write = u_transfer_inline_write_vtbl;
+}
+
+void
+i915_init_screen_resource_functions(struct i915_screen *is)
+{
+ is->base.resource_create = i915_resource_create;
+ is->base.resource_from_handle = i915_resource_from_handle;
+ is->base.resource_get_handle = u_resource_get_handle_vtbl;
+ is->base.resource_destroy = u_resource_destroy_vtbl;
+ is->base.user_buffer_create = i915_user_buffer_create;
+}
diff --git a/src/gallium/drivers/i915/i915_resource.h b/src/gallium/drivers/i915/i915_resource.h
new file mode 100644
index 0000000000..e595139584
--- /dev/null
+++ b/src/gallium/drivers/i915/i915_resource.h
@@ -0,0 +1,114 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef I915_RESOURCE_H
+#define I915_RESOURCE_H
+
+struct i915_screen;
+
+#include "util/u_transfer.h"
+#include "util/u_debug.h"
+
+
+struct i915_context;
+struct i915_screen;
+
+
+struct i915_buffer {
+ struct u_resource b;
+ uint8_t *data;
+ boolean free_on_destroy;
+};
+
+#define I915_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */
+#define I915_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */
+
+
+
+struct i915_texture {
+ struct u_resource b;
+
+ unsigned stride;
+ unsigned depth_stride; /* per-image on i945? */
+ unsigned total_nblocksy;
+
+ unsigned sw_tiled; /**< tiled with software flags */
+ unsigned hw_tiled; /**< tiled with hardware fences */
+
+ unsigned nr_images[I915_MAX_TEXTURE_2D_LEVELS];
+
+ /* Explicitly store the offset of each image for each cube face or
+ * depth value.
+ */
+ unsigned *image_offset[I915_MAX_TEXTURE_2D_LEVELS]; /**< array [depth] of offsets */
+
+ /* The data is held here:
+ */
+ struct i915_winsys_buffer *buffer;
+};
+
+void i915_init_screen_resource_functions(struct i915_screen *is);
+void i915_init_resource_functions(struct i915_context *i915 );
+
+extern struct u_resource_vtbl i915_buffer_vtbl;
+extern struct u_resource_vtbl i915_texture_vtbl;
+
+static INLINE struct i915_texture *i915_texture( struct pipe_resource *resource )
+{
+ struct i915_texture *tex = (struct i915_texture *)resource;
+ assert(tex->b.vtbl == &i915_texture_vtbl);
+ return tex;
+}
+
+static INLINE struct i915_buffer *i915_buffer( struct pipe_resource *resource )
+{
+ struct i915_buffer *tex = (struct i915_buffer *)resource;
+ assert(tex->b.vtbl == &i915_buffer_vtbl);
+ return tex;
+}
+
+struct pipe_resource *
+i915_texture_create(struct pipe_screen *screen,
+ const struct pipe_resource *template);
+
+struct pipe_resource *
+i915_texture_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle);
+
+
+struct pipe_resource *
+i915_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage);
+
+struct pipe_resource *
+i915_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template);
+
+#endif /* I915_RESOURCE_H */
diff --git a/src/gallium/drivers/i915/i915_resource_buffer.c b/src/gallium/drivers/i915/i915_resource_buffer.c
new file mode 100644
index 0000000000..3f3c658e47
--- /dev/null
+++ b/src/gallium/drivers/i915/i915_resource_buffer.c
@@ -0,0 +1,162 @@
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+ /*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Michel Dänzer <michel@tungstengraphics.com>
+ */
+
+#include "pipe/p_context.h"
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "i915_context.h"
+#include "i915_resource.h"
+#include "i915_screen.h"
+
+
+
+static boolean
+i915_buffer_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ return FALSE;
+}
+
+static void
+i915_buffer_destroy(struct pipe_screen *screen,
+ struct pipe_resource *resource)
+{
+ struct i915_buffer *buffer = i915_buffer(resource);
+ if (buffer->free_on_destroy)
+ align_free(buffer->data);
+ FREE(buffer);
+}
+
+
+static void *
+i915_buffer_transfer_map( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct i915_buffer *buffer = i915_buffer(transfer->resource);
+ return buffer->data + transfer->box.x;
+}
+
+
+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 i915_buffer *buffer = i915_buffer(resource);
+
+ memcpy(buffer->data + box->x,
+ data,
+ box->width);
+}
+
+
+struct u_resource_vtbl i915_buffer_vtbl =
+{
+ i915_buffer_get_handle, /* get_handle */
+ i915_buffer_destroy, /* resource_destroy */
+ NULL, /* is_resource_referenced */
+ u_default_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ i915_buffer_transfer_map, /* transfer_map */
+ u_default_transfer_flush_region, /* transfer_flush_region */
+ u_default_transfer_unmap, /* transfer_unmap */
+ i915_buffer_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+struct pipe_resource *
+i915_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer);
+
+ if (!buf)
+ return NULL;
+
+ buf->b.b = *template;
+ 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;
+
+ if (!buf->data)
+ goto err;
+
+ return &buf->b.b;
+
+err:
+ FREE(buf);
+ return NULL;
+}
+
+
+
+struct pipe_resource *
+i915_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind)
+{
+ struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer);
+
+ if (!buf)
+ return NULL;
+
+ pipe_reference_init(&buf->b.b.reference, 1);
+ buf->b.vtbl = &i915_buffer_vtbl;
+ buf->b.b.screen = screen;
+ buf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */
+ buf->b.b._usage = PIPE_USAGE_IMMUTABLE;
+ buf->b.b.bind = bind;
+ buf->b.b.flags = 0;
+ buf->b.b.width0 = bytes;
+ buf->b.b.height0 = 1;
+ buf->b.b.depth0 = 1;
+
+ buf->data = ptr;
+ buf->free_on_destroy = FALSE;
+
+ return &buf->b.b;
+}
diff --git a/src/gallium/drivers/i915/i915_texture.c b/src/gallium/drivers/i915/i915_resource_texture.c
index 8c405c2443..b259968835 100644
--- a/src/gallium/drivers/i915/i915_texture.c
+++ b/src/gallium/drivers/i915/i915_resource_texture.c
@@ -39,7 +39,7 @@
#include "util/u_memory.h"
#include "i915_context.h"
-#include "i915_texture.h"
+#include "i915_resource.h"
#include "i915_screen.h"
#include "i915_winsys.h"
@@ -91,7 +91,7 @@ power_of_two(unsigned x)
static void
-i915_miptree_set_level_info(struct i915_texture *tex,
+i915_texture_set_level_info(struct i915_texture *tex,
unsigned level,
unsigned nr_images,
unsigned w, unsigned h, unsigned d)
@@ -120,7 +120,7 @@ i915_miptree_set_level_info(struct i915_texture *tex,
}
static void
-i915_miptree_set_image_offset(struct i915_texture *tex,
+i915_texture_set_image_offset(struct i915_texture *tex,
unsigned level, unsigned img, unsigned x, unsigned y)
{
if (img == 0 && level == 0)
@@ -128,7 +128,7 @@ i915_miptree_set_image_offset(struct i915_texture *tex,
assert(img < tex->nr_images[level]);
- tex->image_offset[level][img] = y * tex->stride + x * util_format_get_blocksize(tex->base.format);
+ tex->image_offset[level][img] = y * tex->stride + x * util_format_get_blocksize(tex->b.b.format);
/*
printf("%s level %d img %d pos %d,%d image_offset %x\n",
@@ -148,16 +148,16 @@ i915_miptree_set_image_offset(struct i915_texture *tex,
static boolean
i915_scanout_layout(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
if (pt->last_level > 0 || util_format_get_blocksize(pt->format) != 4)
return FALSE;
- i915_miptree_set_level_info(tex, 0, 1,
+ i915_texture_set_level_info(tex, 0, 1,
pt->width0,
pt->height0,
1);
- i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
+ i915_texture_set_image_offset(tex, 0, 0, 0, 0);
if (pt->width0 >= 240) {
tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
@@ -183,7 +183,7 @@ i915_scanout_layout(struct i915_texture *tex)
static boolean
i915_display_target_layout(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
if (pt->last_level > 0 || util_format_get_blocksize(pt->format) != 4)
return FALSE;
@@ -192,11 +192,11 @@ i915_display_target_layout(struct i915_texture *tex)
if (pt->width0 < 240)
return FALSE;
- i915_miptree_set_level_info(tex, 0, 1,
+ i915_texture_set_level_info(tex, 0, 1,
pt->width0,
pt->height0,
1);
- i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
+ i915_texture_set_image_offset(tex, 0, 0, 0, 0);
tex->stride = power_of_two(util_format_get_stride(pt->format, pt->width0));
tex->total_nblocksy = align(util_format_get_nblocksy(pt->format, pt->height0), 8);
@@ -210,21 +210,26 @@ i915_display_target_layout(struct i915_texture *tex)
}
static void
-i915_miptree_layout_2d(struct i915_texture *tex)
+i915_texture_layout_2d(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
unsigned level;
unsigned width = pt->width0;
unsigned height = pt->height0;
unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->width0);
/* used for scanouts that need special layouts */
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT)
+ if (pt->bind & PIPE_BIND_SCANOUT)
if (i915_scanout_layout(tex))
return;
- /* shared buffers needs to be compatible with X servers */
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_SHARED)
+ /* shared buffers needs to be compatible with X servers
+ *
+ * XXX: need a better name than shared for this if it is to be part
+ * of core gallium, and probably move the flag to resource.flags,
+ * rather than bindings.
+ */
+ if (pt->bind & PIPE_BIND_SHARED)
if (i915_display_target_layout(tex))
return;
@@ -232,8 +237,8 @@ i915_miptree_layout_2d(struct i915_texture *tex)
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 1, width, height, 1);
- i915_miptree_set_image_offset(tex, level, 0, 0, tex->total_nblocksy);
+ i915_texture_set_level_info(tex, level, 1, width, height, 1);
+ i915_texture_set_image_offset(tex, level, 0, 0, tex->total_nblocksy);
nblocksy = align(MAX2(2, nblocksy), 2);
@@ -246,9 +251,9 @@ i915_miptree_layout_2d(struct i915_texture *tex)
}
static void
-i915_miptree_layout_3d(struct i915_texture *tex)
+i915_texture_layout_3d(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
unsigned level;
unsigned width = pt->width0;
@@ -264,7 +269,7 @@ i915_miptree_layout_3d(struct i915_texture *tex)
/* XXX: hardware expects/requires 9 levels at minimum.
*/
for (level = 0; level <= MAX2(8, pt->last_level); level++) {
- i915_miptree_set_level_info(tex, level, depth, width, height, depth);
+ i915_texture_set_level_info(tex, level, depth, width, height, depth);
stack_nblocksy += MAX2(2, nblocksy);
@@ -278,7 +283,7 @@ i915_miptree_layout_3d(struct i915_texture *tex)
for (level = 0; level <= pt->last_level; level++) {
unsigned i;
for (i = 0; i < depth; i++)
- i915_miptree_set_image_offset(tex, level, i, 0, i * stack_nblocksy);
+ i915_texture_set_image_offset(tex, level, i, 0, i * stack_nblocksy);
depth = u_minify(depth, 1);
}
@@ -291,9 +296,9 @@ i915_miptree_layout_3d(struct i915_texture *tex)
}
static void
-i915_miptree_layout_cube(struct i915_texture *tex)
+i915_texture_layout_cube(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
unsigned width = pt->width0, height = pt->height0;
const unsigned nblocks = util_format_get_nblocksx(pt->format, pt->width0);
unsigned level;
@@ -306,7 +311,7 @@ i915_miptree_layout_cube(struct i915_texture *tex)
tex->total_nblocksy = nblocks * 4;
for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 6, width, height, 1);
+ i915_texture_set_level_info(tex, level, 6, width, height, 1);
width /= 2;
height /= 2;
}
@@ -317,7 +322,7 @@ i915_miptree_layout_cube(struct i915_texture *tex)
unsigned d = nblocks;
for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_image_offset(tex, level, face, x, y);
+ i915_texture_set_image_offset(tex, level, face, x, y);
d >>= 1;
x += step_offsets[face][0] * d;
y += step_offsets[face][1] * d;
@@ -326,20 +331,20 @@ i915_miptree_layout_cube(struct i915_texture *tex)
}
static boolean
-i915_miptree_layout(struct i915_texture * tex)
+i915_texture_layout(struct i915_texture * tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
switch (pt->target) {
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
- i915_miptree_layout_2d(tex);
+ i915_texture_layout_2d(tex);
break;
case PIPE_TEXTURE_3D:
- i915_miptree_layout_3d(tex);
+ i915_texture_layout_3d(tex);
break;
case PIPE_TEXTURE_CUBE:
- i915_miptree_layout_cube(tex);
+ i915_texture_layout_cube(tex);
break;
default:
assert(0);
@@ -356,9 +361,9 @@ i915_miptree_layout(struct i915_texture * tex)
static void
-i945_miptree_layout_2d(struct i915_texture *tex)
+i945_texture_layout_2d(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
const int align_x = 2, align_y = 4;
unsigned level;
unsigned x = 0;
@@ -369,12 +374,12 @@ i945_miptree_layout_2d(struct i915_texture *tex)
unsigned nblocksy = util_format_get_nblocksy(pt->format, pt->height0);
/* used for scanouts that need special layouts */
- if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_SCANOUT)
+ if (tex->b.b.bind & PIPE_BIND_SCANOUT)
if (i915_scanout_layout(tex))
return;
/* shared buffers needs to be compatible with X servers */
- if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_SHARED)
+ if (tex->b.b.bind & PIPE_BIND_SHARED)
if (i915_display_target_layout(tex))
return;
@@ -400,8 +405,8 @@ i945_miptree_layout_2d(struct i915_texture *tex)
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 1, width, height, 1);
- i915_miptree_set_image_offset(tex, level, 0, x, y);
+ i915_texture_set_level_info(tex, level, 1, width, height, 1);
+ i915_texture_set_image_offset(tex, level, 0, x, y);
nblocksy = align(nblocksy, align_y);
@@ -427,9 +432,9 @@ i945_miptree_layout_2d(struct i915_texture *tex)
}
static void
-i945_miptree_layout_3d(struct i915_texture *tex)
+i945_texture_layout_3d(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
unsigned width = pt->width0;
unsigned height = pt->height0;
unsigned depth = pt->depth0;
@@ -450,11 +455,11 @@ i945_miptree_layout_3d(struct i915_texture *tex)
int y = 0;
unsigned q, j;
- i915_miptree_set_level_info(tex, level, depth, width, height, depth);
+ i915_texture_set_level_info(tex, level, depth, width, height, depth);
for (q = 0; q < depth;) {
for (j = 0; j < pack_x_nr && q < depth; j++, q++) {
- i915_miptree_set_image_offset(tex, level, q, x, y + tex->total_nblocksy);
+ i915_texture_set_image_offset(tex, level, q, x, y + tex->total_nblocksy);
x += pack_x_pitch;
}
@@ -482,9 +487,9 @@ i945_miptree_layout_3d(struct i915_texture *tex)
}
static void
-i945_miptree_layout_cube(struct i915_texture *tex)
+i945_texture_layout_cube(struct i915_texture *tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
unsigned level;
const unsigned nblocks = util_format_get_nblocksx(pt->format, pt->width0);
@@ -516,7 +521,7 @@ i945_miptree_layout_cube(struct i915_texture *tex)
/* Set all the levels to effectively occupy the whole rectangular region.
*/
for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_level_info(tex, level, 6, width, height, 1);
+ i915_texture_set_level_info(tex, level, 6, width, height, 1);
width /= 2;
height /= 2;
}
@@ -538,7 +543,7 @@ i945_miptree_layout_cube(struct i915_texture *tex)
#endif
for (level = 0; level <= pt->last_level; level++) {
- i915_miptree_set_image_offset(tex, level, face, x, y);
+ i915_texture_set_image_offset(tex, level, face, x, y);
d >>= 1;
@@ -583,20 +588,20 @@ i945_miptree_layout_cube(struct i915_texture *tex)
}
static boolean
-i945_miptree_layout(struct i915_texture * tex)
+i945_texture_layout(struct i915_texture * tex)
{
- struct pipe_texture *pt = &tex->base;
+ struct pipe_resource *pt = &tex->b.b;
switch (pt->target) {
case PIPE_TEXTURE_1D:
case PIPE_TEXTURE_2D:
- i945_miptree_layout_2d(tex);
+ i945_texture_layout_2d(tex);
break;
case PIPE_TEXTURE_3D:
- i945_miptree_layout_3d(tex);
+ i945_texture_layout_3d(tex);
break;
case PIPE_TEXTURE_CUBE:
- i945_miptree_layout_cube(tex);
+ i945_texture_layout_cube(tex);
break;
default:
assert(0);
@@ -607,14 +612,135 @@ i945_miptree_layout(struct i915_texture * tex)
}
+
/*
* Screen texture functions
*/
-static struct pipe_texture *
+
+static boolean
+i915_texture_get_handle(struct pipe_screen * screen,
+ struct pipe_resource *texture,
+ struct winsys_handle *whandle)
+{
+ struct i915_screen *is = i915_screen(screen);
+ struct i915_texture *tex = i915_texture(texture);
+ struct i915_winsys *iws = is->iws;
+
+ return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride);
+}
+
+
+static void
+i915_texture_destroy(struct pipe_screen *screen,
+ struct pipe_resource *pt)
+{
+ struct i915_texture *tex = i915_texture(pt);
+ struct i915_winsys *iws = i915_screen(screen)->iws;
+ uint i;
+
+ /*
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
+ */
+
+ iws->buffer_destroy(iws, tex->buffer);
+
+ for (i = 0; i < Elements(tex->image_offset); i++)
+ if (tex->image_offset[i])
+ FREE(tex->image_offset[i]);
+
+ FREE(tex);
+}
+
+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 i915_texture *tex = i915_texture(resource);
+ struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
+ if (transfer == NULL)
+ return NULL;
+
+ transfer->resource = resource;
+ transfer->sr = sr;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = tex->stride;
+
+ return transfer;
+}
+
+
+static void *
+i915_texture_transfer_map(struct pipe_context *pipe,
+ 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 = tex->image_offset[sr.level][sr.face];
+ }
+ else if (resource->target == PIPE_TEXTURE_3D) {
+ offset = tex->image_offset[sr.level][box->z];
+ }
+ else {
+ offset = tex->image_offset[sr.level][0];
+ assert(sr.face == 0);
+ assert(box->z == 0);
+ }
+
+ map = iws->buffer_map(iws,
+ tex->buffer,
+ (transfer->usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE);
+ if (map == NULL)
+ return NULL;
+
+ return map + offset +
+ box->y / util_format_get_blockheight(format) * transfer->stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+}
+
+static void
+i915_texture_transfer_unmap(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct i915_texture *tex = i915_texture(transfer->resource);
+ struct i915_winsys *iws = i915_screen(tex->b.b.screen)->iws;
+ iws->buffer_unmap(iws, tex->buffer);
+}
+
+
+
+struct u_resource_vtbl i915_texture_vtbl =
+{
+ i915_texture_get_handle, /* get_handle */
+ i915_texture_destroy, /* resource_destroy */
+ NULL, /* is_resource_referenced */
+ i915_texture_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ i915_texture_transfer_map, /* transfer_map */
+ u_default_transfer_flush_region, /* transfer_flush_region */
+ i915_texture_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+
+struct pipe_resource *
i915_texture_create(struct pipe_screen *screen,
- const struct pipe_texture *templat)
+ const struct pipe_resource *template)
{
struct i915_screen *is = i915_screen(screen);
struct i915_winsys *iws = is->iws;
@@ -625,24 +751,27 @@ i915_texture_create(struct pipe_screen *screen,
if (!tex)
return NULL;
- tex->base = *templat;
- pipe_reference_init(&tex->base.reference, 1);
- tex->base.screen = screen;
+ tex->b.b = *template;
+ tex->b.vtbl = &i915_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
if (is->is_i945) {
- if (!i945_miptree_layout(tex))
+ if (!i945_texture_layout(tex))
goto fail;
} else {
- if (!i915_miptree_layout(tex))
+ if (!i915_texture_layout(tex))
goto fail;
}
tex_size = tex->stride * tex->total_nblocksy;
-
-
/* for scanouts and cursors, cursors arn't scanouts */
- if (templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT && templat->width0 != 64)
+
+ /* XXX: use a custom flag for cursors, don't rely on magically
+ * guessing that this is Xorg asking for a cursor
+ */
+ if ((template->bind & PIPE_BIND_SCANOUT) && template->width0 != 64)
buf_usage = I915_NEW_SCANOUT;
else
buf_usage = I915_NEW_TEXTURE;
@@ -665,17 +794,17 @@ i915_texture_create(struct pipe_screen *screen,
ws->buffer_unmap(ws, tex->buffer);
#endif
- return &tex->base;
+ return &tex->b.b;
fail:
FREE(tex);
return NULL;
}
-static struct pipe_texture *
+struct pipe_resource *
i915_texture_from_handle(struct pipe_screen * screen,
- const struct pipe_texture *templat,
- struct winsys_handle *whandle)
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
{
struct i915_screen *is = i915_screen(screen);
struct i915_texture *tex;
@@ -688,9 +817,9 @@ i915_texture_from_handle(struct pipe_screen * screen,
buffer = iws->buffer_from_handle(iws, whandle, &stride);
/* Only supports one type */
- if (templat->target != PIPE_TEXTURE_2D ||
- templat->last_level != 0 ||
- templat->depth0 != 1) {
+ if (template->target != PIPE_TEXTURE_2D ||
+ template->last_level != 0 ||
+ template->depth0 != 1) {
return NULL;
}
@@ -698,204 +827,18 @@ i915_texture_from_handle(struct pipe_screen * screen,
if (!tex)
return NULL;
- tex->base = *templat;
- pipe_reference_init(&tex->base.reference, 1);
- tex->base.screen = screen;
+ tex->b.b = *template;
+ tex->b.vtbl = &i915_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
tex->stride = stride;
- i915_miptree_set_level_info(tex, 0, 1, templat->width0, templat->height0, 1);
- i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
+ i915_texture_set_level_info(tex, 0, 1, template->width0, template->height0, 1);
+ i915_texture_set_image_offset(tex, 0, 0, 0, 0);
tex->buffer = buffer;
- return &tex->base;
-}
-
-static boolean
-i915_texture_get_handle(struct pipe_screen * screen,
- struct pipe_texture *texture,
- struct winsys_handle *whandle)
-{
- struct i915_screen *is = i915_screen(screen);
- struct i915_texture *tex = (struct i915_texture *)texture;
- struct i915_winsys *iws = is->iws;
-
- return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride);
-}
-
-
-static void
-i915_texture_destroy(struct pipe_texture *pt)
-{
- struct i915_texture *tex = (struct i915_texture *)pt;
- struct i915_winsys *iws = i915_screen(pt->screen)->iws;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
-
- iws->buffer_destroy(iws, tex->buffer);
-
- for (i = 0; i < Elements(tex->image_offset); i++)
- if (tex->image_offset[i])
- FREE(tex->image_offset[i]);
-
- FREE(tex);
-}
-
-
-/*
- * Screen surface functions
- */
-
-
-static struct pipe_surface *
-i915_get_tex_surface(struct pipe_screen *screen,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
-{
- struct i915_texture *tex = (struct i915_texture *)pt;
- struct pipe_surface *ps;
- unsigned offset; /* in bytes */
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- offset = tex->image_offset[level][face];
- }
- else if (pt->target == PIPE_TEXTURE_3D) {
- offset = tex->image_offset[level][zslice];
- }
- else {
- offset = tex->image_offset[level][0];
- assert(face == 0);
- assert(zslice == 0);
- }
-
- ps = CALLOC_STRUCT(pipe_surface);
- if (ps) {
- pipe_reference_init(&ps->reference, 1);
- pipe_texture_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;
- }
- return ps;
-}
-
-static void
-i915_tex_surface_destroy(struct pipe_surface *surf)
-{
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
-}
-
-
-/*
- * Texture transfer functions
- */
-
-
-static struct pipe_transfer *
-i915_get_tex_transfer(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage, unsigned x, unsigned y,
- unsigned w, unsigned h)
-{
- struct i915_texture *tex = (struct i915_texture *)texture;
- struct i915_transfer *trans;
- unsigned offset; /* in bytes */
-
- if (texture->target == PIPE_TEXTURE_CUBE) {
- offset = tex->image_offset[level][face];
- }
- else if (texture->target == PIPE_TEXTURE_3D) {
- offset = tex->image_offset[level][zslice];
- }
- else {
- offset = tex->image_offset[level][0];
- assert(face == 0);
- assert(zslice == 0);
- }
-
- trans = CALLOC_STRUCT(i915_transfer);
- if (trans) {
- pipe_texture_reference(&trans->base.texture, texture);
- trans->base.x = x;
- trans->base.y = y;
- trans->base.width = w;
- trans->base.height = h;
- trans->base.stride = tex->stride;
- trans->offset = offset;
- trans->base.usage = usage;
- }
- return &trans->base;
-}
-
-static void *
-i915_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct i915_texture *tex = (struct i915_texture *)transfer->texture;
- struct i915_winsys *iws = i915_screen(tex->base.screen)->iws;
- char *map;
- boolean write = FALSE;
- enum pipe_format format = tex->base.format;
-
- if (transfer->usage & PIPE_TRANSFER_WRITE)
- write = TRUE;
-
- map = iws->buffer_map(iws, tex->buffer, write);
- if (map == NULL)
- return NULL;
-
- return map + i915_transfer(transfer)->offset +
- transfer->y / util_format_get_blockheight(format) * transfer->stride +
- transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
-}
-
-static void
-i915_transfer_unmap(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct i915_texture *tex = (struct i915_texture *)transfer->texture;
- struct i915_winsys *iws = i915_screen(tex->base.screen)->iws;
- iws->buffer_unmap(iws, tex->buffer);
-}
-
-static void
-i915_tex_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *trans)
-{
- pipe_texture_reference(&trans->texture, NULL);
- FREE(trans);
-}
-
-
-/*
- * Other texture functions
- */
-
-void
-i915_init_texture_functions(struct i915_context *i915 )
-{
- i915->base.get_tex_transfer = i915_get_tex_transfer;
- i915->base.transfer_map = i915_transfer_map;
- i915->base.transfer_unmap = i915_transfer_unmap;
- i915->base.tex_transfer_destroy = i915_tex_transfer_destroy;
+ return &tex->b.b;
}
-void
-i915_init_screen_texture_functions(struct i915_screen *is)
-{
- is->base.texture_create = i915_texture_create;
- is->base.texture_from_handle = i915_texture_from_handle;
- is->base.texture_get_handle = i915_texture_get_handle;
- is->base.texture_destroy = i915_texture_destroy;
- is->base.get_tex_surface = i915_get_tex_surface;
- is->base.tex_surface_destroy = i915_tex_surface_destroy;
-}
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
index 4ccc66b037..9086f9fc3b 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -33,8 +33,8 @@
#include "i915_reg.h"
#include "i915_context.h"
#include "i915_screen.h"
-#include "i915_buffer.h"
-#include "i915_texture.h"
+#include "i915_surface.h"
+#include "i915_resource.h"
#include "i915_winsys.h"
@@ -190,7 +190,7 @@ i915_is_format_supported(struct pipe_screen *screen,
const enum pipe_format *list;
uint i;
- if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ if(tex_usage & PIPE_BIND_RENDER_TARGET)
list = surface_supported;
else
list = tex_supported;
@@ -308,8 +308,8 @@ i915_create_screen(struct i915_winsys *iws, uint pci_id)
is->base.fence_signalled = i915_fence_signalled;
is->base.fence_finish = i915_fence_finish;
- i915_init_screen_texture_functions(is);
- i915_init_screen_buffer_functions(is);
+ i915_init_screen_resource_functions(is);
+ i915_init_screen_surface_functions(is);
return &is->base;
}
diff --git a/src/gallium/drivers/i915/i915_state.c b/src/gallium/drivers/i915/i915_state.c
index 0f7395246c..bc2f1b268a 100644
--- a/src/gallium/drivers/i915/i915_state.c
+++ b/src/gallium/drivers/i915/i915_state.c
@@ -39,6 +39,7 @@
#include "i915_reg.h"
#include "i915_state_inlines.h"
#include "i915_fpc.h"
+#include "i915_resource.h"
/* The i915 (and related graphics cores) do not support GL_CLAMP. The
* Intel drivers for "other operating systems" implement GL_CLAMP as
@@ -523,10 +524,10 @@ static void i915_delete_vs_state(struct pipe_context *pipe, void *shader)
static void i915_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *buf)
+ struct pipe_resource *buf)
{
struct i915_context *i915 = i915_context(pipe);
- struct pipe_screen *screen = pipe->screen;
+ struct i915_buffer *ir = i915_buffer(buf);
draw_flush(i915->draw);
assert(shader < PIPE_SHADER_TYPES);
@@ -542,19 +543,14 @@ static void i915_set_constant_buffer(struct pipe_context *pipe,
* N constants, leaving any extras from shader translation alone.
*/
if (buf) {
- void *mapped;
- if (buf->size &&
- (mapped = pipe_buffer_map(screen, buf,
- PIPE_BUFFER_USAGE_CPU_READ))) {
- memcpy(i915->current.constants[shader], mapped, buf->size);
- pipe_buffer_unmap(screen, buf);
- i915->current.num_user_constants[shader]
- = buf->size / (4 * sizeof(float));
- }
- else {
- i915->current.num_user_constants[shader] = 0;
- }
+ memcpy(i915->current.constants[shader], ir->data, ir->b.b.width0);
+ i915->current.num_user_constants[shader] = (ir->b.b.width0 /
+ 4 * sizeof(float));
}
+ else {
+ i915->current.num_user_constants[shader] = 0;
+ }
+
i915->dirty |= I915_NEW_CONSTANTS;
}
@@ -593,7 +589,7 @@ static void i915_set_fragment_sampler_views(struct pipe_context *pipe,
static struct pipe_sampler_view *
i915_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -602,7 +598,7 @@ i915_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}
@@ -614,7 +610,7 @@ static void
i915_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
diff --git a/src/gallium/drivers/i915/i915_state_emit.c b/src/gallium/drivers/i915/i915_state_emit.c
index 2d212abfb9..4d069fffa8 100644
--- a/src/gallium/drivers/i915/i915_state_emit.c
+++ b/src/gallium/drivers/i915/i915_state_emit.c
@@ -30,6 +30,7 @@
#include "i915_context.h"
#include "i915_batch.h"
#include "i915_reg.h"
+#include "i915_resource.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -211,8 +212,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
if (cbuf_surface) {
unsigned ctile = BUF_3D_USE_FENCE;
- struct i915_texture *tex = (struct i915_texture *)
- cbuf_surface->texture;
+ struct i915_texture *tex = i915_texture(cbuf_surface->texture);
assert(tex);
if (tex && tex->sw_tiled) {
@@ -234,8 +234,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
*/
if (depth_surface) {
unsigned ztile = BUF_3D_USE_FENCE;
- struct i915_texture *tex = (struct i915_texture *)
- depth_surface->texture;
+ struct i915_texture *tex = i915_texture(depth_surface->texture);
assert(tex);
if (tex && tex->sw_tiled) {
@@ -290,7 +289,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
OUT_BATCH(enabled);
for (unit = 0; unit < I915_TEX_UNITS; unit++) {
if (enabled & (1 << unit)) {
- struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+ struct i915_texture *texture = i915_texture(i915->fragment_sampler_views[unit]->texture);
struct i915_winsys_buffer *buf = texture->buffer;
uint offset = 0;
assert(buf);
diff --git a/src/gallium/drivers/i915/i915_state_sampler.c b/src/gallium/drivers/i915/i915_state_sampler.c
index 270d4f21e1..73e61b6624 100644
--- a/src/gallium/drivers/i915/i915_state_sampler.c
+++ b/src/gallium/drivers/i915/i915_state_sampler.c
@@ -32,6 +32,7 @@
#include "i915_context.h"
#include "i915_reg.h"
#include "i915_state.h"
+#include "i915_resource.h"
/*
@@ -77,7 +78,7 @@ static void update_sampler(struct i915_context *i915,
const struct i915_texture *tex,
unsigned state[3] )
{
- const struct pipe_texture *pt = &tex->base;
+ const struct pipe_resource *pt = &tex->b.b;
unsigned minlod, lastlod;
/* Need to do this after updating the maps, which call the
@@ -149,7 +150,7 @@ void i915_update_samplers( struct i915_context *i915 )
/* determine unit enable/disable by looking for a bound texture */
/* could also examine the fragment program? */
if (i915->fragment_sampler_views[unit]) {
- struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+ struct i915_texture *texture = i915_texture(i915->fragment_sampler_views[unit]->texture);
update_sampler( i915,
unit,
@@ -238,7 +239,7 @@ i915_update_texture(struct i915_context *i915,
const struct i915_sampler_state *sampler,
uint state[6])
{
- const struct pipe_texture *pt = &tex->base;
+ const struct pipe_resource *pt = &tex->b.b;
uint format, pitch;
const uint width = pt->width0, height = pt->height0, depth = pt->depth0;
const uint num_levels = pt->last_level;
@@ -296,7 +297,7 @@ i915_update_textures(struct i915_context *i915)
/* determine unit enable/disable by looking for a bound texture */
/* could also examine the fragment program? */
if (i915->fragment_sampler_views[unit]) {
- struct i915_texture *texture = (struct i915_texture *)i915->fragment_sampler_views[unit]->texture;
+ struct i915_texture *texture = i915_texture(i915->fragment_sampler_views[unit]->texture);
i915_update_texture( i915,
unit,
diff --git a/src/gallium/drivers/i915/i915_surface.c b/src/gallium/drivers/i915/i915_surface.c
index 1ff6b9f4c6..453437b809 100644
--- a/src/gallium/drivers/i915/i915_surface.c
+++ b/src/gallium/drivers/i915/i915_surface.c
@@ -25,10 +25,15 @@
*
**************************************************************************/
-#include "i915_context.h"
+#include "i915_surface.h"
+#include "i915_resource.h"
#include "i915_blit.h"
+#include "i915_screen.h"
#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+#include "util/u_math.h"
#include "util/u_format.h"
+#include "util/u_memory.h"
/* Assumes all values are within bounds -- no checking at this level -
@@ -41,10 +46,10 @@ i915_surface_copy(struct pipe_context *pipe,
struct pipe_surface *src,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- struct i915_texture *dst_tex = (struct i915_texture *)dst->texture;
- struct i915_texture *src_tex = (struct i915_texture *)src->texture;
- struct pipe_texture *dpt = &dst_tex->base;
- struct pipe_texture *spt = &src_tex->base;
+ struct i915_texture *dst_tex = i915_texture(dst->texture);
+ struct i915_texture *src_tex = i915_texture(src->texture);
+ struct pipe_resource *dpt = &dst_tex->b.b;
+ struct pipe_resource *spt = &src_tex->b.b;
assert( dst != src );
assert( util_format_get_blocksize(dpt->format) == util_format_get_blocksize(spt->format) );
@@ -68,8 +73,8 @@ i915_surface_fill(struct pipe_context *pipe,
unsigned dstx, unsigned dsty,
unsigned width, unsigned height, unsigned value)
{
- struct i915_texture *tex = (struct i915_texture *)dst->texture;
- struct pipe_texture *pt = &tex->base;
+ struct i915_texture *tex = i915_texture(dst->texture);
+ struct pipe_resource *pt = &tex->b.b;
assert(util_format_get_blockwidth(pt->format) == 1);
assert(util_format_get_blockheight(pt->format) == 1);
@@ -84,9 +89,68 @@ i915_surface_fill(struct pipe_context *pipe,
}
+/*
+ * Screen surface functions
+ */
+
+
+static struct pipe_surface *
+i915_get_tex_surface(struct pipe_screen *screen,
+ struct pipe_resource *pt,
+ unsigned face, unsigned level, unsigned zslice,
+ unsigned flags)
+{
+ struct i915_texture *tex = i915_texture(pt);
+ struct pipe_surface *ps;
+ unsigned offset; /* in bytes */
+
+ if (pt->target == PIPE_TEXTURE_CUBE) {
+ offset = tex->image_offset[level][face];
+ }
+ else if (pt->target == PIPE_TEXTURE_3D) {
+ offset = tex->image_offset[level][zslice];
+ }
+ else {
+ offset = tex->image_offset[level][0];
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+
+ ps = CALLOC_STRUCT(pipe_surface);
+ if (ps) {
+ 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;
+ }
+ return ps;
+}
+
+static void
+i915_tex_surface_destroy(struct pipe_surface *surf)
+{
+ pipe_resource_reference(&surf->texture, NULL);
+ FREE(surf);
+}
+
+
+/* Probably going to make blits work on textures rather than surfaces.
+ */
void
i915_init_surface_functions(struct i915_context *i915)
{
i915->base.surface_copy = i915_surface_copy;
i915->base.surface_fill = i915_surface_fill;
}
+
+/* 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;
+}
diff --git a/src/gallium/drivers/i915/i915_texture.h b/src/gallium/drivers/i915/i915_surface.h
index 51a1dd984c..448106d566 100644
--- a/src/gallium/drivers/i915/i915_texture.h
+++ b/src/gallium/drivers/i915/i915_surface.h
@@ -25,12 +25,14 @@
*
**************************************************************************/
-#ifndef I915_TEXTURE_H
-#define I915_TEXTURE_H
+#ifndef I915_SURFACE_H
+#define I915_SURFACE_H
+struct i915_context;
struct i915_screen;
-extern void
-i915_init_screen_texture_functions(struct i915_screen *is);
+void i915_init_surface_functions( struct i915_context *i915 );
+void i915_init_screen_surface_functions( struct i915_screen *is );
-#endif /* I915_TEXTURE_H */
+
+#endif /* I915_SCREEN_H */
diff --git a/src/gallium/drivers/i915/i915_winsys.h b/src/gallium/drivers/i915/i915_winsys.h
index 246e95b00d..8a6f579ad9 100644
--- a/src/gallium/drivers/i915/i915_winsys.h
+++ b/src/gallium/drivers/i915/i915_winsys.h
@@ -31,7 +31,7 @@
struct i915_winsys;
struct i915_winsys_buffer;
struct i915_winsys_batchbuffer;
-struct pipe_texture;
+struct pipe_resource;
struct pipe_fence_handle;
struct winsys_handle;
@@ -133,7 +133,7 @@ struct i915_winsys {
/**
* Creates a buffer from a handle.
- * Used to implement pipe_screen::texture_from_handle.
+ * Used to implement pipe_screen::resource_from_handle.
* Also provides the stride information needed for the
* texture via the stride argument.
*/
@@ -143,7 +143,7 @@ struct i915_winsys {
unsigned *stride);
/**
- * Used to implement pipe_screen::texture_get_handle.
+ * Used to implement pipe_screen::resource_get_handle.
* The winsys might need the stride information.
*/
boolean (*buffer_get_handle)(struct i915_winsys *iws,
diff --git a/src/gallium/drivers/i965/Makefile b/src/gallium/drivers/i965/Makefile
index 95fd3cd69b..b0b0970338 100644
--- a/src/gallium/drivers/i965/Makefile
+++ b/src/gallium/drivers/i965/Makefile
@@ -36,6 +36,7 @@ C_SOURCES = \
brw_pipe_vertex.c \
brw_pipe_clear.c \
brw_pipe_rast.c \
+ brw_resource.c \
brw_sf.c \
brw_sf_emit.c \
brw_sf_state.c \
@@ -46,7 +47,6 @@ C_SOURCES = \
brw_structs_dump.c \
brw_swtnl.c \
brw_urb.c \
- brw_util.c \
brw_vs.c \
brw_vs_emit.c \
brw_vs_state.c \
@@ -63,9 +63,9 @@ C_SOURCES = \
brw_wm_state.c \
brw_wm_surface_state.c \
brw_screen.c \
- brw_screen_buffers.c \
- brw_screen_tex_layout.c \
- brw_screen_texture.c \
+ brw_resource_buffer.c \
+ brw_resource_texture.c \
+ brw_resource_texture_layout.c \
brw_screen_surface.c \
brw_batchbuffer.c \
brw_winsys_debug.c \
diff --git a/src/gallium/drivers/i965/SConscript b/src/gallium/drivers/i965/SConscript
index d900ea2596..85c4d7ed22 100644
--- a/src/gallium/drivers/i965/SConscript
+++ b/src/gallium/drivers/i965/SConscript
@@ -38,11 +38,12 @@ i965 = env.ConvenienceLibrary(
'brw_pipe_sampler.c',
'brw_pipe_shader.c',
'brw_pipe_vertex.c',
- 'brw_screen_buffers.c',
+ 'brw_resource.c',
+ 'brw_resource_buffer.c',
+ 'brw_resource_texture.c',
+ 'brw_resource_texture_layout.c',
'brw_screen.c',
'brw_screen_surface.c',
- 'brw_screen_tex_layout.c',
- 'brw_screen_texture.c',
'brw_structs_dump.c',
'brw_sf.c',
'brw_sf_emit.c',
@@ -53,7 +54,6 @@ i965 = env.ConvenienceLibrary(
'brw_state_upload.c',
'brw_swtnl.c',
'brw_urb.c',
- 'brw_util.c',
'brw_vs.c',
'brw_vs_emit.c',
'brw_vs_state.c',
diff --git a/src/gallium/drivers/i965/brw_context.c b/src/gallium/drivers/i965/brw_context.c
index 4bcdcdd17e..227bc790de 100644
--- a/src/gallium/drivers/i965/brw_context.c
+++ b/src/gallium/drivers/i965/brw_context.c
@@ -39,6 +39,7 @@
#include "brw_state.h"
#include "brw_batchbuffer.h"
#include "brw_winsys.h"
+#include "brw_resource.h"
#include "brw_screen.h"
@@ -118,7 +119,7 @@ struct pipe_context *brw_create_context(struct pipe_screen *screen,
brw->sws = brw_screen(screen)->sws;
brw->chipset = brw_screen(screen)->chipset;
- brw_tex_init( brw );
+ brw_init_resource_functions( brw );
brw_pipe_blend_init( brw );
brw_pipe_depth_stencil_init( brw );
brw_pipe_framebuffer_init( brw );
diff --git a/src/gallium/drivers/i965/brw_context.h b/src/gallium/drivers/i965/brw_context.h
index dab881fea2..94c9c443f0 100644
--- a/src/gallium/drivers/i965/brw_context.h
+++ b/src/gallium/drivers/i965/brw_context.h
@@ -561,8 +561,8 @@ struct brw_context
struct pipe_stencil_ref stencil_ref;
struct pipe_framebuffer_state fb;
struct pipe_clip_state ucp;
- struct pipe_buffer *vertex_constants;
- struct pipe_buffer *fragment_constants;
+ struct pipe_resource *vertex_constants;
+ struct pipe_resource *fragment_constants;
struct brw_blend_constant_color bcc;
struct brw_cc1 cc1_stencil_ref;
@@ -574,7 +574,7 @@ struct brw_context
*
* Updates are signaled by PIPE_NEW_INDEX_BUFFER.
*/
- struct pipe_buffer *index_buffer;
+ struct pipe_resource *index_buffer;
unsigned index_size;
/* Updates are signalled by PIPE_NEW_INDEX_RANGE:
diff --git a/src/gallium/drivers/i965/brw_curbe.c b/src/gallium/drivers/i965/brw_curbe.c
index 4b215a001c..323af16b14 100644
--- a/src/gallium/drivers/i965/brw_curbe.c
+++ b/src/gallium/drivers/i965/brw_curbe.c
@@ -160,7 +160,6 @@ static GLfloat fixed_plane[6][4] = {
*/
static enum pipe_error prepare_curbe_buffer(struct brw_context *brw)
{
- struct pipe_screen *screen = brw->base.screen;
const GLuint sz = brw->curbe.total_size;
const GLuint bufsz = sz * 16 * sizeof(GLfloat);
enum pipe_error ret;
@@ -196,15 +195,11 @@ static enum pipe_error prepare_curbe_buffer(struct brw_context *brw)
nr_const = fs->info.file_max[TGSI_FILE_CONSTANT] + 1;
/* nr_const = brw->wm.prog_data->nr_params; */
if (nr_const) {
- const GLfloat *value = screen->buffer_map( screen,
- brw->curr.fragment_constants,
- PIPE_BUFFER_USAGE_CPU_READ);
-
- memcpy(&buf[offset], value,
- nr_const * 4 * sizeof(float));
-
- screen->buffer_unmap( screen,
- brw->curr.fragment_constants );
+ pipe_buffer_read( &brw->base,
+ brw->curr.fragment_constants,
+ 0,
+ nr_const * 4 * sizeof(float),
+ &buf[offset]);
}
}
@@ -258,15 +253,14 @@ static enum pipe_error prepare_curbe_buffer(struct brw_context *brw)
* buffer objects. If we want to keep on putting them into the
* curbe, makes sense to treat constbuf's specially with malloc.
*/
- const GLfloat *value = screen->buffer_map( screen,
- brw->curr.vertex_constants,
- PIPE_BUFFER_USAGE_CPU_READ);
/* XXX: what if user's constant buffer is too small?
*/
- memcpy(&buf[offset], value, nr_const * 4 * sizeof(float));
-
- screen->buffer_unmap( screen, brw->curr.vertex_constants );
+ pipe_buffer_read(&brw->base,
+ brw->curr.vertex_constants,
+ 0,
+ nr_const * 4 * sizeof(float),
+ &buf[offset]);
}
}
diff --git a/src/gallium/drivers/i965/brw_draw.c b/src/gallium/drivers/i965/brw_draw.c
index 9bad61ef72..eb73ec2f27 100644
--- a/src/gallium/drivers/i965/brw_draw.c
+++ b/src/gallium/drivers/i965/brw_draw.c
@@ -142,7 +142,7 @@ static int brw_emit_prim(struct brw_context *brw,
*/
static int
try_draw_range_elements(struct brw_context *brw,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned hw_prim,
unsigned start, unsigned count)
{
@@ -178,7 +178,7 @@ try_draw_range_elements(struct brw_context *brw,
static void
brw_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
@@ -201,7 +201,7 @@ brw_draw_range_elements(struct pipe_context *pipe,
*/
if (brw->curr.index_buffer != index_buffer ||
brw->curr.index_size != index_size) {
- pipe_buffer_reference( &brw->curr.index_buffer, index_buffer );
+ pipe_resource_reference( &brw->curr.index_buffer, index_buffer );
brw->curr.index_size = index_size;
brw->state.dirty.mesa |= PIPE_NEW_INDEX_BUFFER;
}
@@ -232,7 +232,7 @@ brw_draw_range_elements(struct pipe_context *pipe,
static void
brw_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned mode,
unsigned start, unsigned count)
@@ -263,17 +263,17 @@ boolean brw_draw_init( struct brw_context *brw )
/* Create helpers for uploading data in user buffers:
*/
- brw->vb.upload_vertex = u_upload_create( brw->base.screen,
+ brw->vb.upload_vertex = u_upload_create( &brw->base,
128 * 1024,
64,
- PIPE_BUFFER_USAGE_VERTEX );
+ PIPE_BIND_VERTEX_BUFFER );
if (brw->vb.upload_vertex == NULL)
return FALSE;
- brw->vb.upload_index = u_upload_create( brw->base.screen,
+ brw->vb.upload_index = u_upload_create( &brw->base,
32 * 1024,
64,
- PIPE_BUFFER_USAGE_INDEX );
+ PIPE_BIND_INDEX_BUFFER );
if (brw->vb.upload_index == NULL)
return FALSE;
diff --git a/src/gallium/drivers/i965/brw_draw_upload.c b/src/gallium/drivers/i965/brw_draw_upload.c
index 0820ba20a0..337eee8cd9 100644
--- a/src/gallium/drivers/i965/brw_draw_upload.c
+++ b/src/gallium/drivers/i965/brw_draw_upload.c
@@ -38,6 +38,7 @@
#include "brw_screen.h"
#include "brw_batchbuffer.h"
#include "brw_debug.h"
+#include "brw_resource.h"
@@ -67,7 +68,7 @@ static int brw_prepare_vertices(struct brw_context *brw)
for (i = 0; i < brw->curr.num_vertex_buffers; i++) {
struct pipe_vertex_buffer *vb = &brw->curr.vertex_buffer[i];
struct brw_winsys_buffer *bo;
- struct pipe_buffer *upload_buf = NULL;
+ struct pipe_resource *upload_buf = NULL;
unsigned offset;
if (BRW_DEBUG & DEBUG_VERTS)
@@ -75,7 +76,7 @@ static int brw_prepare_vertices(struct brw_context *brw)
__FUNCTION__, i,
brw_buffer_is_user_buffer(vb->buffer),
vb->buffer_offset,
- vb->buffer->size,
+ vb->buffer->width0,
vb->stride);
if (brw_buffer_is_user_buffer(vb->buffer)) {
@@ -85,8 +86,8 @@ static int brw_prepare_vertices(struct brw_context *brw)
* add support for >1 constant buffer) instead.
*/
unsigned size = (vb->stride == 0 ?
- vb->buffer->size - vb->buffer_offset :
- MAX2(vb->buffer->size - vb->buffer_offset,
+ vb->buffer->width0 - vb->buffer_offset :
+ MAX2(vb->buffer->width0 - vb->buffer_offset,
vb->stride * (max_index + 1 - min_index)));
ret = u_upload_buffer( brw->vb.upload_vertex,
@@ -123,7 +124,7 @@ static int brw_prepare_vertices(struct brw_context *brw)
/* Don't need to retain this reference. We have a reference on
* the underlying winsys buffer:
*/
- pipe_buffer_reference( &upload_buf, NULL );
+ pipe_resource_reference( &upload_buf, NULL );
}
brw->vb.nr_vb = i;
@@ -226,8 +227,8 @@ const struct brw_tracked_state brw_vertices = {
static int brw_prepare_indices(struct brw_context *brw)
{
- struct pipe_buffer *index_buffer = brw->curr.index_buffer;
- struct pipe_buffer *upload_buf = NULL;
+ struct pipe_resource *index_buffer = brw->curr.index_buffer;
+ struct pipe_resource *upload_buf = NULL;
struct brw_winsys_buffer *bo = NULL;
GLuint offset;
GLuint index_size;
@@ -241,9 +242,9 @@ static int brw_prepare_indices(struct brw_context *brw)
debug_printf("%s: index_size:%d index_buffer->size:%d\n",
__FUNCTION__,
brw->curr.index_size,
- brw->curr.index_buffer->size);
+ brw->curr.index_buffer->width0);
- ib_size = index_buffer->size;
+ ib_size = index_buffer->width0;
index_size = brw->curr.index_size;
/* Turn userbuffer into a proper hardware buffer?
@@ -297,7 +298,7 @@ static int brw_prepare_indices(struct brw_context *brw)
brw->state.dirty.brw |= BRW_NEW_INDEX_BUFFER;
}
- pipe_buffer_reference( &upload_buf, NULL );
+ pipe_resource_reference( &upload_buf, NULL );
brw_add_validated_bo(brw, brw->ib.bo);
return 0;
}
diff --git a/src/gallium/drivers/i965/brw_pipe_flush.c b/src/gallium/drivers/i965/brw_pipe_flush.c
index fdc4814b22..fa2b64fd26 100644
--- a/src/gallium/drivers/i965/brw_pipe_flush.c
+++ b/src/gallium/drivers/i965/brw_pipe_flush.c
@@ -1,10 +1,11 @@
-#include "util/u_upload_mgr.h"
-
#include "brw_context.h"
#include "brw_screen.h"
#include "brw_batchbuffer.h"
+#include "util/u_upload_mgr.h"
+
+
/* All batchbuffer flushes must go through this function.
@@ -46,35 +47,9 @@ brw_flush( struct pipe_context *pipe,
*fence = NULL;
}
-static unsigned brw_is_buffer_referenced(struct pipe_context *pipe,
- struct pipe_buffer *buffer)
-{
- struct brw_context *brw = brw_context(pipe);
- struct brw_screen *bscreen = brw_screen(brw->base.screen);
-
- return brw_is_buffer_referenced_by_bo( bscreen,
- buffer,
- brw->batch->buf );
-}
-
-static unsigned brw_is_texture_referenced(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face,
- unsigned level)
-{
- struct brw_context *brw = brw_context(pipe);
- struct brw_screen *bscreen = brw_screen(brw->base.screen);
-
- return brw_is_texture_referenced_by_bo( bscreen,
- texture, face, level,
- brw->batch->buf );
-}
-
void brw_pipe_flush_init( struct brw_context *brw )
{
brw->base.flush = brw_flush;
- brw->base.is_buffer_referenced = brw_is_buffer_referenced;
- brw->base.is_texture_referenced = brw_is_texture_referenced;
}
diff --git a/src/gallium/drivers/i965/brw_pipe_sampler.c b/src/gallium/drivers/i965/brw_pipe_sampler.c
index d2aa2bc9f3..3fe753ec42 100644
--- a/src/gallium/drivers/i965/brw_pipe_sampler.c
+++ b/src/gallium/drivers/i965/brw_pipe_sampler.c
@@ -214,7 +214,7 @@ static void brw_bind_vertex_sampler_state(struct pipe_context *pipe,
static struct pipe_sampler_view *
brw_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -223,7 +223,7 @@ brw_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}
@@ -235,7 +235,7 @@ static void
brw_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
diff --git a/src/gallium/drivers/i965/brw_pipe_shader.c b/src/gallium/drivers/i965/brw_pipe_shader.c
index fe445b9982..d9bee96c11 100644
--- a/src/gallium/drivers/i965/brw_pipe_shader.c
+++ b/src/gallium/drivers/i965/brw_pipe_shader.c
@@ -262,20 +262,20 @@ static void brw_delete_vs_state( struct pipe_context *pipe, void *prog )
static void brw_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *buf)
+ struct pipe_resource *buf)
{
struct brw_context *brw = brw_context(pipe);
assert(index == 0);
if (shader == PIPE_SHADER_FRAGMENT) {
- pipe_buffer_reference( &brw->curr.fragment_constants,
+ pipe_resource_reference( &brw->curr.fragment_constants,
buf );
brw->state.dirty.mesa |= PIPE_NEW_FRAGMENT_CONSTANTS;
}
else {
- pipe_buffer_reference( &brw->curr.vertex_constants,
+ pipe_resource_reference( &brw->curr.vertex_constants,
buf );
brw->state.dirty.mesa |= PIPE_NEW_VERTEX_CONSTANTS;
@@ -298,6 +298,6 @@ void brw_pipe_shader_init( struct brw_context *brw )
void brw_pipe_shader_cleanup( struct brw_context *brw )
{
- pipe_buffer_reference( &brw->curr.fragment_constants, NULL );
- pipe_buffer_reference( &brw->curr.vertex_constants, NULL );
+ pipe_resource_reference( &brw->curr.fragment_constants, NULL );
+ pipe_resource_reference( &brw->curr.vertex_constants, NULL );
}
diff --git a/src/gallium/drivers/i965/brw_pipe_vertex.c b/src/gallium/drivers/i965/brw_pipe_vertex.c
index d6a840857e..4a120a51da 100644
--- a/src/gallium/drivers/i965/brw_pipe_vertex.c
+++ b/src/gallium/drivers/i965/brw_pipe_vertex.c
@@ -259,11 +259,11 @@ static void brw_set_vertex_buffers(struct pipe_context *pipe,
/* Adjust refcounts */
for (i = 0; i < count; i++)
- pipe_buffer_reference(&brw->curr.vertex_buffer[i].buffer,
+ pipe_resource_reference(&brw->curr.vertex_buffer[i].buffer,
buffers[i].buffer);
for ( ; i < brw->curr.num_vertex_buffers; i++)
- pipe_buffer_reference(&brw->curr.vertex_buffer[i].buffer,
+ pipe_resource_reference(&brw->curr.vertex_buffer[i].buffer,
NULL);
/* Copy remaining data */
diff --git a/src/gallium/drivers/i965/brw_resource.c b/src/gallium/drivers/i965/brw_resource.c
new file mode 100644
index 0000000000..d601f42dd1
--- /dev/null
+++ b/src/gallium/drivers/i965/brw_resource.c
@@ -0,0 +1,50 @@
+#include "util/u_debug.h"
+
+#include "brw_resource.h"
+#include "brw_context.h"
+#include "brw_screen.h"
+
+
+static struct pipe_resource *
+brw_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ if (template->target == PIPE_BUFFER)
+ return brw_buffer_create(screen, template);
+ else
+ return brw_resource_create(screen, template);
+
+}
+
+static struct pipe_resource *
+brw_resource_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
+{
+ if (template->target == PIPE_BUFFER)
+ return NULL;
+ else
+ return brw_texture_from_handle(screen, template, whandle);
+}
+
+
+void
+brw_init_resource_functions(struct brw_context *brw )
+{
+ brw->base.get_transfer = u_get_transfer_vtbl;
+ brw->base.transfer_map = u_transfer_map_vtbl;
+ brw->base.transfer_flush_region = u_transfer_flush_region_vtbl;
+ brw->base.transfer_unmap = u_transfer_unmap_vtbl;
+ brw->base.transfer_destroy = u_transfer_destroy_vtbl;
+ brw->base.transfer_inline_write = u_transfer_inline_write_vtbl;
+}
+
+void
+brw_init_screen_resource_functions(struct brw_screen *is)
+{
+ is->base.resource_create = brw_resource_create;
+ is->base.resource_from_handle = brw_resource_from_handle;
+ is->base.resource_get_handle = u_resource_get_handle_vtbl;
+ is->base.resource_destroy = u_resource_destroy_vtbl;
+ is->base.user_buffer_create = brw_user_buffer_create;
+}
diff --git a/src/gallium/drivers/i965/brw_resource.h b/src/gallium/drivers/i965/brw_resource.h
new file mode 100644
index 0000000000..3390c270d4
--- /dev/null
+++ b/src/gallium/drivers/i965/brw_resource.h
@@ -0,0 +1,151 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef BRW_RESOURCE_H
+#define BRW_RESOURCE_H
+
+struct brw_screen;
+
+#include "util/u_transfer.h"
+#include "util/u_debug.h"
+
+#include "brw_screen.h" /* for brw_surface */
+
+struct brw_context;
+struct brw_screen;
+
+
+struct brw_buffer {
+ struct u_resource b;
+
+ /* One of either bo or user_buffer will be non-null, depending on
+ * whether this is a hardware or user buffer.
+ */
+ struct brw_winsys_buffer *bo;
+ void *user_buffer;
+
+ /* Mapped pointer??
+ */
+ void *ptr;
+};
+
+#define BRW_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */
+#define BRW_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */
+
+
+
+struct brw_texture {
+ struct u_resource b;
+ struct brw_winsys_buffer *bo;
+ struct brw_surface_state ss;
+
+ unsigned *image_offset[BRW_MAX_TEXTURE_2D_LEVELS];
+ unsigned nr_images[BRW_MAX_TEXTURE_2D_LEVELS];
+ unsigned level_offset[BRW_MAX_TEXTURE_2D_LEVELS];
+
+ boolean compressed;
+ unsigned brw_target;
+ unsigned pitch;
+ unsigned tiling;
+ unsigned cpp;
+ unsigned total_height;
+
+ struct brw_surface views[2];
+};
+
+
+void brw_init_screen_resource_functions(struct brw_screen *is);
+void brw_init_resource_functions(struct brw_context *brw );
+
+extern struct u_resource_vtbl brw_buffer_vtbl;
+extern struct u_resource_vtbl brw_texture_vtbl;
+
+static INLINE struct brw_texture *brw_texture( struct pipe_resource *resource )
+{
+ struct brw_texture *tex = (struct brw_texture *)resource;
+ assert(tex->b.vtbl == &brw_texture_vtbl);
+ return tex;
+}
+
+static INLINE struct brw_buffer *brw_buffer( struct pipe_resource *resource )
+{
+ struct brw_buffer *tex = (struct brw_buffer *)resource;
+ assert(tex->b.vtbl == &brw_buffer_vtbl);
+ return tex;
+}
+
+struct pipe_resource *
+brw_texture_create(struct pipe_screen *screen,
+ const struct pipe_resource *template);
+
+struct pipe_resource *
+brw_texture_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle);
+
+
+struct pipe_resource *
+brw_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage);
+
+struct pipe_resource *
+brw_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template);
+
+
+/*
+boolean
+brw_is_format_supported( struct pipe_screen *screen,
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags );
+*/
+
+/* Pipe buffer helpers
+ */
+static INLINE boolean
+brw_buffer_is_user_buffer( const struct pipe_resource *buf )
+{
+ return ((const struct brw_buffer *)buf)->user_buffer != NULL;
+}
+
+
+/***********************************************************************
+ * Internal functions
+ */
+GLboolean brw_texture_layout(struct brw_screen *brw_screen,
+ struct brw_texture *tex );
+
+void brw_update_texture( struct brw_screen *brw_screen,
+ struct brw_texture *tex );
+
+
+
+#endif /* BRW_RESOURCE_H */
diff --git a/src/gallium/drivers/i965/brw_resource_buffer.c b/src/gallium/drivers/i965/brw_resource_buffer.c
new file mode 100644
index 0000000000..488fe13c71
--- /dev/null
+++ b/src/gallium/drivers/i965/brw_resource_buffer.c
@@ -0,0 +1,201 @@
+
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+
+#include "brw_resource.h"
+#include "brw_context.h"
+#include "brw_batchbuffer.h"
+#include "brw_winsys.h"
+
+static boolean
+brw_buffer_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ return FALSE;
+}
+
+
+static void
+brw_buffer_destroy(struct pipe_screen *screen,
+ struct pipe_resource *resource)
+{
+ struct brw_buffer *buf = brw_buffer( resource );
+
+ bo_reference(&buf->bo, NULL);
+ FREE(buf);
+}
+
+
+static void *
+brw_buffer_transfer_map( struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct brw_screen *bscreen = brw_screen(pipe->screen);
+ struct brw_winsys_screen *sws = bscreen->sws;
+ struct brw_buffer *buf = brw_buffer(transfer->resource);
+ unsigned offset = transfer->box.x;
+ unsigned length = transfer->box.width;
+ unsigned usage = transfer->usage;
+ uint8_t *map;
+
+ if (buf->user_buffer)
+ map = buf->user_buffer;
+ else
+ map = sws->bo_map( buf->bo,
+ BRW_DATA_OTHER,
+ offset,
+ length,
+ (usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE,
+ (usage & PIPE_TRANSFER_DISCARD) ? TRUE : FALSE,
+ (usage & PIPE_TRANSFER_FLUSH_EXPLICIT) ? TRUE : FALSE);
+
+ return map + offset;
+}
+
+
+static void
+brw_buffer_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ struct brw_screen *bscreen = brw_screen(pipe->screen);
+ struct brw_winsys_screen *sws = bscreen->sws;
+ struct brw_buffer *buf = brw_buffer(transfer->resource);
+ unsigned offset = box->x;
+ unsigned length = box->width;
+
+ if (buf->user_buffer)
+ return;
+
+ sws->bo_flush_range( buf->bo,
+ offset,
+ length );
+}
+
+
+static void
+brw_buffer_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct brw_screen *bscreen = brw_screen(pipe->screen);
+ struct brw_winsys_screen *sws = bscreen->sws;
+ struct brw_buffer *buf = brw_buffer( transfer->resource );
+
+ if (buf->bo)
+ sws->bo_unmap(buf->bo);
+}
+
+
+static unsigned brw_buffer_is_referenced( struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face,
+ unsigned level)
+{
+ struct brw_context *brw = brw_context(pipe);
+ struct brw_winsys_buffer *batch_bo = brw->batch->buf;
+ struct brw_buffer *buf = brw_buffer(resource);
+
+ if (buf->bo == NULL)
+ return PIPE_UNREFERENCED;
+
+ if (!brw_screen(pipe->screen)->sws->bo_references( batch_bo, buf->bo ))
+ return PIPE_UNREFERENCED;
+
+ return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+}
+
+
+struct u_resource_vtbl brw_buffer_vtbl =
+{
+ brw_buffer_get_handle, /* get_handle */
+ brw_buffer_destroy, /* resource_destroy */
+ brw_buffer_is_referenced, /* is_resource_referenced */
+ u_default_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ brw_buffer_transfer_map, /* transfer_map */
+ brw_buffer_transfer_flush_region, /* transfer_flush_region */
+ brw_buffer_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+struct pipe_resource *
+brw_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ struct brw_screen *bscreen = brw_screen(screen);
+ struct brw_winsys_screen *sws = bscreen->sws;
+ struct brw_buffer *buf;
+ unsigned buffer_type;
+ enum pipe_error ret;
+
+ buf = CALLOC_STRUCT(brw_buffer);
+ if (!buf)
+ return NULL;
+
+ buf->b.b = *template;
+ buf->b.vtbl = &brw_buffer_vtbl;
+ pipe_reference_init(&buf->b.b.reference, 1);
+ buf->b.b.screen = screen;
+
+ switch (template->bind & (PIPE_BIND_VERTEX_BUFFER |
+ PIPE_BIND_INDEX_BUFFER |
+ PIPE_BIND_CONSTANT_BUFFER))
+ {
+ case PIPE_BIND_VERTEX_BUFFER:
+ case PIPE_BIND_INDEX_BUFFER:
+ case (PIPE_BIND_VERTEX_BUFFER|PIPE_BIND_INDEX_BUFFER):
+ buffer_type = BRW_BUFFER_TYPE_VERTEX;
+ break;
+
+ case PIPE_BIND_CONSTANT_BUFFER:
+ buffer_type = BRW_BUFFER_TYPE_SHADER_CONSTANTS;
+ break;
+
+ default:
+ buffer_type = BRW_BUFFER_TYPE_GENERIC;
+ break;
+ }
+
+ ret = sws->bo_alloc( sws, buffer_type,
+ template->width0,
+ 64, /* alignment */
+ &buf->bo );
+ if (ret != PIPE_OK)
+ return NULL;
+
+ return &buf->b.b;
+}
+
+
+struct pipe_resource *
+brw_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind)
+{
+ struct brw_buffer *buf;
+
+ buf = CALLOC_STRUCT(brw_buffer);
+ if (!buf)
+ return NULL;
+
+ pipe_reference_init(&buf->b.b.reference, 1);
+ buf->b.vtbl = &brw_buffer_vtbl;
+ buf->b.b.screen = screen;
+ buf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */
+ buf->b.b._usage = PIPE_USAGE_IMMUTABLE;
+ buf->b.b.bind = bind;
+ buf->b.b.width0 = bytes;
+ buf->b.b.height0 = 1;
+ buf->b.b.depth0 = 1;
+
+ buf->user_buffer = ptr;
+
+ return &buf->b.b;
+}
diff --git a/src/gallium/drivers/i965/brw_screen_texture.c b/src/gallium/drivers/i965/brw_resource_texture.c
index 17bf3152dc..a6f27b8a41 100644
--- a/src/gallium/drivers/i965/brw_screen_texture.c
+++ b/src/gallium/drivers/i965/brw_resource_texture.c
@@ -37,9 +37,26 @@
#include "brw_defines.h"
#include "brw_structs.h"
#include "brw_winsys.h"
+#include "brw_batchbuffer.h"
#include "brw_context.h"
+#include "brw_resource.h"
+/**
+ * Subclass of pipe_transfer
+ */
+struct brw_transfer
+{
+ struct pipe_transfer base;
+
+ unsigned offset;
+};
+
+static INLINE struct brw_transfer *
+brw_transfer(struct pipe_transfer *transfer)
+{
+ return (struct brw_transfer *)transfer;
+}
static GLuint translate_tex_target( unsigned target )
@@ -182,12 +199,176 @@ static GLuint translate_tex_format( enum pipe_format pf )
}
+static boolean
+brw_texture_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *texture,
+ struct winsys_handle *whandle)
+{
+ struct brw_screen *bscreen = brw_screen(screen);
+ struct brw_texture *tex = brw_texture(texture);
+ unsigned stride;
+
+ stride = tex->pitch * tex->cpp;
+
+ return bscreen->sws->bo_get_handle(tex->bo, whandle, stride);
+}
+
+
+
+static void brw_texture_destroy(struct pipe_screen *screen,
+ struct pipe_resource *pt)
+{
+ struct brw_texture *tex = brw_texture(pt);
+ bo_reference(&tex->bo, NULL);
+ FREE(pt);
+}
+
+
+
+
+static unsigned brw_texture_is_referenced( struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ unsigned face,
+ unsigned level )
+{
+ struct brw_context *brw = brw_context(pipe);
+ struct brw_screen *bscreen = brw_screen(pipe->screen);
+ struct brw_winsys_buffer *batch_bo = brw->batch->buf;
+ struct brw_texture *tex = brw_texture(texture);
+ struct brw_surface *surf;
+ int i;
+
+ /* XXX: this is subject to false positives if the underlying
+ * texture BO is referenced, we can't tell whether the sub-region
+ * we care about participates in that.
+ */
+ if (bscreen->sws->bo_references( batch_bo, tex->bo ))
+ return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+
+ /* Find any view on this texture for this face/level and see if it
+ * is referenced:
+ */
+ for (i = 0; i < 2; i++) {
+ foreach (surf, &tex->views[i]) {
+ if (surf->bo == tex->bo)
+ continue;
+
+ if (surf->id.bits.face != face ||
+ surf->id.bits.level != level)
+ continue;
+
+ if (bscreen->sws->bo_references( batch_bo, surf->bo))
+ return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+ }
+ }
+
+ return PIPE_UNREFERENCED;
+}
+
+
+/*
+ * Transfer functions
+ */
+
+
+static struct pipe_transfer *
+brw_texture_get_transfer(struct pipe_context *context,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
+{
+ struct brw_texture *tex = brw_texture(resource);
+ struct pipe_transfer *transfer = CALLOC_STRUCT(pipe_transfer);
+ if (transfer == NULL)
+ return NULL;
+
+ transfer->resource = resource;
+ transfer->sr = sr;
+ transfer->usage = usage;
+ transfer->box = *box;
+ transfer->stride = tex->pitch * tex->cpp;
+
+ return transfer;
+}
+
+
+static void *
+brw_texture_transfer_map(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct pipe_resource *resource = transfer->resource;
+ struct brw_texture *tex = brw_texture(transfer->resource);
+ struct brw_winsys_screen *sws = brw_screen(pipe->screen)->sws;
+ struct pipe_subresource sr = transfer->sr;
+ struct pipe_box *box = &transfer->box;
+ enum pipe_format format = resource->format;
+ unsigned usage = transfer->usage;
+ unsigned offset;
+ char *map;
+
+ if (resource->target == PIPE_TEXTURE_CUBE) {
+ offset = tex->image_offset[sr.level][sr.face];
+ }
+ else if (resource->target == PIPE_TEXTURE_3D) {
+ offset = tex->image_offset[sr.level][box->z];
+ }
+ else {
+ offset = tex->image_offset[sr.level][0];
+ assert(sr.face == 0);
+ assert(box->z == 0);
+ }
+
+ map = sws->bo_map(tex->bo,
+ BRW_DATA_OTHER,
+ 0,
+ tex->bo->size,
+ (usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE,
+ (usage & 0) ? TRUE : FALSE,
+ (usage & 0) ? TRUE : FALSE);
+
+ if (!map)
+ return NULL;
+
+ return map + offset +
+ box->y / util_format_get_blockheight(format) * transfer->stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+}
+
+static void
+brw_texture_transfer_unmap(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct brw_texture *tex = brw_texture(transfer->resource);
+ struct brw_winsys_screen *sws = brw_screen(pipe->screen)->sws;
+
+ sws->bo_unmap(tex->bo);
+}
+
+
+
+
+
+struct u_resource_vtbl brw_texture_vtbl =
+{
+ brw_texture_get_handle, /* get_handle */
+ brw_texture_destroy, /* resource_destroy */
+ brw_texture_is_referenced, /* is_resource_referenced */
+ brw_texture_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ brw_texture_transfer_map, /* transfer_map */
+ u_default_transfer_flush_region, /* transfer_flush_region */
+ brw_texture_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
-static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
- const struct pipe_texture *templ )
+
+struct pipe_resource *
+brw_texture_create( struct pipe_screen *screen,
+ const struct pipe_resource *template )
{
struct brw_screen *bscreen = brw_screen(screen);
struct brw_texture *tex;
@@ -199,14 +380,15 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
if (tex == NULL)
return NULL;
- memcpy(&tex->base, templ, sizeof *templ);
- pipe_reference_init(&tex->base.reference, 1);
- tex->base.screen = screen;
+ tex->b.b = *template;
+ tex->b.vtbl = &brw_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
/* XXX: compressed textures need special treatment here
*/
- tex->cpp = util_format_get_blocksize(tex->base.format);
- tex->compressed = util_format_is_s3tc(tex->base.format);
+ tex->cpp = util_format_get_blocksize(tex->b.b.format);
+ tex->compressed = util_format_is_s3tc(tex->b.b.format);
make_empty_list(&tex->views[0]);
make_empty_list(&tex->views[1]);
@@ -217,7 +399,7 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
!bscreen->no_tiling)
{
if (bscreen->chipset.is_965 &&
- util_format_is_depth_or_stencil(templ->format))
+ util_format_is_depth_or_stencil(template->format))
tex->tiling = BRW_TILING_Y;
else
tex->tiling = BRW_TILING_X;
@@ -227,14 +409,12 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
}
-
-
if (!brw_texture_layout( bscreen, tex ))
goto fail;
- if (templ->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) {
+ if (template->bind & (PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) {
buffer_type = BRW_BUFFER_TYPE_SCANOUT;
}
else {
@@ -250,9 +430,9 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
goto fail;
tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
- tex->ss.ss0.surface_type = translate_tex_target(tex->base.target);
+ tex->ss.ss0.surface_type = translate_tex_target(tex->b.b.target);
- format = translate_tex_format(tex->base.format);
+ format = translate_tex_format(tex->b.b.format);
assert(format != BRW_SURFACEFORMAT_INVALID);
tex->ss.ss0.surface_format = format;
@@ -264,9 +444,9 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
/* XXX: what happens when tex->bo->offset changes???
*/
tex->ss.ss1.base_addr = 0; /* reloc */
- tex->ss.ss2.mip_count = tex->base.last_level;
- tex->ss.ss2.width = tex->base.width0 - 1;
- tex->ss.ss2.height = tex->base.height0 - 1;
+ tex->ss.ss2.mip_count = tex->b.b.last_level;
+ tex->ss.ss2.width = tex->b.b.width0 - 1;
+ tex->ss.ss2.height = tex->b.b.height0 - 1;
switch (tex->tiling) {
case BRW_TILING_NONE:
@@ -284,11 +464,11 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
}
tex->ss.ss3.pitch = (tex->pitch * tex->cpp) - 1;
- tex->ss.ss3.depth = tex->base.depth0 - 1;
+ tex->ss.ss3.depth = tex->b.b.depth0 - 1;
tex->ss.ss4.min_lod = 0;
- if (tex->base.target == PIPE_TEXTURE_CUBE) {
+ if (tex->b.b.target == PIPE_TEXTURE_CUBE) {
tex->ss.ss0.cube_pos_x = 1;
tex->ss.ss0.cube_pos_y = 1;
tex->ss.ss0.cube_pos_z = 1;
@@ -297,7 +477,7 @@ static struct pipe_texture *brw_texture_create( struct pipe_screen *screen,
tex->ss.ss0.cube_neg_z = 1;
}
- return &tex->base;
+ return &tex->b.b;
fail:
bo_reference(&tex->bo, NULL);
@@ -305,9 +485,10 @@ fail:
return NULL;
}
-static struct pipe_texture *
+
+struct pipe_resource *
brw_texture_from_handle(struct pipe_screen *screen,
- const struct pipe_texture *templ,
+ const struct pipe_resource *template,
struct winsys_handle *whandle)
{
struct brw_screen *bscreen = brw_screen(screen);
@@ -317,12 +498,12 @@ brw_texture_from_handle(struct pipe_screen *screen,
unsigned pitch;
GLuint format;
- if (templ->target != PIPE_TEXTURE_2D ||
- templ->last_level != 0 ||
- templ->depth0 != 1)
+ if (template->target != PIPE_TEXTURE_2D ||
+ template->last_level != 0 ||
+ template->depth0 != 1)
return NULL;
- if (util_format_is_s3tc(templ->format))
+ if (util_format_is_s3tc(template->format))
return NULL;
tex = CALLOC_STRUCT(brw_texture);
@@ -332,13 +513,14 @@ brw_texture_from_handle(struct pipe_screen *screen,
if (bscreen->sws->bo_from_handle(bscreen->sws, whandle, &pitch, &tiling, &buffer) != PIPE_OK)
goto fail;
- memcpy(&tex->base, templ, sizeof *templ);
- pipe_reference_init(&tex->base.reference, 1);
- tex->base.screen = screen;
+ tex->b.b = *template;
+ tex->b.vtbl = &brw_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
/* XXX: cpp vs. blocksize
*/
- tex->cpp = util_format_get_blocksize(tex->base.format);
+ tex->cpp = util_format_get_blocksize(tex->b.b.format);
tex->tiling = tiling;
make_empty_list(&tex->views[0]);
@@ -362,11 +544,12 @@ brw_texture_from_handle(struct pipe_screen *screen,
#endif
tex->ss.ss0.mipmap_layout_mode = BRW_SURFACE_MIPMAPLAYOUT_BELOW;
- tex->ss.ss0.surface_type = translate_tex_target(tex->base.target);
+ tex->ss.ss0.surface_type = translate_tex_target(tex->b.b.target);
- format = translate_tex_format(tex->base.format);
+ format = translate_tex_format(tex->b.b.format);
assert(format != BRW_SURFACEFORMAT_INVALID);
tex->ss.ss0.surface_format = format;
+ assert(tex->ss.ss0.surface_format != BRW_SURFACEFORMAT_INVALID);
/* This is ok for all textures with channel width 8bit or less:
*/
@@ -376,9 +559,9 @@ brw_texture_from_handle(struct pipe_screen *screen,
/* XXX: what happens when tex->bo->offset changes???
*/
tex->ss.ss1.base_addr = 0; /* reloc */
- tex->ss.ss2.mip_count = tex->base.last_level;
- tex->ss.ss2.width = tex->base.width0 - 1;
- tex->ss.ss2.height = tex->base.height0 - 1;
+ tex->ss.ss2.mip_count = tex->b.b.last_level;
+ tex->ss.ss2.width = tex->b.b.width0 - 1;
+ tex->ss.ss2.height = tex->b.b.height0 - 1;
switch (tex->tiling) {
case BRW_TILING_NONE:
@@ -396,187 +579,25 @@ brw_texture_from_handle(struct pipe_screen *screen,
}
tex->ss.ss3.pitch = (tex->pitch * tex->cpp) - 1;
- tex->ss.ss3.depth = tex->base.depth0 - 1;
+ tex->ss.ss3.depth = tex->b.b.depth0 - 1;
tex->ss.ss4.min_lod = 0;
- return &tex->base;
+ return &tex->b.b;
fail:
FREE(tex);
return NULL;
}
-static boolean
-brw_texture_get_handle(struct pipe_screen *screen,
- struct pipe_texture *texture,
- struct winsys_handle *whandle)
-{
- struct brw_screen *bscreen = brw_screen(screen);
- struct brw_texture *tex = brw_texture(texture);
- unsigned stride;
-
- stride = tex->pitch * tex->cpp;
- return bscreen->sws->bo_get_handle(tex->bo, whandle, stride);
-}
-
-
-
-static void brw_texture_destroy(struct pipe_texture *pt)
-{
- struct brw_texture *tex = brw_texture(pt);
- bo_reference(&tex->bo, NULL);
- FREE(pt);
-}
-
-
-static boolean brw_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format,
- enum pipe_texture_target target,
- unsigned tex_usage,
- unsigned geom_flags )
+#if 0
+boolean brw_is_format_supported( struct pipe_screen *screen,
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags )
{
return translate_tex_format(format) != BRW_SURFACEFORMAT_INVALID;
}
-
-
-boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen,
- struct pipe_texture *texture,
- unsigned face,
- unsigned level,
- struct brw_winsys_buffer *bo )
-{
- struct brw_texture *tex = brw_texture(texture);
- struct brw_surface *surf;
- int i;
-
- /* XXX: this is subject to false positives if the underlying
- * texture BO is referenced, we can't tell whether the sub-region
- * we care about participates in that.
- */
- if (brw_screen->sws->bo_references( bo, tex->bo ))
- return TRUE;
-
- /* Find any view on this texture for this face/level and see if it
- * is referenced:
- */
- for (i = 0; i < 2; i++) {
- foreach (surf, &tex->views[i]) {
- if (surf->bo == tex->bo)
- continue;
-
- if (surf->id.bits.face != face ||
- surf->id.bits.level != level)
- continue;
-
- if (brw_screen->sws->bo_references( bo, surf->bo))
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-
-/*
- * Transfer functions
- */
-
-static struct pipe_transfer*
-brw_get_tex_transfer(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage, unsigned x, unsigned y,
- unsigned w, unsigned h)
-{
- struct brw_texture *tex = brw_texture(texture);
- struct brw_transfer *trans;
- unsigned offset; /* in bytes */
-
- if (texture->target == PIPE_TEXTURE_CUBE) {
- offset = tex->image_offset[level][face];
- } else if (texture->target == PIPE_TEXTURE_3D) {
- offset = tex->image_offset[level][zslice];
- } else {
- offset = tex->image_offset[level][0];
- assert(face == 0);
- assert(zslice == 0);
- }
-
- trans = CALLOC_STRUCT(brw_transfer);
- if (trans) {
- pipe_texture_reference(&trans->base.texture, texture);
- trans->base.x = x;
- trans->base.y = y;
- trans->base.width = w;
- trans->base.height = h;
- trans->base.stride = tex->pitch * tex->cpp;
- trans->offset = offset;
- trans->base.usage = usage;
- }
- return &trans->base;
-}
-
-static void *
-brw_transfer_map(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct brw_texture *tex = brw_texture(transfer->texture);
- struct brw_winsys_screen *sws = brw_screen(pipe->screen)->sws;
- char *map;
- unsigned usage = transfer->usage;
-
- map = sws->bo_map(tex->bo,
- BRW_DATA_OTHER,
- 0,
- tex->bo->size,
- (usage & PIPE_TRANSFER_WRITE) ? TRUE : FALSE,
- (usage & 0) ? TRUE : FALSE,
- (usage & 0) ? TRUE : FALSE);
-
- if (!map)
- return NULL;
-
- /* XXX: blocksize and compressed textures
- */
- return map + brw_transfer(transfer)->offset +
- transfer->y /* / transfer->block.height */ * transfer->stride +
- transfer->x /* / transfer->block.width */ * brw_texture(transfer->texture)->cpp;
-}
-
-static void
-brw_transfer_unmap(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct brw_texture *tex = brw_texture(transfer->texture);
- struct brw_winsys_screen *sws = brw_screen(pipe->screen)->sws;
-
- sws->bo_unmap(tex->bo);
-}
-
-static void
-brw_tex_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *trans)
-{
- pipe_texture_reference(&trans->texture, NULL);
- FREE(trans);
-}
-
-
-void brw_tex_init( struct brw_context *brw )
-{
- brw->base.get_tex_transfer = brw_get_tex_transfer;
- brw->base.transfer_map = brw_transfer_map;
- brw->base.transfer_unmap = brw_transfer_unmap;
- brw->base.tex_transfer_destroy = brw_tex_transfer_destroy;
-}
-
-void brw_screen_tex_init( struct brw_screen *brw_screen )
-{
- brw_screen->base.is_format_supported = brw_is_format_supported;
- brw_screen->base.texture_create = brw_texture_create;
- brw_screen->base.texture_from_handle = brw_texture_from_handle;
- brw_screen->base.texture_get_handle = brw_texture_get_handle;
- brw_screen->base.texture_destroy = brw_texture_destroy;
-}
+#endif
diff --git a/src/gallium/drivers/i965/brw_screen_tex_layout.c b/src/gallium/drivers/i965/brw_resource_texture_layout.c
index 894f4bea40..2187bdd82c 100644
--- a/src/gallium/drivers/i965/brw_screen_tex_layout.c
+++ b/src/gallium/drivers/i965/brw_resource_texture_layout.c
@@ -30,7 +30,7 @@
#include "util/u_math.h"
#include "util/u_memory.h"
-#include "brw_screen.h"
+#include "brw_resource.h"
#include "brw_debug.h"
#include "brw_winsys.h"
@@ -143,14 +143,14 @@ static void brw_layout_2d( struct brw_texture *tex )
GLuint level;
GLuint x = 0;
GLuint y = 0;
- GLuint width = tex->base.width0;
- GLuint height = tex->base.height0;
+ GLuint width = tex->b.b.width0;
+ GLuint height = tex->b.b.height0;
- tex->pitch = tex->base.width0;
- brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
+ tex->pitch = tex->b.b.width0;
+ brw_tex_alignment_unit(tex->b.b.format, &align_w, &align_h);
if (tex->compressed) {
- tex->pitch = align(tex->base.width0, align_w);
+ tex->pitch = align(tex->b.b.width0, align_w);
}
/* May need to adjust pitch to accomodate the placement of
@@ -158,15 +158,15 @@ static void brw_layout_2d( struct brw_texture *tex )
* constraints of mipmap placement push the right edge of the
* 2nd mipmap out past the width of its parent.
*/
- if (tex->base.last_level > 0) {
+ if (tex->b.b.last_level > 0) {
GLuint mip1_width;
if (tex->compressed) {
- mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
- align(u_minify(tex->base.width0, 2), align_w));
+ mip1_width = (align(u_minify(tex->b.b.width0, 1), align_w) +
+ align(u_minify(tex->b.b.width0, 2), align_w));
} else {
- mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
- u_minify(tex->base.width0, 2));
+ mip1_width = (align(u_minify(tex->b.b.width0, 1), align_w) +
+ u_minify(tex->b.b.width0, 2));
}
if (mip1_width > tex->pitch) {
@@ -180,7 +180,7 @@ static void brw_layout_2d( struct brw_texture *tex )
tex->pitch = brw_tex_pitch_align (tex, tex->pitch);
tex->total_height = 0;
- for ( level = 0 ; level <= tex->base.last_level ; level++ ) {
+ for ( level = 0 ; level <= tex->b.b.last_level ; level++ ) {
GLuint img_height;
brw_tex_set_level_info(tex, level, 1, x, y, width, height, 1);
@@ -218,28 +218,28 @@ brw_layout_cubemap_idgng( struct brw_texture *tex )
GLuint level;
GLuint x = 0;
GLuint y = 0;
- GLuint width = tex->base.width0;
- GLuint height = tex->base.height0;
+ GLuint width = tex->b.b.width0;
+ GLuint height = tex->b.b.height0;
GLuint qpitch = 0;
GLuint y_pitch = 0;
- tex->pitch = tex->base.width0;
- brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
+ tex->pitch = tex->b.b.width0;
+ brw_tex_alignment_unit(tex->b.b.format, &align_w, &align_h);
y_pitch = align(height, align_h);
if (tex->compressed) {
- tex->pitch = align(tex->base.width0, align_w);
+ tex->pitch = align(tex->b.b.width0, align_w);
}
- if (tex->base.last_level != 0) {
+ if (tex->b.b.last_level != 0) {
GLuint mip1_width;
if (tex->compressed) {
- mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
- align(u_minify(tex->base.width0, 2), align_w));
+ mip1_width = (align(u_minify(tex->b.b.width0, 1), align_w) +
+ align(u_minify(tex->b.b.width0, 2), align_w));
} else {
- mip1_width = (align(u_minify(tex->base.width0, 1), align_w) +
- u_minify(tex->base.width0, 2));
+ mip1_width = (align(u_minify(tex->b.b.width0, 1), align_w) +
+ u_minify(tex->b.b.width0, 2));
}
if (mip1_width > tex->pitch) {
@@ -267,7 +267,7 @@ brw_layout_cubemap_idgng( struct brw_texture *tex )
11 * align_h) * 6;
}
- for (level = 0; level <= tex->base.last_level; level++) {
+ for (level = 0; level <= tex->b.b.last_level; level++) {
GLuint img_height;
GLuint nr_images = 6;
GLuint q = 0;
@@ -300,9 +300,9 @@ brw_layout_cubemap_idgng( struct brw_texture *tex )
static boolean
brw_layout_3d_cube( struct brw_texture *tex )
{
- GLuint width = tex->base.width0;
- GLuint height = tex->base.height0;
- GLuint depth = tex->base.depth0;
+ GLuint width = tex->b.b.width0;
+ GLuint height = tex->b.b.height0;
+ GLuint depth = tex->b.b.depth0;
GLuint pack_x_pitch, pack_x_nr;
GLuint pack_y_pitch;
GLuint level;
@@ -310,21 +310,21 @@ brw_layout_3d_cube( struct brw_texture *tex )
GLuint align_w = 4;
tex->total_height = 0;
- brw_tex_alignment_unit(tex->base.format, &align_w, &align_h);
+ brw_tex_alignment_unit(tex->b.b.format, &align_w, &align_h);
if (tex->compressed) {
tex->pitch = align(width, align_w);
pack_y_pitch = (height + 3) / 4;
} else {
- tex->pitch = brw_tex_pitch_align(tex, tex->base.width0);
- pack_y_pitch = align(tex->base.height0, align_h);
+ tex->pitch = brw_tex_pitch_align(tex, tex->b.b.width0);
+ pack_y_pitch = align(tex->b.b.height0, align_h);
}
pack_x_pitch = width;
pack_x_nr = 1;
- for (level = 0 ; level <= tex->base.last_level ; level++) {
- GLuint nr_images = tex->base.target == PIPE_TEXTURE_3D ? depth : 6;
+ for (level = 0 ; level <= tex->b.b.last_level ; level++) {
+ GLuint nr_images = tex->b.b.target == PIPE_TEXTURE_3D ? depth : 6;
GLint x = 0;
GLint y = 0;
GLint q, j;
@@ -375,7 +375,7 @@ brw_layout_3d_cube( struct brw_texture *tex )
* memory. As a result, the docs say in Surface Padding Requirements:
* Sampling Engine Surfaces that two extra rows of padding are required.
*/
- if (tex->base.target == PIPE_TEXTURE_CUBE)
+ if (tex->b.b.target == PIPE_TEXTURE_CUBE)
tex->total_height += 2;
return TRUE;
@@ -386,7 +386,7 @@ brw_layout_3d_cube( struct brw_texture *tex )
GLboolean brw_texture_layout(struct brw_screen *brw_screen,
struct brw_texture *tex )
{
- switch (tex->base.target) {
+ switch (tex->b.b.target) {
case PIPE_TEXTURE_CUBE:
if (brw_screen->chipset.is_igdng)
brw_layout_cubemap_idgng( tex );
diff --git a/src/gallium/drivers/i965/brw_screen.c b/src/gallium/drivers/i965/brw_screen.c
index ba30e63f20..0a7151bde4 100644
--- a/src/gallium/drivers/i965/brw_screen.c
+++ b/src/gallium/drivers/i965/brw_screen.c
@@ -35,6 +35,7 @@
#include "brw_screen.h"
#include "brw_winsys.h"
#include "brw_debug.h"
+#include "brw_resource.h"
#ifdef DEBUG
static const struct debug_named_value debug_names[] = {
@@ -275,9 +276,9 @@ brw_is_format_supported(struct pipe_screen *screen,
const enum pipe_format *list;
uint i;
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
+ if (tex_usage & PIPE_BIND_DEPTH_STENCIL)
list = depth_supported;
- else if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ else if (tex_usage & PIPE_BIND_RENDER_TARGET)
list = render_supported;
else
list = tex_supported;
@@ -406,9 +407,8 @@ brw_create_screen(struct brw_winsys_screen *sws, uint pci_id)
bscreen->base.fence_signalled = brw_fence_signalled;
bscreen->base.fence_finish = brw_fence_finish;
- brw_screen_tex_init(bscreen);
+ brw_init_screen_resource_functions(bscreen);
brw_screen_tex_surface_init(bscreen);
- brw_screen_buffer_init(bscreen);
bscreen->no_tiling = debug_get_option("BRW_NO_TILING", FALSE) != NULL;
diff --git a/src/gallium/drivers/i965/brw_screen.h b/src/gallium/drivers/i965/brw_screen.h
index e3a7c64d48..522a3bf899 100644
--- a/src/gallium/drivers/i965/brw_screen.h
+++ b/src/gallium/drivers/i965/brw_screen.h
@@ -48,30 +48,6 @@ struct brw_screen
boolean no_tiling;
};
-/**
- * Subclass of pipe_transfer
- */
-struct brw_transfer
-{
- struct pipe_transfer base;
-
- unsigned offset;
-};
-
-struct brw_buffer
-{
- struct pipe_buffer base;
-
- /* One of either bo or user_buffer will be non-null, depending on
- * whether this is a hardware or user buffer.
- */
- struct brw_winsys_buffer *bo;
- void *user_buffer;
-
- /* Mapped pointer??
- */
- void *ptr;
-};
union brw_surface_id {
@@ -100,31 +76,6 @@ struct brw_surface
};
-#define BRW_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */
-#define BRW_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */
-
-
-struct brw_texture
-{
- struct pipe_texture base;
- struct brw_winsys_buffer *bo;
- struct brw_surface_state ss;
-
- unsigned *image_offset[BRW_MAX_TEXTURE_2D_LEVELS];
- unsigned nr_images[BRW_MAX_TEXTURE_2D_LEVELS];
- unsigned level_offset[BRW_MAX_TEXTURE_2D_LEVELS];
-
- boolean compressed;
- unsigned brw_target;
- unsigned pitch;
- unsigned tiling;
- unsigned cpp;
- unsigned total_height;
-
- struct brw_surface views[2];
-};
-
-
/*
* Cast wrappers
@@ -135,11 +86,6 @@ brw_screen(struct pipe_screen *pscreen)
return (struct brw_screen *) pscreen;
}
-static INLINE struct brw_transfer *
-brw_transfer(struct pipe_transfer *transfer)
-{
- return (struct brw_transfer *)transfer;
-}
static INLINE struct brw_surface *
brw_surface(struct pipe_surface *surface)
@@ -147,60 +93,10 @@ brw_surface(struct pipe_surface *surface)
return (struct brw_surface *)surface;
}
-static INLINE struct brw_buffer *
-brw_buffer(struct pipe_buffer *buffer)
-{
- return (struct brw_buffer *)buffer;
-}
-
-static INLINE struct brw_texture *
-brw_texture(struct pipe_texture *texture)
-{
- return (struct brw_texture *)texture;
-}
-
-
-/* Pipe buffer helpers
- */
-static INLINE boolean
-brw_buffer_is_user_buffer( const struct pipe_buffer *buf )
-{
- return ((const struct brw_buffer *)buf)->user_buffer != NULL;
-}
-
unsigned
brw_surface_pitch( const struct pipe_surface *surface );
-/***********************************************************************
- * Internal functions
- */
-GLboolean brw_texture_layout(struct brw_screen *brw_screen,
- struct brw_texture *tex );
-
-void brw_update_texture( struct brw_screen *brw_screen,
- struct brw_texture *tex );
-
-
-/* brw_screen_texture.h
- */
-struct brw_context;
-void brw_tex_init( struct brw_context *brw );
-void brw_screen_tex_init( struct brw_screen *brw_screen );
void brw_screen_tex_surface_init( struct brw_screen *brw_screen );
-void brw_screen_buffer_init(struct brw_screen *brw_screen);
-
-
-boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen,
- struct pipe_texture *texture,
- unsigned face,
- unsigned level,
- struct brw_winsys_buffer *bo );
-
-boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen,
- struct pipe_buffer *buffer,
- struct brw_winsys_buffer *bo );
-
-
#endif /* BRW_SCREEN_H */
diff --git a/src/gallium/drivers/i965/brw_screen_buffers.c b/src/gallium/drivers/i965/brw_screen_buffers.c
deleted file mode 100644
index 0b38885f40..0000000000
--- a/src/gallium/drivers/i965/brw_screen_buffers.c
+++ /dev/null
@@ -1,202 +0,0 @@
-
-#include "util/u_memory.h"
-#include "util/u_math.h"
-
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
-
-#include "brw_screen.h"
-#include "brw_winsys.h"
-
-
-
-static void *
-brw_buffer_map_range( struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned offset,
- unsigned length,
- unsigned usage )
-{
- struct brw_screen *bscreen = brw_screen(screen);
- struct brw_winsys_screen *sws = bscreen->sws;
- struct brw_buffer *buf = brw_buffer( buffer );
-
- if (buf->user_buffer)
- return buf->user_buffer;
-
- return sws->bo_map( buf->bo,
- BRW_DATA_OTHER,
- offset,
- length,
- (usage & PIPE_BUFFER_USAGE_CPU_WRITE) ? TRUE : FALSE,
- (usage & PIPE_BUFFER_USAGE_DISCARD) ? TRUE : FALSE,
- (usage & PIPE_BUFFER_USAGE_FLUSH_EXPLICIT) ? TRUE : FALSE);
-}
-
-static void *
-brw_buffer_map( struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned usage )
-{
- struct brw_screen *bscreen = brw_screen(screen);
- struct brw_winsys_screen *sws = bscreen->sws;
- struct brw_buffer *buf = brw_buffer( buffer );
-
- if (buf->user_buffer)
- return buf->user_buffer;
-
- return sws->bo_map( buf->bo,
- BRW_DATA_OTHER,
- 0,
- buf->base.size,
- (usage & PIPE_BUFFER_USAGE_CPU_WRITE) ? TRUE : FALSE,
- FALSE,
- FALSE);
-}
-
-
-static void
-brw_buffer_flush_mapped_range( struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned offset,
- unsigned length )
-{
- struct brw_screen *bscreen = brw_screen(screen);
- struct brw_winsys_screen *sws = bscreen->sws;
- struct brw_buffer *buf = brw_buffer( buffer );
-
- if (buf->user_buffer)
- return;
-
- sws->bo_flush_range( buf->bo,
- offset,
- length );
-}
-
-
-static void
-brw_buffer_unmap( struct pipe_screen *screen,
- struct pipe_buffer *buffer )
-{
- struct brw_screen *bscreen = brw_screen(screen);
- struct brw_winsys_screen *sws = bscreen->sws;
- struct brw_buffer *buf = brw_buffer( buffer );
-
- if (buf->bo)
- sws->bo_unmap(buf->bo);
-}
-
-static void
-brw_buffer_destroy( struct pipe_buffer *buffer )
-{
- struct brw_buffer *buf = brw_buffer( buffer );
-
- assert(!p_atomic_read(&buffer->reference.count));
-
- bo_reference(&buf->bo, NULL);
- FREE(buf);
-}
-
-
-static struct pipe_buffer *
-brw_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct brw_screen *bscreen = brw_screen(screen);
- struct brw_winsys_screen *sws = bscreen->sws;
- struct brw_buffer *buf;
- unsigned buffer_type;
- enum pipe_error ret;
-
- buf = CALLOC_STRUCT(brw_buffer);
- if (!buf)
- return NULL;
-
- pipe_reference_init(&buf->base.reference, 1);
- buf->base.screen = screen;
- buf->base.alignment = alignment;
- buf->base.usage = usage;
- buf->base.size = size;
-
- switch (usage & (PIPE_BUFFER_USAGE_VERTEX |
- PIPE_BUFFER_USAGE_INDEX |
- PIPE_BUFFER_USAGE_PIXEL |
- PIPE_BUFFER_USAGE_CONSTANT))
- {
- case PIPE_BUFFER_USAGE_VERTEX:
- case PIPE_BUFFER_USAGE_INDEX:
- case (PIPE_BUFFER_USAGE_VERTEX|PIPE_BUFFER_USAGE_INDEX):
- buffer_type = BRW_BUFFER_TYPE_VERTEX;
- break;
-
- case PIPE_BUFFER_USAGE_PIXEL:
- buffer_type = BRW_BUFFER_TYPE_PIXEL;
- break;
-
- case PIPE_BUFFER_USAGE_CONSTANT:
- buffer_type = BRW_BUFFER_TYPE_SHADER_CONSTANTS;
- break;
-
- default:
- buffer_type = BRW_BUFFER_TYPE_GENERIC;
- break;
- }
-
- ret = sws->bo_alloc( sws, buffer_type,
- size, alignment,
- &buf->bo );
- if (ret != PIPE_OK)
- return NULL;
-
- return &buf->base;
-}
-
-
-static struct pipe_buffer *
-brw_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct brw_buffer *buf;
-
- buf = CALLOC_STRUCT(brw_buffer);
- if (!buf)
- return NULL;
-
- buf->user_buffer = ptr;
-
- pipe_reference_init(&buf->base.reference, 1);
- buf->base.screen = screen;
- buf->base.alignment = 1;
- buf->base.usage = 0;
- buf->base.size = bytes;
-
- return &buf->base;
-}
-
-
-boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen,
- struct pipe_buffer *buffer,
- struct brw_winsys_buffer *bo )
-{
- struct brw_buffer *buf = brw_buffer(buffer);
- if (buf->bo == NULL)
- return FALSE;
-
- return brw_screen->sws->bo_references( bo, buf->bo );
-}
-
-
-void brw_screen_buffer_init(struct brw_screen *brw_screen)
-{
- brw_screen->base.buffer_create = brw_buffer_create;
- brw_screen->base.user_buffer_create = brw_user_buffer_create;
- brw_screen->base.buffer_map = brw_buffer_map;
- brw_screen->base.buffer_map_range = brw_buffer_map_range;
- brw_screen->base.buffer_flush_mapped_range = brw_buffer_flush_mapped_range;
- brw_screen->base.buffer_unmap = brw_buffer_unmap;
- brw_screen->base.buffer_destroy = brw_buffer_destroy;
-}
diff --git a/src/gallium/drivers/i965/brw_screen_surface.c b/src/gallium/drivers/i965/brw_screen_surface.c
index 904df813dd..f288fdbcd3 100644
--- a/src/gallium/drivers/i965/brw_screen_surface.c
+++ b/src/gallium/drivers/i965/brw_screen_surface.c
@@ -36,6 +36,7 @@
#include "pipe/p_screen.h"
#include "brw_screen.h"
#include "brw_defines.h"
+#include "brw_resource.h"
#include "brw_winsys.h"
enum {
@@ -138,9 +139,9 @@ static struct brw_surface *create_in_place_view( struct brw_screen *brw_screen,
*/
assert(id.bits.zslice == 0);
- surface->base.format = tex->base.format;
- surface->base.width = u_minify(tex->base.width0, id.bits.level);
- surface->base.height = u_minify(tex->base.height0, id.bits.level);
+ surface->base.format = tex->b.b.format;
+ surface->base.width = u_minify(tex->b.b.width0, id.bits.level);
+ surface->base.height = u_minify(tex->b.b.height0, id.bits.level);
surface->base.offset = tex->image_offset[id.bits.level][id.bits.face];
surface->base.usage = usage;
surface->base.zslice = id.bits.zslice;
@@ -152,7 +153,7 @@ static struct brw_surface *create_in_place_view( struct brw_screen *brw_screen,
surface->tiling = tex->tiling;
bo_reference( &surface->bo, tex->bo );
- pipe_texture_reference( &surface->base.texture, &tex->base );
+ pipe_resource_reference( &surface->base.texture, &tex->b.b );
surface->ss.ss0.surface_format = tex->ss.ss0.surface_format;
surface->ss.ss0.surface_type = BRW_SURFACE_2D;
@@ -198,7 +199,7 @@ static struct brw_surface *create_in_place_view( struct brw_screen *brw_screen,
/* Get a surface which is view into a texture
*/
static struct pipe_surface *brw_get_tex_surface(struct pipe_screen *screen,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned face, unsigned level,
unsigned zslice,
unsigned usage )
@@ -246,7 +247,7 @@ static void brw_tex_surface_destroy( struct pipe_surface *surf )
*/
remove_from_list(surface);
bo_reference(&surface->bo, NULL);
- pipe_texture_reference( &surface->base.texture, NULL );
+ pipe_resource_reference( &surface->base.texture, NULL );
FREE(surface);
diff --git a/src/gallium/drivers/i965/brw_util.c b/src/gallium/drivers/i965/brw_util.c
deleted file mode 100644
index 1fd2e29713..0000000000
--- a/src/gallium/drivers/i965/brw_util.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- Copyright (C) Intel Corp. 2006. All Rights Reserved.
- Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
- develop this 3D driver.
-
- Permission is hereby granted, free of charge, to any person obtaining
- a copy of this software and associated documentation files (the
- "Software"), to deal in the Software without restriction, including
- without limitation the rights to use, copy, modify, merge, publish,
- distribute, sublicense, and/or sell copies of the Software, and to
- permit persons to whom the Software is furnished to do so, subject to
- the following conditions:
-
- The above copyright notice and this permission notice (including the
- next paragraph) shall be included in all copies or substantial
- portions of the Software.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
- **********************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- */
-
-
-
-
-
-
diff --git a/src/gallium/drivers/i965/brw_vs_surface_state.c b/src/gallium/drivers/i965/brw_vs_surface_state.c
index 004e3cb4e6..424bb0d0df 100644
--- a/src/gallium/drivers/i965/brw_vs_surface_state.c
+++ b/src/gallium/drivers/i965/brw_vs_surface_state.c
@@ -82,7 +82,7 @@ brw_update_vs_constant_surface( struct brw_context *brw,
GLuint surf)
{
struct brw_surface_key key;
- struct pipe_buffer *cb = brw->curr.vs_constants;
+ struct pipe_resource *cb = brw->curr.vs_constants;
enum pipe_error ret;
assert(surf == 0);
diff --git a/src/gallium/drivers/i965/brw_wm.c b/src/gallium/drivers/i965/brw_wm.c
index 7ed2378ec0..5d66e61fbc 100644
--- a/src/gallium/drivers/i965/brw_wm.c
+++ b/src/gallium/drivers/i965/brw_wm.c
@@ -35,6 +35,7 @@
#include "brw_wm.h"
#include "brw_state.h"
#include "brw_debug.h"
+#include "brw_resource.h"
#include "brw_pipe_rast.h"
@@ -254,10 +255,10 @@ static void brw_wm_populate_key( struct brw_context *brw,
for (i = 0; i < brw->curr.num_fragment_sampler_views; i++) {
const struct brw_texture *tex = brw_texture(brw->curr.fragment_sampler_views[i]->texture);
- if (tex->base.format == PIPE_FORMAT_UYVY)
+ if (tex->b.b.format == PIPE_FORMAT_UYVY)
key->yuvtex_mask |= 1 << i;
- if (tex->base.format == PIPE_FORMAT_YUYV)
+ if (tex->b.b.format == PIPE_FORMAT_YUYV)
key->yuvtex_swap_mask |= 1 << i;
/* XXX: shadow texture
diff --git a/src/gallium/drivers/i965/brw_wm_constant_buffer.c b/src/gallium/drivers/i965/brw_wm_constant_buffer.c
index 6434c6acf7..df5cd0398c 100644
--- a/src/gallium/drivers/i965/brw_wm_constant_buffer.c
+++ b/src/gallium/drivers/i965/brw_wm_constant_buffer.c
@@ -62,7 +62,7 @@ brw_update_wm_constant_surface( struct brw_context *brw,
{
struct brw_surface_key key;
struct brw_fragment_shader *fp = brw->curr.fragment_shader;
- struct pipe_buffer *cbuf = brw->curr.fragment_constants;
+ struct pipe_resource *cbuf = brw->curr.fragment_constants;
int pitch = cbuf->size / (4 * sizeof(float));
enum pipe_error ret;
diff --git a/src/gallium/drivers/i965/brw_wm_sampler_state.c b/src/gallium/drivers/i965/brw_wm_sampler_state.c
index 3f18062c58..8406a1a9e2 100644
--- a/src/gallium/drivers/i965/brw_wm_sampler_state.c
+++ b/src/gallium/drivers/i965/brw_wm_sampler_state.c
@@ -35,7 +35,7 @@
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "brw_screen.h"
+#include "brw_resource.h"
/* Samplers aren't strictly wm state from the hardware's perspective,
@@ -94,7 +94,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
/* Cube-maps on 965 and later must use the same wrap mode for all 3
* coordinate dimensions. Futher, only CUBE and CLAMP are valid.
*/
- if (tex->base.target == PIPE_TEXTURE_CUBE) {
+ if (tex->b.b.target == PIPE_TEXTURE_CUBE) {
if (FALSE &&
(sampler->ss0.min_filter != BRW_MAPFILTER_NEAREST ||
sampler->ss0.mag_filter != BRW_MAPFILTER_NEAREST)) {
@@ -106,7 +106,7 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
entry->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
entry->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
}
- } else if (tex->base.target == PIPE_TEXTURE_1D) {
+ } else if (tex->b.b.target == PIPE_TEXTURE_1D) {
/* There's a bug in 1D texture sampling - it actually pays
* attention to the wrap_t value, though it should not.
* Override the wrap_t value here to GL_REPEAT to keep
@@ -137,7 +137,7 @@ brw_wm_sampler_update_default_colors(struct brw_context *brw)
sampler->border_color[0]
};
- if (util_format_is_depth_or_stencil(tex->base.format)) {
+ if (util_format_is_depth_or_stencil(tex->b.b.format)) {
bc = bordercolor;
}
else {
diff --git a/src/gallium/drivers/i965/brw_wm_surface_state.c b/src/gallium/drivers/i965/brw_wm_surface_state.c
index 2368ae3f80..0d80a0114a 100644
--- a/src/gallium/drivers/i965/brw_wm_surface_state.c
+++ b/src/gallium/drivers/i965/brw_wm_surface_state.c
@@ -34,7 +34,7 @@
#include "brw_batchbuffer.h"
#include "brw_context.h"
#include "brw_state.h"
-#include "brw_screen.h"
+#include "brw_resource.h"
diff --git a/src/gallium/drivers/identity/id_context.c b/src/gallium/drivers/identity/id_context.c
index 00a542215a..3b7eaecc02 100644
--- a/src/gallium/drivers/identity/id_context.c
+++ b/src/gallium/drivers/identity/id_context.c
@@ -28,6 +28,7 @@
#include "pipe/p_context.h"
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "id_context.h"
#include "id_objects.h"
@@ -61,19 +62,19 @@ identity_draw_arrays(struct pipe_context *_pipe,
static void
identity_draw_elements(struct pipe_context *_pipe,
- struct pipe_buffer *_indexBuffer,
+ struct pipe_resource *_indexResource,
unsigned indexSize,
unsigned prim,
unsigned start,
unsigned count)
{
struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_buffer *id_buffer = identity_buffer(_indexBuffer);
+ struct identity_resource *id_resource = identity_resource(_indexResource);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_buffer *indexBuffer = id_buffer->buffer;
+ struct pipe_resource *indexResource = id_resource->resource;
pipe->draw_elements(pipe,
- indexBuffer,
+ indexResource,
indexSize,
prim,
start,
@@ -82,7 +83,7 @@ identity_draw_elements(struct pipe_context *_pipe,
static void
identity_draw_range_elements(struct pipe_context *_pipe,
- struct pipe_buffer *_indexBuffer,
+ struct pipe_resource *_indexResource,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -91,12 +92,12 @@ identity_draw_range_elements(struct pipe_context *_pipe,
unsigned count)
{
struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_buffer *id_buffer = identity_buffer(_indexBuffer);
+ struct identity_resource *id_resource = identity_resource(_indexResource);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_buffer *indexBuffer = id_buffer->buffer;
+ struct pipe_resource *indexResource = id_resource->resource;
pipe->draw_range_elements(pipe,
- indexBuffer,
+ indexResource,
indexSize,
minIndex,
maxIndex,
@@ -450,23 +451,23 @@ static void
identity_set_constant_buffer(struct pipe_context *_pipe,
uint shader,
uint index,
- struct pipe_buffer *_buffer)
+ struct pipe_resource *_resource)
{
struct identity_context *id_pipe = identity_context(_pipe);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_buffer *unwrapped_buffer;
- struct pipe_buffer *buffer = NULL;
+ struct pipe_resource *unwrapped_resource;
+ struct pipe_resource *resource = NULL;
/* XXX hmm? unwrap the input state */
- if (_buffer) {
- unwrapped_buffer = identity_buffer_unwrap(_buffer);
- buffer = unwrapped_buffer;
+ if (_resource) {
+ unwrapped_resource = identity_resource_unwrap(_resource);
+ resource = unwrapped_resource;
}
pipe->set_constant_buffer(pipe,
shader,
index,
- buffer);
+ resource);
}
static void
@@ -587,7 +588,7 @@ identity_set_vertex_buffers(struct pipe_context *_pipe,
if (num_buffers) {
memcpy(unwrapped_buffers, _buffers, num_buffers * sizeof(*_buffers));
for (i = 0; i < num_buffers; i++)
- unwrapped_buffers[i].buffer = identity_buffer_unwrap(_buffers[i].buffer);
+ unwrapped_buffers[i].buffer = identity_resource_unwrap(_buffers[i].buffer);
buffers = unwrapped_buffers;
}
@@ -678,44 +679,31 @@ identity_flush(struct pipe_context *_pipe,
}
static unsigned int
-identity_is_texture_referenced(struct pipe_context *_pipe,
- struct pipe_texture *_texture,
+identity_is_resource_referenced(struct pipe_context *_pipe,
+ struct pipe_resource *_resource,
unsigned face,
unsigned level)
{
struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_texture *id_texture = identity_texture(_texture);
+ struct identity_resource *id_resource = identity_resource(_resource);
struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_texture *texture = id_texture->texture;
+ struct pipe_resource *texture = id_resource->resource;
- return pipe->is_texture_referenced(pipe,
+ return pipe->is_resource_referenced(pipe,
texture,
face,
level);
}
-static unsigned int
-identity_is_buffer_referenced(struct pipe_context *_pipe,
- struct pipe_buffer *_buffer)
-{
- struct identity_context *id_pipe = identity_context(_pipe);
- struct identity_buffer *id_buffer = identity_buffer(_buffer);
- struct pipe_context *pipe = id_pipe->pipe;
- struct pipe_buffer *buffer = id_buffer->buffer;
-
- return pipe->is_buffer_referenced(pipe,
- buffer);
-}
-
static struct pipe_sampler_view *
identity_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct identity_context *id_pipe = identity_context(pipe);
- struct identity_texture *id_texture = identity_texture(texture);
+ struct identity_resource *id_resource = identity_resource(texture);
struct pipe_context *pipe_unwrapped = id_pipe->pipe;
- struct pipe_texture *texture_unwrapped = id_texture->texture;
+ struct pipe_resource *texture_unwrapped = id_resource->resource;
struct identity_sampler_view *view = malloc(sizeof(struct identity_sampler_view));
view->sampler_view = pipe_unwrapped->create_sampler_view(pipe_unwrapped,
@@ -725,7 +713,7 @@ identity_create_sampler_view(struct pipe_context *pipe,
view->base = *templ;
view->base.reference.count = 1;
view->base.texture = NULL;
- pipe_texture_reference(&view->base.texture, texture);
+ pipe_resource_reference(&view->base.texture, texture);
view->base.context = pipe;
return &view->base;
@@ -743,47 +731,36 @@ identity_sampler_view_destroy(struct pipe_context *pipe,
pipe_unwrapped->sampler_view_destroy(pipe_unwrapped,
view_unwrapped);
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
free(view);
}
-
static struct pipe_transfer *
-identity_context_get_tex_transfer(struct pipe_context *_context,
- struct pipe_texture *_texture,
- unsigned face,
- unsigned level,
- unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x,
- unsigned y,
- unsigned w,
- unsigned h)
+identity_context_get_transfer(struct pipe_context *_context,
+ struct pipe_resource *_resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
struct identity_context *id_context = identity_context(_context);
- struct identity_texture *id_texture = identity_texture(_texture);
+ struct identity_resource *id_resource = identity_resource(_resource);
struct pipe_context *context = id_context->pipe;
- struct pipe_texture *texture = id_texture->texture;
+ struct pipe_resource *texture = id_resource->resource;
struct pipe_transfer *result;
- result = context->get_tex_transfer(context,
- texture,
- face,
- level,
- zslice,
- usage,
- x,
- y,
- w,
- h);
+ result = context->get_transfer(context,
+ texture,
+ sr,
+ usage,
+ box);
if (result)
- return identity_transfer_create(id_context, id_texture, result);
+ return identity_transfer_create(id_context, id_resource, result);
return NULL;
}
static void
-identity_context_tex_transfer_destroy(struct pipe_context *_pipe,
+identity_context_transfer_destroy(struct pipe_context *_pipe,
struct pipe_transfer *_transfer)
{
identity_transfer_destroy(identity_context(_pipe),
@@ -803,6 +780,24 @@ identity_context_transfer_map(struct pipe_context *_context,
transfer);
}
+
+
+static void
+identity_context_transfer_flush_region( struct pipe_context *_context,
+ struct pipe_transfer *_transfer,
+ const struct pipe_box *box)
+{
+ struct identity_context *id_context = identity_context(_context);
+ struct identity_transfer *id_transfer = identity_transfer(_transfer);
+ struct pipe_context *context = id_context->pipe;
+ struct pipe_transfer *transfer = id_transfer->transfer;
+
+ context->transfer_flush_region(context,
+ transfer,
+ box);
+}
+
+
static void
identity_context_transfer_unmap(struct pipe_context *_context,
struct pipe_transfer *_transfer)
@@ -816,6 +811,33 @@ identity_context_transfer_unmap(struct pipe_context *_context,
transfer);
}
+
+static void
+identity_context_transfer_inline_write( struct pipe_context *_context,
+ struct pipe_resource *_resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride)
+{
+ struct identity_context *id_context = identity_context(_context);
+ struct identity_resource *id_resource = identity_resource(_resource);
+ struct pipe_context *context = id_context->pipe;
+ struct pipe_resource *texture = id_resource->resource;
+
+ context->transfer_inline_write(context,
+ texture,
+ sr,
+ usage,
+ box,
+ data,
+ stride,
+ slice_stride);
+}
+
+
struct pipe_context *
identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
{
@@ -878,14 +900,15 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
id_pipe->base.surface_fill = identity_surface_fill;
id_pipe->base.clear = identity_clear;
id_pipe->base.flush = identity_flush;
- id_pipe->base.is_texture_referenced = identity_is_texture_referenced;
- id_pipe->base.is_buffer_referenced = identity_is_buffer_referenced;
+ id_pipe->base.is_resource_referenced = identity_is_resource_referenced;
id_pipe->base.create_sampler_view = identity_create_sampler_view;
id_pipe->base.sampler_view_destroy = identity_sampler_view_destroy;
- id_pipe->base.get_tex_transfer = identity_context_get_tex_transfer;
- id_pipe->base.tex_transfer_destroy = identity_context_tex_transfer_destroy;
+ id_pipe->base.get_transfer = identity_context_get_transfer;
+ id_pipe->base.transfer_destroy = identity_context_transfer_destroy;
id_pipe->base.transfer_map = identity_context_transfer_map;
id_pipe->base.transfer_unmap = identity_context_transfer_unmap;
+ id_pipe->base.transfer_flush_region = identity_context_transfer_flush_region;
+ id_pipe->base.transfer_inline_write = identity_context_transfer_inline_write;
id_pipe->pipe = pipe;
diff --git a/src/gallium/drivers/identity/id_objects.c b/src/gallium/drivers/identity/id_objects.c
index d37fb0042e..d50914e7d5 100644
--- a/src/gallium/drivers/identity/id_objects.c
+++ b/src/gallium/drivers/identity/id_objects.c
@@ -32,80 +32,46 @@
#include "id_objects.h"
#include "id_context.h"
-struct pipe_buffer *
-identity_buffer_create(struct identity_screen *id_screen,
- struct pipe_buffer *buffer)
-{
- struct identity_buffer *id_buffer;
-
- if(!buffer)
- goto error;
-
- assert(buffer->screen == id_screen->screen);
-
- id_buffer = CALLOC_STRUCT(identity_buffer);
- if(!id_buffer)
- goto error;
-
- memcpy(&id_buffer->base, buffer, sizeof(struct pipe_buffer));
-
- pipe_reference_init(&id_buffer->base.reference, 1);
- id_buffer->base.screen = &id_screen->base;
- id_buffer->buffer = buffer;
-
- return &id_buffer->base;
-
-error:
- pipe_buffer_reference(&buffer, NULL);
- return NULL;
-}
-
-void
-identity_buffer_destroy(struct identity_buffer *id_buffer)
-{
- pipe_buffer_reference(&id_buffer->buffer, NULL);
- FREE(id_buffer);
-}
-struct pipe_texture *
-identity_texture_create(struct identity_screen *id_screen,
- struct pipe_texture *texture)
+struct pipe_resource *
+identity_resource_create(struct identity_screen *id_screen,
+ struct pipe_resource *resource)
{
- struct identity_texture *id_texture;
+ struct identity_resource *id_resource;
- if(!texture)
+ if(!resource)
goto error;
- assert(texture->screen == id_screen->screen);
+ assert(resource->screen == id_screen->screen);
- id_texture = CALLOC_STRUCT(identity_texture);
- if(!id_texture)
+ id_resource = CALLOC_STRUCT(identity_resource);
+ if(!id_resource)
goto error;
- memcpy(&id_texture->base, texture, sizeof(struct pipe_texture));
+ memcpy(&id_resource->base, resource, sizeof(struct pipe_resource));
- pipe_reference_init(&id_texture->base.reference, 1);
- id_texture->base.screen = &id_screen->base;
- id_texture->texture = texture;
+ pipe_reference_init(&id_resource->base.reference, 1);
+ id_resource->base.screen = &id_screen->base;
+ id_resource->resource = resource;
- return &id_texture->base;
+ return &id_resource->base;
error:
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&resource, NULL);
return NULL;
}
void
-identity_texture_destroy(struct identity_texture *id_texture)
+identity_resource_destroy(struct identity_resource *id_resource)
{
- pipe_texture_reference(&id_texture->texture, NULL);
- FREE(id_texture);
+ pipe_resource_reference(&id_resource->resource, NULL);
+ FREE(id_resource);
}
struct pipe_surface *
-identity_surface_create(struct identity_texture *id_texture,
+identity_surface_create(struct identity_resource *id_resource,
struct pipe_surface *surface)
{
struct identity_surface *id_surface;
@@ -113,7 +79,7 @@ identity_surface_create(struct identity_texture *id_texture,
if(!surface)
goto error;
- assert(surface->texture == id_texture->texture);
+ assert(surface->texture == id_resource->resource);
id_surface = CALLOC_STRUCT(identity_surface);
if(!id_surface)
@@ -123,7 +89,7 @@ identity_surface_create(struct identity_texture *id_texture,
pipe_reference_init(&id_surface->base.reference, 1);
id_surface->base.texture = NULL;
- pipe_texture_reference(&id_surface->base.texture, &id_texture->base);
+ pipe_resource_reference(&id_surface->base.texture, &id_resource->base);
id_surface->surface = surface;
return &id_surface->base;
@@ -136,7 +102,7 @@ error:
void
identity_surface_destroy(struct identity_surface *id_surface)
{
- pipe_texture_reference(&id_surface->base.texture, NULL);
+ pipe_resource_reference(&id_surface->base.texture, NULL);
pipe_surface_reference(&id_surface->surface, NULL);
FREE(id_surface);
}
@@ -144,7 +110,7 @@ identity_surface_destroy(struct identity_surface *id_surface)
struct pipe_transfer *
identity_transfer_create(struct identity_context *id_context,
- struct identity_texture *id_texture,
+ struct identity_resource *id_resource,
struct pipe_transfer *transfer)
{
struct identity_transfer *id_transfer;
@@ -152,7 +118,7 @@ identity_transfer_create(struct identity_context *id_context,
if(!transfer)
goto error;
- assert(transfer->texture == id_texture->texture);
+ assert(transfer->resource == id_resource->resource);
id_transfer = CALLOC_STRUCT(identity_transfer);
if(!id_transfer)
@@ -160,16 +126,16 @@ identity_transfer_create(struct identity_context *id_context,
memcpy(&id_transfer->base, transfer, sizeof(struct pipe_transfer));
- id_transfer->base.texture = NULL;
+ id_transfer->base.resource = NULL;
id_transfer->transfer = transfer;
- pipe_texture_reference(&id_transfer->base.texture, &id_texture->base);
- assert(id_transfer->base.texture == &id_texture->base);
+ pipe_resource_reference(&id_transfer->base.resource, &id_resource->base);
+ assert(id_transfer->base.resource == &id_resource->base);
return &id_transfer->base;
error:
- id_context->pipe->tex_transfer_destroy(id_context->pipe, transfer);
+ id_context->pipe->transfer_destroy(id_context->pipe, transfer);
return NULL;
}
@@ -177,47 +143,9 @@ void
identity_transfer_destroy(struct identity_context *id_context,
struct identity_transfer *id_transfer)
{
- pipe_texture_reference(&id_transfer->base.texture, NULL);
- id_context->pipe->tex_transfer_destroy(id_context->pipe,
- id_transfer->transfer);
+ pipe_resource_reference(&id_transfer->base.resource, NULL);
+ id_context->pipe->transfer_destroy(id_context->pipe,
+ id_transfer->transfer);
FREE(id_transfer);
}
-struct pipe_video_surface *
-identity_video_surface_create(struct identity_screen *id_screen,
- struct pipe_video_surface *video_surface)
-{
- struct identity_video_surface *id_video_surface;
-
- if (!video_surface) {
- goto error;
- }
-
- assert(video_surface->screen == id_screen->screen);
-
- id_video_surface = CALLOC_STRUCT(identity_video_surface);
- if (!id_video_surface) {
- goto error;
- }
-
- memcpy(&id_video_surface->base,
- video_surface,
- sizeof(struct pipe_video_surface));
-
- pipe_reference_init(&id_video_surface->base.reference, 1);
- id_video_surface->base.screen = &id_screen->base;
- id_video_surface->video_surface = video_surface;
-
- return &id_video_surface->base;
-
-error:
- pipe_video_surface_reference(&video_surface, NULL);
- return NULL;
-}
-
-void
-identity_video_surface_destroy(struct identity_video_surface *id_video_surface)
-{
- pipe_video_surface_reference(&id_video_surface->video_surface, NULL);
- FREE(id_video_surface);
-}
diff --git a/src/gallium/drivers/identity/id_objects.h b/src/gallium/drivers/identity/id_objects.h
index 9a07ebe8d7..058cf3009d 100644
--- a/src/gallium/drivers/identity/id_objects.h
+++ b/src/gallium/drivers/identity/id_objects.h
@@ -31,25 +31,17 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
-#include "pipe/p_video_state.h"
#include "id_screen.h"
struct identity_context;
-struct identity_buffer
-{
- struct pipe_buffer base;
-
- struct pipe_buffer *buffer;
-};
-
-struct identity_texture
+struct identity_resource
{
- struct pipe_texture base;
+ struct pipe_resource base;
- struct pipe_texture *texture;
+ struct pipe_resource *resource;
};
@@ -78,30 +70,13 @@ struct identity_transfer
};
-struct identity_video_surface
-{
- struct pipe_video_surface base;
-
- struct pipe_video_surface *video_surface;
-};
-
-
-static INLINE struct identity_buffer *
-identity_buffer(struct pipe_buffer *_buffer)
+static INLINE struct identity_resource *
+identity_resource(struct pipe_resource *_resource)
{
- if(!_buffer)
+ if(!_resource)
return NULL;
- (void)identity_screen(_buffer->screen);
- return (struct identity_buffer *)_buffer;
-}
-
-static INLINE struct identity_texture *
-identity_texture(struct pipe_texture *_texture)
-{
- if(!_texture)
- return NULL;
- (void)identity_screen(_texture->screen);
- return (struct identity_texture *)_texture;
+ (void)identity_screen(_resource->screen);
+ return (struct identity_resource *)_resource;
}
static INLINE struct identity_sampler_view *
@@ -118,7 +93,7 @@ identity_surface(struct pipe_surface *_surface)
{
if(!_surface)
return NULL;
- (void)identity_texture(_surface->texture);
+ (void)identity_resource(_surface->texture);
return (struct identity_surface *)_surface;
}
@@ -127,34 +102,16 @@ identity_transfer(struct pipe_transfer *_transfer)
{
if(!_transfer)
return NULL;
- (void)identity_texture(_transfer->texture);
+ (void)identity_resource(_transfer->resource);
return (struct identity_transfer *)_transfer;
}
-static INLINE struct identity_video_surface *
-identity_video_surface(struct pipe_video_surface *_video_surface)
-{
- if (!_video_surface) {
- return NULL;
- }
- (void)identity_screen(_video_surface->screen);
- return (struct identity_video_surface *)_video_surface;
-}
-
-static INLINE struct pipe_buffer *
-identity_buffer_unwrap(struct pipe_buffer *_buffer)
-{
- if(!_buffer)
- return NULL;
- return identity_buffer(_buffer)->buffer;
-}
-
-static INLINE struct pipe_texture *
-identity_texture_unwrap(struct pipe_texture *_texture)
+static INLINE struct pipe_resource *
+identity_resource_unwrap(struct pipe_resource *_resource)
{
- if(!_texture)
+ if(!_resource)
return NULL;
- return identity_texture(_texture)->texture;
+ return identity_resource(_resource)->resource;
}
static INLINE struct pipe_sampler_view *
@@ -183,22 +140,15 @@ identity_transfer_unwrap(struct pipe_transfer *_transfer)
}
-struct pipe_buffer *
-identity_buffer_create(struct identity_screen *id_screen,
- struct pipe_buffer *buffer);
-
-void
-identity_buffer_destroy(struct identity_buffer *id_buffer);
-
-struct pipe_texture *
-identity_texture_create(struct identity_screen *id_screen,
- struct pipe_texture *texture);
+struct pipe_resource *
+identity_resource_create(struct identity_screen *id_screen,
+ struct pipe_resource *resource);
void
-identity_texture_destroy(struct identity_texture *id_texture);
+identity_resource_destroy(struct identity_resource *id_resource);
struct pipe_surface *
-identity_surface_create(struct identity_texture *id_texture,
+identity_surface_create(struct identity_resource *id_resource,
struct pipe_surface *surface);
void
@@ -206,19 +156,12 @@ identity_surface_destroy(struct identity_surface *id_surface);
struct pipe_transfer *
identity_transfer_create(struct identity_context *id_context,
- struct identity_texture *id_texture,
+ struct identity_resource *id_resource,
struct pipe_transfer *transfer);
void
identity_transfer_destroy(struct identity_context *id_context,
struct identity_transfer *id_transfer);
-struct pipe_video_surface *
-identity_video_surface_create(struct identity_screen *id_screen,
- struct pipe_video_surface *video_surface);
-
-void
-identity_video_surface_destroy(struct identity_video_surface *id_video_surface);
-
#endif /* ID_OBJECTS_H */
diff --git a/src/gallium/drivers/identity/id_screen.c b/src/gallium/drivers/identity/id_screen.c
index 419b146578..52573b211f 100644
--- a/src/gallium/drivers/identity/id_screen.c
+++ b/src/gallium/drivers/identity/id_screen.c
@@ -118,75 +118,76 @@ identity_screen_context_create(struct pipe_screen *_screen,
return NULL;
}
-static struct pipe_texture *
-identity_screen_texture_create(struct pipe_screen *_screen,
- const struct pipe_texture *templat)
+static struct pipe_resource *
+identity_screen_resource_create(struct pipe_screen *_screen,
+ const struct pipe_resource *templat)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
- struct pipe_texture *result;
+ struct pipe_resource *result;
- result = screen->texture_create(screen,
+ result = screen->resource_create(screen,
templat);
if (result)
- return identity_texture_create(id_screen, result);
+ return identity_resource_create(id_screen, result);
return NULL;
}
-static struct pipe_texture *
-identity_screen_texture_from_handle(struct pipe_screen *_screen,
- const struct pipe_texture *templ,
+static struct pipe_resource *
+identity_screen_resource_from_handle(struct pipe_screen *_screen,
+ const struct pipe_resource *templ,
struct winsys_handle *handle)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
- struct pipe_texture *result;
+ struct pipe_resource *result;
/* TODO trace call */
- result = screen->texture_from_handle(screen, templ, handle);
+ result = screen->resource_from_handle(screen, templ, handle);
- result = identity_texture_create(identity_screen(_screen), result);
+ result = identity_resource_create(identity_screen(_screen), result);
return result;
}
static boolean
-identity_screen_texture_get_handle(struct pipe_screen *_screen,
- struct pipe_texture *_texture,
+identity_screen_resource_get_handle(struct pipe_screen *_screen,
+ struct pipe_resource *_texture,
struct winsys_handle *handle)
{
struct identity_screen *id_screen = identity_screen(_screen);
- struct identity_texture *id_texture = identity_texture(_texture);
+ struct identity_resource *id_resource = identity_resource(_texture);
struct pipe_screen *screen = id_screen->screen;
- struct pipe_texture *texture = id_texture->texture;
+ struct pipe_resource *texture = id_resource->resource;
/* TODO trace call */
- return screen->texture_get_handle(screen, texture, handle);
+ return screen->resource_get_handle(screen, texture, handle);
}
static void
-identity_screen_texture_destroy(struct pipe_texture *_texture)
+identity_screen_resource_destroy(struct pipe_screen *screen,
+ struct pipe_resource *_texture)
{
- identity_texture_destroy(identity_texture(_texture));
+ identity_resource_destroy(identity_resource(_texture));
}
static struct pipe_surface *
identity_screen_get_tex_surface(struct pipe_screen *_screen,
- struct pipe_texture *_texture,
+ struct pipe_resource *_texture,
unsigned face,
unsigned level,
unsigned zslice,
unsigned usage)
{
struct identity_screen *id_screen = identity_screen(_screen);
- struct identity_texture *id_texture = identity_texture(_texture);
+ struct identity_resource *id_resource = identity_resource(_texture);
struct pipe_screen *screen = id_screen->screen;
- struct pipe_texture *texture = id_texture->texture;
+ struct pipe_resource *texture = id_resource->resource;
struct pipe_surface *result;
result = screen->get_tex_surface(screen,
@@ -197,7 +198,7 @@ identity_screen_get_tex_surface(struct pipe_screen *_screen,
usage);
if (result)
- return identity_surface_create(id_texture, result);
+ return identity_surface_create(id_resource, result);
return NULL;
}
@@ -208,141 +209,28 @@ identity_screen_tex_surface_destroy(struct pipe_surface *_surface)
}
-static struct pipe_buffer *
-identity_screen_buffer_create(struct pipe_screen *_screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct identity_screen *id_screen = identity_screen(_screen);
- struct pipe_screen *screen = id_screen->screen;
- struct pipe_buffer *result;
-
- result = screen->buffer_create(screen,
- alignment,
- usage,
- size);
- if (result)
- return identity_buffer_create(id_screen, result);
- return NULL;
-}
-
-static struct pipe_buffer *
+static struct pipe_resource *
identity_screen_user_buffer_create(struct pipe_screen *_screen,
void *ptr,
- unsigned bytes)
+ unsigned bytes,
+ unsigned usage)
{
struct identity_screen *id_screen = identity_screen(_screen);
struct pipe_screen *screen = id_screen->screen;
- struct pipe_buffer *result;
+ struct pipe_resource *result;
result = screen->user_buffer_create(screen,
ptr,
- bytes);
+ bytes,
+ usage);
if (result)
- return identity_buffer_create(id_screen, result);
+ return identity_resource_create(id_screen, result);
return NULL;
}
-static void *
-identity_screen_buffer_map(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer,
- unsigned usage)
-{
- struct identity_screen *id_screen = identity_screen(_screen);
- struct identity_buffer *id_buffer = identity_buffer(_buffer);
- struct pipe_screen *screen = id_screen->screen;
- struct pipe_buffer *buffer = id_buffer->buffer;
-
- return screen->buffer_map(screen,
- buffer,
- usage);
-}
-
-static void *
-identity_screen_buffer_map_range(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer,
- unsigned offset,
- unsigned length,
- unsigned usage)
-{
- struct identity_screen *id_screen = identity_screen(_screen);
- struct identity_buffer *id_buffer = identity_buffer(_buffer);
- struct pipe_screen *screen = id_screen->screen;
- struct pipe_buffer *buffer = id_buffer->buffer;
-
- return screen->buffer_map_range(screen,
- buffer,
- offset,
- length,
- usage);
-}
-
-static void
-identity_screen_buffer_flush_mapped_range(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer,
- unsigned offset,
- unsigned length)
-{
- struct identity_screen *id_screen = identity_screen(_screen);
- struct identity_buffer *id_buffer = identity_buffer(_buffer);
- struct pipe_screen *screen = id_screen->screen;
- struct pipe_buffer *buffer = id_buffer->buffer;
-
- screen->buffer_flush_mapped_range(screen,
- buffer,
- offset,
- length);
-}
-
-static void
-identity_screen_buffer_unmap(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer)
-{
- struct identity_screen *id_screen = identity_screen(_screen);
- struct identity_buffer *id_buffer = identity_buffer(_buffer);
- struct pipe_screen *screen = id_screen->screen;
- struct pipe_buffer *buffer = id_buffer->buffer;
-
- screen->buffer_unmap(screen,
- buffer);
-}
-
-static void
-identity_screen_buffer_destroy(struct pipe_buffer *_buffer)
-{
- identity_buffer_destroy(identity_buffer(_buffer));
-}
-
-static struct pipe_video_surface *
-identity_screen_video_surface_create(struct pipe_screen *_screen,
- enum pipe_video_chroma_format chroma_format,
- unsigned width,
- unsigned height)
-{
- struct identity_screen *id_screen = identity_screen(_screen);
- struct pipe_screen *screen = id_screen->screen;
- struct pipe_video_surface *result;
-
- result = screen->video_surface_create(screen,
- chroma_format,
- width,
- height);
-
- if (result) {
- return identity_video_surface_create(id_screen, result);
- }
- return NULL;
-}
-
-static void
-identity_screen_video_surface_destroy(struct pipe_video_surface *_vsfc)
-{
- identity_video_surface_destroy(identity_video_surface(_vsfc));
-}
static void
identity_screen_flush_frontbuffer(struct pipe_screen *_screen,
@@ -417,29 +305,13 @@ identity_screen_create(struct pipe_screen *screen)
id_screen->base.get_paramf = identity_screen_get_paramf;
id_screen->base.is_format_supported = identity_screen_is_format_supported;
id_screen->base.context_create = identity_screen_context_create;
- id_screen->base.texture_create = identity_screen_texture_create;
- id_screen->base.texture_from_handle = identity_screen_texture_from_handle;
- id_screen->base.texture_get_handle = identity_screen_texture_get_handle;
- id_screen->base.texture_destroy = identity_screen_texture_destroy;
+ id_screen->base.resource_create = identity_screen_resource_create;
+ id_screen->base.resource_from_handle = identity_screen_resource_from_handle;
+ id_screen->base.resource_get_handle = identity_screen_resource_get_handle;
+ id_screen->base.resource_destroy = identity_screen_resource_destroy;
id_screen->base.get_tex_surface = identity_screen_get_tex_surface;
id_screen->base.tex_surface_destroy = identity_screen_tex_surface_destroy;
- id_screen->base.buffer_create = identity_screen_buffer_create;
id_screen->base.user_buffer_create = identity_screen_user_buffer_create;
- if (screen->buffer_map)
- id_screen->base.buffer_map = identity_screen_buffer_map;
- if (screen->buffer_map_range)
- id_screen->base.buffer_map_range = identity_screen_buffer_map_range;
- if (screen->buffer_flush_mapped_range)
- id_screen->base.buffer_flush_mapped_range = identity_screen_buffer_flush_mapped_range;
- if (screen->buffer_unmap)
- id_screen->base.buffer_unmap = identity_screen_buffer_unmap;
- id_screen->base.buffer_destroy = identity_screen_buffer_destroy;
- if (screen->video_surface_create) {
- id_screen->base.video_surface_create = identity_screen_video_surface_create;
- }
- if (screen->video_surface_destroy) {
- id_screen->base.video_surface_destroy = identity_screen_video_surface_destroy;
- }
id_screen->base.flush_frontbuffer = identity_screen_flush_frontbuffer;
id_screen->base.fence_reference = identity_screen_fence_reference;
id_screen->base.fence_signalled = identity_screen_fence_signalled;
diff --git a/src/gallium/drivers/llvmpipe/Makefile b/src/gallium/drivers/llvmpipe/Makefile
index 7bfce15c2e..a35a24f5b0 100644
--- a/src/gallium/drivers/llvmpipe/Makefile
+++ b/src/gallium/drivers/llvmpipe/Makefile
@@ -6,7 +6,6 @@ LIBNAME = llvmpipe
DEFINES += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
C_SOURCES = \
- lp_buffer.c \
lp_clear.c \
lp_context.c \
lp_draw_arrays.c \
diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript
index 07e6ccfce4..f5a38d05d4 100644
--- a/src/gallium/drivers/llvmpipe/SConscript
+++ b/src/gallium/drivers/llvmpipe/SConscript
@@ -27,7 +27,6 @@ env.Depends('lp_tile_soa.c', [
llvmpipe = env.ConvenienceLibrary(
target = 'llvmpipe',
source = [
- 'lp_buffer.c',
'lp_clear.c',
'lp_context.c',
'lp_draw_arrays.c',
diff --git a/src/gallium/drivers/llvmpipe/lp_buffer.c b/src/gallium/drivers/llvmpipe/lp_buffer.c
deleted file mode 100644
index 6e0f37393e..0000000000
--- a/src/gallium/drivers/llvmpipe/lp_buffer.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_math.h"
-
-#include "lp_screen.h"
-#include "lp_buffer.h"
-
-
-static void *
-llvmpipe_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- struct llvmpipe_buffer *llvmpipe_buf = llvmpipe_buffer(buf);
- return llvmpipe_buf->data;
-}
-
-
-static void
-llvmpipe_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
-{
-}
-
-
-static void
-llvmpipe_buffer_destroy(struct pipe_buffer *buf)
-{
- struct llvmpipe_buffer *sbuf = llvmpipe_buffer(buf);
-
- if (!sbuf->userBuffer)
- align_free(sbuf->data);
-
- FREE(sbuf);
-}
-
-
-static struct pipe_buffer *
-llvmpipe_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct llvmpipe_buffer *buffer = CALLOC_STRUCT(llvmpipe_buffer);
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.screen = screen;
- buffer->base.alignment = MAX2(alignment, 16);
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- buffer->data = align_malloc(size, alignment);
-
- return &buffer->base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-llvmpipe_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct llvmpipe_buffer *buffer;
-
- buffer = CALLOC_STRUCT(llvmpipe_buffer);
- if(!buffer)
- return NULL;
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.screen = screen;
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
-
- return &buffer->base;
-}
-
-
-void
-llvmpipe_init_screen_buffer_funcs(struct pipe_screen *screen)
-{
- screen->buffer_create = llvmpipe_buffer_create;
- screen->user_buffer_create = llvmpipe_user_buffer_create;
- screen->buffer_map = llvmpipe_buffer_map;
- screen->buffer_unmap = llvmpipe_buffer_unmap;
- screen->buffer_destroy = llvmpipe_buffer_destroy;
-}
diff --git a/src/gallium/drivers/llvmpipe/lp_buffer.h b/src/gallium/drivers/llvmpipe/lp_buffer.h
deleted file mode 100644
index d6b8184a0b..0000000000
--- a/src/gallium/drivers/llvmpipe/lp_buffer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef LP_BUFFER_H
-#define LP_BUFFER_H
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-
-struct llvmpipe_buffer
-{
- struct pipe_buffer base;
- boolean userBuffer; /** Is this a user-space buffer? */
- void *data;
-};
-
-
-/** Cast wrapper */
-static INLINE struct llvmpipe_buffer *
-llvmpipe_buffer( struct pipe_buffer *buf )
-{
- return (struct llvmpipe_buffer *)buf;
-}
-
-
-void
-llvmpipe_init_screen_buffer_funcs(struct pipe_screen *screen);
-
-
-#endif /* LP_BUFFER_H */
diff --git a/src/gallium/drivers/llvmpipe/lp_context.c b/src/gallium/drivers/llvmpipe/lp_context.c
index 270ae451c0..c7acb0c545 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.c
+++ b/src/gallium/drivers/llvmpipe/lp_context.c
@@ -77,29 +77,13 @@ static void llvmpipe_destroy( struct pipe_context *pipe )
for (i = 0; i < Elements(llvmpipe->constants); i++) {
if (llvmpipe->constants[i]) {
- pipe_buffer_reference(&llvmpipe->constants[i], NULL);
+ pipe_resource_reference(&llvmpipe->constants[i], NULL);
}
}
align_free( llvmpipe );
}
-static unsigned int
-llvmpipe_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe );
-
- return lp_setup_is_texture_referenced(llvmpipe->setup, texture);
-}
-
-static unsigned int
-llvmpipe_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- return PIPE_UNREFERENCED;
-}
struct pipe_context *
llvmpipe_create_context( struct pipe_screen *screen, void *priv )
@@ -171,11 +155,9 @@ llvmpipe_create_context( struct pipe_screen *screen, void *priv )
llvmpipe->pipe.clear = llvmpipe_clear;
llvmpipe->pipe.flush = llvmpipe_flush;
- llvmpipe->pipe.is_texture_referenced = llvmpipe_is_texture_referenced;
- llvmpipe->pipe.is_buffer_referenced = llvmpipe_is_buffer_referenced;
llvmpipe_init_query_funcs( llvmpipe );
- llvmpipe_init_context_texture_funcs( &llvmpipe->pipe );
+ llvmpipe_init_context_resource_funcs( &llvmpipe->pipe );
/*
* Create drawing context and plug our rendering stage into it.
diff --git a/src/gallium/drivers/llvmpipe/lp_context.h b/src/gallium/drivers/llvmpipe/lp_context.h
index 71f991049e..4848101ffb 100644
--- a/src/gallium/drivers/llvmpipe/lp_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_context.h
@@ -65,7 +65,7 @@ struct llvmpipe_context {
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
- struct pipe_buffer *constants[PIPE_SHADER_TYPES];
+ struct pipe_resource *constants[PIPE_SHADER_TYPES];
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
index 3dd68d5794..a9b8ba258b 100644
--- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
+++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c
@@ -35,7 +35,6 @@
#include "pipe/p_context.h"
#include "util/u_prim.h"
-#include "lp_buffer.h"
#include "lp_context.h"
#include "lp_state.h"
@@ -58,7 +57,7 @@ llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
*/
void
llvmpipe_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
@@ -75,13 +74,13 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
* Map vertex buffers
*/
for (i = 0; i < lp->num_vertex_buffers; i++) {
- void *buf = llvmpipe_buffer(lp->vertex_buffer[i].buffer)->data;
+ void *buf = llvmpipe_resource(lp->vertex_buffer[i].buffer)->data;
draw_set_mapped_vertex_buffer(draw, i, buf);
}
/* Map index buffer, if present */
if (indexBuffer) {
- void *mapped_indexes = llvmpipe_buffer(indexBuffer)->data;
+ void *mapped_indexes = llvmpipe_resource(indexBuffer)->data;
draw_set_mapped_element_buffer_range(draw, indexSize,
min_index,
max_index,
@@ -117,7 +116,7 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe,
void
llvmpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c
index 782669a1e7..f1533f8f70 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.c
+++ b/src/gallium/drivers/llvmpipe/lp_flush.c
@@ -103,7 +103,7 @@ llvmpipe_flush( struct pipe_context *pipe,
*/
boolean
llvmpipe_flush_texture(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
unsigned face,
unsigned level,
unsigned flush_flags,
@@ -113,7 +113,7 @@ llvmpipe_flush_texture(struct pipe_context *pipe,
{
unsigned referenced;
- referenced = pipe->is_texture_referenced(pipe, texture, face, level);
+ referenced = pipe->is_resource_referenced(pipe, texture, face, level);
if ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
((referenced & PIPE_REFERENCED_FOR_READ) && !read_only)) {
diff --git a/src/gallium/drivers/llvmpipe/lp_flush.h b/src/gallium/drivers/llvmpipe/lp_flush.h
index e13f57ccec..2375d22b85 100644
--- a/src/gallium/drivers/llvmpipe/lp_flush.h
+++ b/src/gallium/drivers/llvmpipe/lp_flush.h
@@ -38,7 +38,7 @@ void llvmpipe_flush(struct pipe_context *pipe, unsigned flags,
boolean
llvmpipe_flush_texture(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
unsigned face,
unsigned level,
unsigned flush_flags,
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index e629a3e5f1..fccc63c28f 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -67,13 +67,13 @@ lp_rast_begin( struct lp_rasterizer *rast,
rast->cbuf[i].format = cbuf->texture->format;
rast->cbuf[i].width = cbuf->width;
rast->cbuf[i].height = cbuf->height;
- rast->cbuf[i].stride = llvmpipe_texture_stride(cbuf->texture, cbuf->level);
+ rast->cbuf[i].stride = llvmpipe_resource_stride(cbuf->texture, cbuf->level);
}
if (write_zstencil) {
struct pipe_surface *zsbuf = scene->fb.zsbuf;
rast->zsbuf.map = scene->zsbuf_map;
- rast->zsbuf.stride = llvmpipe_texture_stride(zsbuf->texture, zsbuf->level);
+ rast->zsbuf.stride = llvmpipe_resource_stride(zsbuf->texture, zsbuf->level);
rast->zsbuf.blocksize =
util_format_get_blocksize(zsbuf->texture->format);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.c b/src/gallium/drivers/llvmpipe/lp_scene.c
index 0c51b52d17..245d387578 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.c
+++ b/src/gallium/drivers/llvmpipe/lp_scene.c
@@ -181,7 +181,7 @@ lp_scene_reset(struct lp_scene *scene )
struct texture_ref *ref, *next, *ref_list = &scene->textures;
for (ref = ref_list->next; ref != ref_list; ref = next) {
next = next_elem(ref);
- pipe_texture_reference(&ref->texture, NULL);
+ pipe_resource_reference(&ref->texture, NULL);
FREE(ref);
}
make_empty_list(ref_list);
@@ -248,12 +248,12 @@ lp_scene_bin_size( const struct lp_scene *scene, unsigned x, unsigned y )
*/
void
lp_scene_texture_reference( struct lp_scene *scene,
- struct pipe_texture *texture )
+ struct pipe_resource *texture )
{
struct texture_ref *ref = CALLOC_STRUCT(texture_ref);
if (ref) {
struct texture_ref *ref_list = &scene->textures;
- pipe_texture_reference(&ref->texture, texture);
+ pipe_resource_reference(&ref->texture, texture);
insert_at_tail(ref_list, ref);
}
}
@@ -263,8 +263,8 @@ lp_scene_texture_reference( struct lp_scene *scene,
* Does this scene have a reference to the given texture?
*/
boolean
-lp_scene_is_texture_referenced( const struct lp_scene *scene,
- const struct pipe_texture *texture )
+lp_scene_is_resource_referenced( const struct lp_scene *scene,
+ const struct pipe_resource *texture )
{
const struct texture_ref *ref_list = &scene->textures;
const struct texture_ref *ref;
@@ -398,20 +398,25 @@ static boolean
lp_scene_map_buffers( struct lp_scene *scene )
{
struct pipe_surface *cbuf, *zsbuf;
+ unsigned usage;
int i;
LP_DBG(DEBUG_RAST, "%s\n", __FUNCTION__);
+ /* XXX: try to improve on this:
+ */
+ usage = PIPE_TRANSFER_READ_WRITE;
/* Map all color buffers
*/
for (i = 0; i < scene->fb.nr_cbufs; i++) {
cbuf = scene->fb.cbufs[i];
if (cbuf) {
- scene->cbuf_map[i] = llvmpipe_texture_map(cbuf->texture,
- cbuf->face,
- cbuf->level,
- cbuf->zslice);
+ scene->cbuf_map[i] = llvmpipe_resource_map(cbuf->texture,
+ usage,
+ cbuf->face,
+ cbuf->level,
+ cbuf->zslice);
if (!scene->cbuf_map[i])
goto fail;
}
@@ -421,10 +426,11 @@ lp_scene_map_buffers( struct lp_scene *scene )
*/
zsbuf = scene->fb.zsbuf;
if (zsbuf) {
- scene->zsbuf_map = llvmpipe_texture_map(zsbuf->texture,
- zsbuf->face,
- zsbuf->level,
- zsbuf->zslice);
+ scene->zsbuf_map = llvmpipe_resource_map(zsbuf->texture,
+ usage,
+ zsbuf->face,
+ zsbuf->level,
+ zsbuf->zslice);
if (!scene->zsbuf_map)
goto fail;
}
@@ -453,7 +459,7 @@ lp_scene_unmap_buffers( struct lp_scene *scene )
for (i = 0; i < scene->fb.nr_cbufs; i++) {
if (scene->cbuf_map[i]) {
struct pipe_surface *cbuf = scene->fb.cbufs[i];
- llvmpipe_texture_unmap(cbuf->texture,
+ llvmpipe_resource_unmap(cbuf->texture,
cbuf->face,
cbuf->level,
cbuf->zslice);
@@ -463,7 +469,7 @@ lp_scene_unmap_buffers( struct lp_scene *scene )
if (scene->zsbuf_map) {
struct pipe_surface *zsbuf = scene->fb.zsbuf;
- llvmpipe_texture_unmap(zsbuf->texture,
+ llvmpipe_resource_unmap(zsbuf->texture,
zsbuf->face,
zsbuf->level,
zsbuf->zslice);
diff --git a/src/gallium/drivers/llvmpipe/lp_scene.h b/src/gallium/drivers/llvmpipe/lp_scene.h
index b602b1e8a0..a1fb8bf541 100644
--- a/src/gallium/drivers/llvmpipe/lp_scene.h
+++ b/src/gallium/drivers/llvmpipe/lp_scene.h
@@ -99,7 +99,7 @@ struct data_block_list {
/** List of texture references */
struct texture_ref {
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct texture_ref *prev, *next; /**< linked list w/ u_simple_list.h */
};
@@ -168,10 +168,10 @@ unsigned lp_scene_data_size( const struct lp_scene *scene );
unsigned lp_scene_bin_size( const struct lp_scene *scene, unsigned x, unsigned y );
void lp_scene_texture_reference( struct lp_scene *scene,
- struct pipe_texture *texture );
+ struct pipe_resource *texture );
-boolean lp_scene_is_texture_referenced( const struct lp_scene *scene,
- const struct pipe_texture *texture );
+boolean lp_scene_is_resource_referenced( const struct lp_scene *scene,
+ const struct pipe_resource *texture );
/**
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index 6999599558..6d309c6b64 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -33,7 +33,6 @@
#include "pipe/p_screen.h"
#include "lp_texture.h"
-#include "lp_buffer.h"
#include "lp_fence.h"
#include "lp_jit.h"
#include "lp_screen.h"
@@ -192,7 +191,7 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
break;
}
- if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
+ if(tex_usage & PIPE_BIND_RENDER_TARGET) {
if(format_desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
return FALSE;
@@ -205,14 +204,14 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen,
return FALSE;
}
- if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) {
+ if(tex_usage & (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) {
if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
return FALSE;
}
- if(tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
+ if(tex_usage & PIPE_BIND_DEPTH_STENCIL) {
if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
return FALSE;
@@ -234,7 +233,7 @@ llvmpipe_flush_frontbuffer(struct pipe_screen *_screen,
{
struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
struct sw_winsys *winsys = screen->winsys;
- struct llvmpipe_texture *texture = llvmpipe_texture(surface->texture);
+ struct llvmpipe_resource *texture = llvmpipe_resource(surface->texture);
assert(texture->dt);
if (texture->dt)
@@ -289,8 +288,7 @@ llvmpipe_create_screen(struct sw_winsys *winsys)
util_format_s3tc_init();
- llvmpipe_init_screen_texture_funcs(&screen->base);
- llvmpipe_init_screen_buffer_funcs(&screen->base);
+ llvmpipe_init_screen_resource_funcs(&screen->base);
llvmpipe_init_screen_fence_funcs(&screen->base);
lp_jit_screen_init(screen);
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.c b/src/gallium/drivers/llvmpipe/lp_setup.c
index 76a8b87a30..b8abdfa114 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.c
+++ b/src/gallium/drivers/llvmpipe/lp_setup.c
@@ -39,7 +39,6 @@
#include "util/u_surface.h"
#include "lp_scene.h"
#include "lp_scene_queue.h"
-#include "lp_buffer.h"
#include "lp_texture.h"
#include "lp_debug.h"
#include "lp_fence.h"
@@ -379,11 +378,11 @@ lp_setup_set_fs_functions( struct lp_setup_context *setup,
void
lp_setup_set_fs_constants(struct lp_setup_context *setup,
- struct pipe_buffer *buffer)
+ struct pipe_resource *buffer)
{
LP_DBG(DEBUG_SETUP, "%s %p\n", __FUNCTION__, (void *) buffer);
- pipe_buffer_reference(&setup->constants.current, buffer);
+ pipe_resource_reference(&setup->constants.current, buffer);
setup->dirty |= LP_SETUP_NEW_CONSTANTS;
}
@@ -481,8 +480,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
struct pipe_sampler_view *view = i < num ? views[i] : NULL;
if(view) {
- struct pipe_texture *tex = view->texture;
- struct llvmpipe_texture *lp_tex = llvmpipe_texture(tex);
+ struct pipe_resource *tex = view->texture;
+ struct llvmpipe_resource *lp_tex = llvmpipe_resource(tex);
struct lp_jit_texture *jit_tex;
jit_tex = &setup->fs.current.jit_context.textures[i];
jit_tex->width = tex->width0;
@@ -493,7 +492,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
/* We're referencing the texture's internal data, so save a
* reference to it.
*/
- pipe_texture_reference(&setup->fs.current_tex[i], tex);
+ pipe_resource_reference(&setup->fs.current_tex[i], tex);
if (!lp_tex->dt) {
/* regular texture - setup array of mipmap level pointers */
@@ -513,7 +512,7 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
struct llvmpipe_screen *screen = llvmpipe_screen(tex->screen);
struct sw_winsys *winsys = screen->winsys;
jit_tex->data[0] = winsys->displaytarget_map(winsys, lp_tex->dt,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ);
jit_tex->row_stride[0] = lp_tex->stride[0];
assert(jit_tex->data[0]);
}
@@ -530,8 +529,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
* being rendered and the current scene being built.
*/
unsigned
-lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
- const struct pipe_texture *texture )
+lp_setup_is_resource_referenced( const struct lp_setup_context *setup,
+ const struct pipe_resource *texture )
{
unsigned i;
@@ -546,7 +545,7 @@ lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
/* check textures referenced by the scene */
for (i = 0; i < Elements(setup->scenes); i++) {
- if (lp_scene_is_texture_referenced(setup->scenes[i], texture)) {
+ if (lp_scene_is_resource_referenced(setup->scenes[i], texture)) {
return PIPE_REFERENCED_FOR_READ;
}
}
@@ -607,11 +606,11 @@ lp_setup_update_state( struct lp_setup_context *setup )
}
if(setup->dirty & LP_SETUP_NEW_CONSTANTS) {
- struct pipe_buffer *buffer = setup->constants.current;
+ struct pipe_resource *buffer = setup->constants.current;
if(buffer) {
- unsigned current_size = buffer->size;
- const void *current_data = llvmpipe_buffer(buffer)->data;
+ unsigned current_size = buffer->width0;
+ const void *current_data = llvmpipe_resource(buffer)->data;
/* TODO: copy only the actually used constants? */
@@ -693,10 +692,10 @@ lp_setup_destroy( struct lp_setup_context *setup )
reset_context( setup );
for (i = 0; i < Elements(setup->fs.current_tex); i++) {
- pipe_texture_reference(&setup->fs.current_tex[i], NULL);
+ pipe_resource_reference(&setup->fs.current_tex[i], NULL);
}
- pipe_buffer_reference(&setup->constants.current, NULL);
+ pipe_resource_reference(&setup->constants.current, NULL);
/* free the scenes in the 'empty' queue */
while (1) {
diff --git a/src/gallium/drivers/llvmpipe/lp_setup.h b/src/gallium/drivers/llvmpipe/lp_setup.h
index dbfc1bf8d4..e10d37d8d0 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup.h
@@ -52,9 +52,8 @@ struct lp_shader_input {
unsigned src_index; /* where to find values in incoming vertices */
};
-struct pipe_texture;
+struct pipe_resource;
struct pipe_surface;
-struct pipe_buffer;
struct pipe_blend_color;
struct pipe_screen;
struct pipe_framebuffer_state;
@@ -105,7 +104,7 @@ lp_setup_set_fs_functions( struct lp_setup_context *setup,
void
lp_setup_set_fs_constants(struct lp_setup_context *setup,
- struct pipe_buffer *buffer);
+ struct pipe_resource *buffer);
void
@@ -130,8 +129,8 @@ lp_setup_set_fragment_sampler_views(struct lp_setup_context *setup,
struct pipe_sampler_view **views);
unsigned
-lp_setup_is_texture_referenced( const struct lp_setup_context *setup,
- const struct pipe_texture *texture );
+lp_setup_is_resource_referenced( const struct lp_setup_context *setup,
+ const struct pipe_resource *texture );
void
lp_setup_set_flatshade_first( struct lp_setup_context *setup,
diff --git a/src/gallium/drivers/llvmpipe/lp_setup_context.h b/src/gallium/drivers/llvmpipe/lp_setup_context.h
index ca0dafab62..ed21ec0f75 100644
--- a/src/gallium/drivers/llvmpipe/lp_setup_context.h
+++ b/src/gallium/drivers/llvmpipe/lp_setup_context.h
@@ -111,12 +111,12 @@ struct lp_setup_context
const struct lp_rast_state *stored; /**< what's in the scene */
struct lp_rast_state current; /**< currently set state */
- struct pipe_texture *current_tex[PIPE_MAX_SAMPLERS];
+ struct pipe_resource *current_tex[PIPE_MAX_SAMPLERS];
} fs;
/** fragment shader constants */
struct {
- struct pipe_buffer *current;
+ struct pipe_resource *current;
unsigned stored_size;
const void *stored_data;
} constants;
diff --git a/src/gallium/drivers/llvmpipe/lp_state.h b/src/gallium/drivers/llvmpipe/lp_state.h
index 74ebf90d58..d89c28a2af 100644
--- a/src/gallium/drivers/llvmpipe/lp_state.h
+++ b/src/gallium/drivers/llvmpipe/lp_state.h
@@ -170,7 +170,7 @@ void llvmpipe_set_clip_state( struct pipe_context *,
void llvmpipe_set_constant_buffer(struct pipe_context *,
uint shader, uint index,
- struct pipe_buffer *buf);
+ struct pipe_resource *buf);
void *llvmpipe_create_fs_state(struct pipe_context *,
const struct pipe_shader_state *);
@@ -204,7 +204,7 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *,
struct pipe_sampler_view *
llvmpipe_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ);
void
@@ -227,12 +227,12 @@ void llvmpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
unsigned start, unsigned count);
void llvmpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count);
void
llvmpipe_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
index 7bbf348e0b..c57b4a4258 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
@@ -85,7 +85,6 @@
#include "gallivm/lp_bld_swizzle.h"
#include "gallivm/lp_bld_flow.h"
#include "gallivm/lp_bld_debug.h"
-#include "lp_buffer.h"
#include "lp_context.h"
#include "lp_debug.h"
#include "lp_perf.h"
@@ -1044,11 +1043,11 @@ llvmpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
void
llvmpipe_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *constants)
+ struct pipe_resource *constants)
{
struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
- unsigned size = constants ? constants->size : 0;
- const void *data = constants ? llvmpipe_buffer(constants)->data : NULL;
+ unsigned size = constants ? constants->width0 : 0;
+ const void *data = constants ? llvmpipe_resource(constants)->data : NULL;
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
@@ -1059,7 +1058,7 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
draw_flush(llvmpipe->draw);
/* note: reference counting */
- pipe_buffer_reference(&llvmpipe->constants[shader], constants);
+ pipe_resource_reference(&llvmpipe->constants[shader], constants);
if(shader == PIPE_SHADER_VERTEX) {
draw_set_mapped_constant_buffer(llvmpipe->draw, PIPE_SHADER_VERTEX, 0,
diff --git a/src/gallium/drivers/llvmpipe/lp_state_sampler.c b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
index 2645441b58..3552ff50ce 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_sampler.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_sampler.c
@@ -165,7 +165,7 @@ llvmpipe_set_vertex_sampler_views(struct pipe_context *pipe,
struct pipe_sampler_view *
llvmpipe_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -174,7 +174,7 @@ llvmpipe_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}
@@ -186,7 +186,7 @@ void
llvmpipe_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.c b/src/gallium/drivers/llvmpipe/lp_texture.c
index 8137f29af5..972c7ae7c3 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.c
+++ b/src/gallium/drivers/llvmpipe/lp_texture.c
@@ -37,11 +37,13 @@
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_transfer.h"
#include "lp_context.h"
#include "lp_screen.h"
#include "lp_flush.h"
#include "lp_texture.h"
+#include "lp_setup.h"
#include "lp_tile_size.h"
#include "state_tracker/sw_winsys.h"
@@ -51,10 +53,10 @@
* Simple, maximally packed layout.
*/
static boolean
-llvmpipe_texture_layout(struct llvmpipe_screen *screen,
- struct llvmpipe_texture *lpt)
+llvmpipe_resource_layout(struct llvmpipe_screen *screen,
+ struct llvmpipe_resource *lpt)
{
- struct pipe_texture *pt = &lpt->base;
+ struct pipe_resource *pt = &lpt->base;
unsigned level;
unsigned width = pt->width0;
unsigned height = pt->height0;
@@ -92,7 +94,7 @@ llvmpipe_texture_layout(struct llvmpipe_screen *screen,
static boolean
llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
- struct llvmpipe_texture *lpt)
+ struct llvmpipe_resource *lpt)
{
struct sw_winsys *winsys = screen->winsys;
@@ -103,7 +105,7 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
unsigned height = align(lpt->base.height0, TILE_SIZE);
lpt->dt = winsys->displaytarget_create(winsys,
- lpt->base.tex_usage,
+ lpt->base.bind,
lpt->base.format,
width, height,
16,
@@ -113,12 +115,12 @@ llvmpipe_displaytarget_layout(struct llvmpipe_screen *screen,
}
-static struct pipe_texture *
-llvmpipe_texture_create(struct pipe_screen *_screen,
- const struct pipe_texture *templat)
+static struct pipe_resource *
+llvmpipe_resource_create(struct pipe_screen *_screen,
+ const struct pipe_resource *templat)
{
struct llvmpipe_screen *screen = llvmpipe_screen(_screen);
- struct llvmpipe_texture *lpt = CALLOC_STRUCT(llvmpipe_texture);
+ struct llvmpipe_resource *lpt = CALLOC_STRUCT(llvmpipe_resource);
if (!lpt)
return NULL;
@@ -126,17 +128,17 @@ llvmpipe_texture_create(struct pipe_screen *_screen,
pipe_reference_init(&lpt->base.reference, 1);
lpt->base.screen = &screen->base;
- if (lpt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) {
+ if (lpt->base.bind & (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) {
if (!llvmpipe_displaytarget_layout(screen, lpt))
goto fail;
}
else {
- if (!llvmpipe_texture_layout(screen, lpt))
+ if (!llvmpipe_resource_layout(screen, lpt))
goto fail;
}
-
+
return &lpt->base;
fail:
@@ -146,17 +148,18 @@ llvmpipe_texture_create(struct pipe_screen *_screen,
static void
-llvmpipe_texture_destroy(struct pipe_texture *pt)
+llvmpipe_resource_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *pt)
{
- struct llvmpipe_screen *screen = llvmpipe_screen(pt->screen);
- struct llvmpipe_texture *lpt = llvmpipe_texture(pt);
+ struct llvmpipe_screen *screen = llvmpipe_screen(pscreen);
+ struct llvmpipe_resource *lpt = llvmpipe_resource(pt);
if (lpt->dt) {
/* display target */
struct sw_winsys *winsys = screen->winsys;
winsys->displaytarget_destroy(winsys, lpt->dt);
}
- else {
+ else if (!lpt->userBuffer) {
/* regular texture */
align_free(lpt->data);
}
@@ -169,19 +172,19 @@ llvmpipe_texture_destroy(struct pipe_texture *pt)
* Map a texture. Without any synchronization.
*/
void *
-llvmpipe_texture_map(struct pipe_texture *texture,
- unsigned face,
- unsigned level,
- unsigned zslice)
+llvmpipe_resource_map(struct pipe_resource *texture,
+ unsigned usage,
+ unsigned face,
+ unsigned level,
+ unsigned zslice)
{
- struct llvmpipe_texture *lpt = llvmpipe_texture(texture);
+ struct llvmpipe_resource *lpt = llvmpipe_resource(texture);
uint8_t *map;
if (lpt->dt) {
/* display target */
struct llvmpipe_screen *screen = llvmpipe_screen(texture->screen);
struct sw_winsys *winsys = screen->winsys;
- const unsigned usage = PIPE_BUFFER_USAGE_CPU_READ_WRITE;
assert(face == 0);
assert(level == 0);
@@ -204,7 +207,7 @@ llvmpipe_texture_map(struct pipe_texture *texture,
/* XXX shouldn't that rather be
tex_height = align(u_minify(texture->height0, level), 2)
- to account for alignment done in llvmpipe_texture_layout ?
+ to account for alignment done in llvmpipe_resource_layout ?
*/
if (texture->target == PIPE_TEXTURE_CUBE) {
unsigned tex_height = u_minify(texture->height0, level);
@@ -230,12 +233,12 @@ llvmpipe_texture_map(struct pipe_texture *texture,
* Unmap a texture. Without any synchronization.
*/
void
-llvmpipe_texture_unmap(struct pipe_texture *texture,
+llvmpipe_resource_unmap(struct pipe_resource *texture,
unsigned face,
unsigned level,
unsigned zslice)
{
- struct llvmpipe_texture *lpt = llvmpipe_texture(texture);
+ struct llvmpipe_resource *lpt = llvmpipe_resource(texture);
if (lpt->dt) {
/* display target */
@@ -251,13 +254,13 @@ llvmpipe_texture_unmap(struct pipe_texture *texture,
}
-static struct pipe_texture *
-llvmpipe_texture_from_handle(struct pipe_screen *screen,
- const struct pipe_texture *template,
- struct winsys_handle *whandle)
+static struct pipe_resource *
+llvmpipe_resource_from_handle(struct pipe_screen *screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
{
struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
- struct llvmpipe_texture *lpt = CALLOC_STRUCT(llvmpipe_texture);
+ struct llvmpipe_resource *lpt = CALLOC_STRUCT(llvmpipe_resource);
if (!lpt)
return NULL;
@@ -281,12 +284,12 @@ llvmpipe_texture_from_handle(struct pipe_screen *screen,
static boolean
-llvmpipe_texture_get_handle(struct pipe_screen *screen,
- struct pipe_texture *pt,
+llvmpipe_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *pt,
struct winsys_handle *whandle)
{
struct sw_winsys *winsys = llvmpipe_screen(screen)->winsys;
- struct llvmpipe_texture *lpt = llvmpipe_texture(pt);
+ struct llvmpipe_resource *lpt = llvmpipe_resource(pt);
assert(lpt->dt);
if (!lpt->dt)
@@ -298,11 +301,10 @@ llvmpipe_texture_get_handle(struct pipe_screen *screen,
static struct pipe_surface *
llvmpipe_get_tex_surface(struct pipe_screen *screen,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned face, unsigned level, unsigned zslice,
unsigned usage)
{
- struct llvmpipe_texture *lpt = llvmpipe_texture(pt);
struct pipe_surface *ps;
assert(level <= pt->last_level);
@@ -310,32 +312,12 @@ llvmpipe_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
pipe_reference_init(&ps->reference, 1);
- pipe_texture_reference(&ps->texture, pt);
+ 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->usage = usage;
- /* Because we are llvmpipe, anything that the state tracker
- * thought was going to be done with the GPU will actually get
- * done with the CPU. Let's adjust the flags to take that into
- * account.
- */
- if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
- /* GPU_WRITE means "render" and that can involve reads (blending) */
- ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_CPU_READ;
- }
-
- if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ)
- ps->usage |= PIPE_BUFFER_USAGE_CPU_READ;
-
- if (ps->usage & (PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_WRITE)) {
- /* Mark the surface as dirty. */
- lpt->timestamp++;
- llvmpipe_screen(screen)->timestamp++;
- }
-
ps->face = face;
ps->level = level;
ps->zslice = zslice;
@@ -352,37 +334,31 @@ llvmpipe_tex_surface_destroy(struct pipe_surface *surf)
* where it would happen. For llvmpipe, nothing to do.
*/
assert(surf->texture);
- pipe_texture_reference(&surf->texture, NULL);
+ pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
}
static struct pipe_transfer *
-llvmpipe_get_tex_transfer(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
+llvmpipe_get_transfer(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
- struct llvmpipe_texture *lptex = llvmpipe_texture(texture);
+ struct llvmpipe_resource *lptex = llvmpipe_resource(resource);
struct llvmpipe_transfer *lpt;
- assert(texture);
- assert(level <= texture->last_level);
+ assert(resource);
+ assert(sr.level <= resource->last_level);
lpt = CALLOC_STRUCT(llvmpipe_transfer);
if (lpt) {
struct pipe_transfer *pt = &lpt->base;
- pipe_texture_reference(&pt->texture, texture);
- pt->x = x;
- pt->y = y;
- pt->width = align(w, TILE_SIZE);
- pt->height = align(h, TILE_SIZE);
- pt->stride = lptex->stride[level];
+ pipe_resource_reference(&pt->resource, resource);
+ pt->box = *box;
+ pt->stride = lptex->stride[sr.level];
pt->usage = usage;
- pt->face = face;
- pt->level = level;
- pt->zslice = zslice;
return pt;
}
@@ -391,15 +367,15 @@ llvmpipe_get_tex_transfer(struct pipe_context *pipe,
static void
-llvmpipe_tex_transfer_destroy(struct pipe_context *pipe,
+llvmpipe_transfer_destroy(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For llvmpipe, nothing to do.
*/
- assert (transfer->texture);
- pipe_texture_reference(&transfer->texture, NULL);
+ assert (transfer->resource);
+ pipe_resource_reference(&transfer->resource, NULL);
FREE(transfer);
}
@@ -410,11 +386,11 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
{
struct llvmpipe_screen *screen = llvmpipe_screen(pipe->screen);
ubyte *map;
- struct llvmpipe_texture *lpt;
+ struct llvmpipe_resource *lpt;
enum pipe_format format;
- assert(transfer->texture);
- lpt = llvmpipe_texture(transfer->texture);
+ assert(transfer->resource);
+ lpt = llvmpipe_resource(transfer->resource);
format = lpt->base.format;
/*
@@ -422,14 +398,19 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
* context if necessary.
*/
llvmpipe_flush_texture(pipe,
- transfer->texture, transfer->face, transfer->level,
+ transfer->resource,
+ transfer->sr.face,
+ transfer->sr.level,
0, /* flush_flags */
!(transfer->usage & PIPE_TRANSFER_WRITE), /* read_only */
TRUE, /* cpu_access */
FALSE); /* do_not_flush */
- map = llvmpipe_texture_map(transfer->texture,
- transfer->face, transfer->level, transfer->zslice);
+ map = llvmpipe_resource_map(transfer->resource,
+ transfer->usage,
+ transfer->sr.face,
+ transfer->sr.level,
+ transfer->box.z);
/* May want to different things here depending on read/write nature
* of the map:
@@ -441,8 +422,8 @@ llvmpipe_transfer_map( struct pipe_context *pipe,
}
map +=
- transfer->y / util_format_get_blockheight(format) * transfer->stride +
- transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
+ transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
return map;
}
@@ -452,20 +433,68 @@ static void
llvmpipe_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
- assert(transfer->texture);
+ assert(transfer->resource);
+
+ llvmpipe_resource_unmap(transfer->resource,
+ transfer->sr.face,
+ transfer->sr.level,
+ transfer->box.z);
+}
+
+static unsigned int
+llvmpipe_is_resource_referenced( struct pipe_context *pipe,
+ struct pipe_resource *presource,
+ unsigned face, unsigned level)
+{
+ struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe );
+
+ if (presource->target == PIPE_BUFFER)
+ return PIPE_UNREFERENCED;
+
+ return lp_setup_is_resource_referenced(llvmpipe->setup, presource);
+}
+
+
+
+/**
+ * Create buffer which wraps user-space data.
+ */
+static struct pipe_resource *
+llvmpipe_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind_flags)
+{
+ struct llvmpipe_resource *buffer;
+
+ buffer = CALLOC_STRUCT(llvmpipe_resource);
+ if(!buffer)
+ return NULL;
- llvmpipe_texture_unmap(transfer->texture,
- transfer->face, transfer->level, transfer->zslice);
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.screen = screen;
+ buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */
+ buffer->base.bind = bind_flags;
+ buffer->base._usage = PIPE_USAGE_IMMUTABLE;
+ buffer->base.flags = 0;
+ buffer->base.width0 = bytes;
+ buffer->base.height0 = 1;
+ buffer->base.depth0 = 1;
+ buffer->userBuffer = TRUE;
+ buffer->data = ptr;
+
+ return &buffer->base;
}
void
-llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen)
+llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen)
{
- screen->texture_create = llvmpipe_texture_create;
- screen->texture_destroy = llvmpipe_texture_destroy;
- screen->texture_from_handle = llvmpipe_texture_from_handle;
- screen->texture_get_handle = llvmpipe_texture_get_handle;
+ screen->resource_create = llvmpipe_resource_create;
+ screen->resource_destroy = llvmpipe_resource_destroy;
+ screen->resource_from_handle = llvmpipe_resource_from_handle;
+ screen->resource_get_handle = llvmpipe_resource_get_handle;
+ screen->user_buffer_create = llvmpipe_user_buffer_create;
screen->get_tex_surface = llvmpipe_get_tex_surface;
screen->tex_surface_destroy = llvmpipe_tex_surface_destroy;
@@ -473,10 +502,14 @@ llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen)
void
-llvmpipe_init_context_texture_funcs(struct pipe_context *pipe)
+llvmpipe_init_context_resource_funcs(struct pipe_context *pipe)
{
- pipe->get_tex_transfer = llvmpipe_get_tex_transfer;
- pipe->tex_transfer_destroy = llvmpipe_tex_transfer_destroy;
+ pipe->get_transfer = llvmpipe_get_transfer;
+ pipe->transfer_destroy = llvmpipe_transfer_destroy;
pipe->transfer_map = llvmpipe_transfer_map;
pipe->transfer_unmap = llvmpipe_transfer_unmap;
+ pipe->is_resource_referenced = llvmpipe_is_resource_referenced;
+
+ pipe->transfer_flush_region = u_default_transfer_flush_region;
+ pipe->transfer_inline_write = u_default_transfer_inline_write;
}
diff --git a/src/gallium/drivers/llvmpipe/lp_texture.h b/src/gallium/drivers/llvmpipe/lp_texture.h
index 6b78750f1a..0226867840 100644
--- a/src/gallium/drivers/llvmpipe/lp_texture.h
+++ b/src/gallium/drivers/llvmpipe/lp_texture.h
@@ -44,15 +44,15 @@ struct llvmpipe_context;
struct sw_displaytarget;
-struct llvmpipe_texture
+struct llvmpipe_resource
{
- struct pipe_texture base;
+ struct pipe_resource base;
unsigned long level_offset[LP_MAX_TEXTURE_2D_LEVELS];
unsigned stride[LP_MAX_TEXTURE_2D_LEVELS];
/**
- * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET
+ * Display target, for textures with the PIPE_BIND_DISPLAY_TARGET
* usage.
*/
struct sw_displaytarget *dt;
@@ -62,6 +62,7 @@ struct llvmpipe_texture
*/
void *data;
+ boolean userBuffer; /** Is this a user-space buffer? */
unsigned timestamp;
};
@@ -75,17 +76,17 @@ struct llvmpipe_transfer
/** cast wrappers */
-static INLINE struct llvmpipe_texture *
-llvmpipe_texture(struct pipe_texture *pt)
+static INLINE struct llvmpipe_resource *
+llvmpipe_resource(struct pipe_resource *pt)
{
- return (struct llvmpipe_texture *) pt;
+ return (struct llvmpipe_resource *) pt;
}
-static INLINE const struct llvmpipe_texture *
-llvmpipe_texture_const(const struct pipe_texture *pt)
+static INLINE const struct llvmpipe_resource *
+llvmpipe_resource_const(const struct pipe_resource *pt)
{
- return (const struct llvmpipe_texture *) pt;
+ return (const struct llvmpipe_resource *) pt;
}
@@ -96,32 +97,31 @@ llvmpipe_transfer(struct pipe_transfer *pt)
}
+void llvmpipe_init_screen_resource_funcs(struct pipe_screen *screen);
+void llvmpipe_init_context_resource_funcs(struct pipe_context *pipe);
+
static INLINE unsigned
-llvmpipe_texture_stride(struct pipe_texture *texture,
+llvmpipe_resource_stride(struct pipe_resource *texture,
unsigned level)
{
- struct llvmpipe_texture *lpt = llvmpipe_texture(texture);
+ struct llvmpipe_resource *lpt = llvmpipe_resource(texture);
assert(level < LP_MAX_TEXTURE_2D_LEVELS);
return lpt->stride[level];
}
void *
-llvmpipe_texture_map(struct pipe_texture *texture,
- unsigned face,
- unsigned level,
- unsigned zslice);
+llvmpipe_resource_map(struct pipe_resource *texture,
+ unsigned usage,
+ unsigned face,
+ unsigned level,
+ unsigned zslice);
void
-llvmpipe_texture_unmap(struct pipe_texture *texture,
+llvmpipe_resource_unmap(struct pipe_resource *texture,
unsigned face,
unsigned level,
unsigned zslice);
-extern void
-llvmpipe_init_screen_texture_funcs(struct pipe_screen *screen);
-
-extern void
-llvmpipe_init_context_texture_funcs(struct pipe_context *pipe);
#endif /* LP_TEXTURE_H */
diff --git a/src/gallium/drivers/nouveau/Makefile b/src/gallium/drivers/nouveau/Makefile
index 0cb66041d5..db591b756c 100644
--- a/src/gallium/drivers/nouveau/Makefile
+++ b/src/gallium/drivers/nouveau/Makefile
@@ -3,7 +3,9 @@ include $(TOP)/configs/current
LIBNAME = nouveau
-C_SOURCES = nouveau_screen.c \
- nouveau_context.c
+LIBRARY_INCLUDES = \
+ -I$(TOP)/src/gallium/drivers/nouveau/include
+
+C_SOURCES = nouveau_screen.c
include ../../Makefile.template
diff --git a/src/gallium/drivers/nouveau/nouveau_context.c b/src/gallium/drivers/nouveau/nouveau_context.c
deleted file mode 100644
index 15174983e7..0000000000
--- a/src/gallium/drivers/nouveau/nouveau_context.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "pipe/p_defines.h"
-#include "pipe/p_context.h"
-
-#include "nouveau/nouveau_screen.h"
-#include "nouveau/nouveau_context.h"
-
-#include "nouveau/nouveau_bo.h"
-
-static unsigned int
-nouveau_reference_flags(struct nouveau_bo *bo)
-{
- uint32_t bo_flags;
- int flags = 0;
-
- bo_flags = nouveau_bo_pending(bo);
- if (bo_flags & NOUVEAU_BO_RD)
- flags |= PIPE_REFERENCED_FOR_READ;
- if (bo_flags & NOUVEAU_BO_WR)
- flags |= PIPE_REFERENCED_FOR_WRITE;
-
- return flags;
-}
-
-unsigned int
-nouveau_is_texture_referenced(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level)
-{
- struct nouveau_miptree *mt = nouveau_miptree(pt);
-
- return nouveau_reference_flags(mt->bo);
-}
-
-unsigned int
-nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb)
-{
- struct nouveau_bo *bo = nouveau_bo(pb);
-
- return nouveau_reference_flags(bo);
-}
-
diff --git a/src/gallium/drivers/nouveau/nouveau_context.h b/src/gallium/drivers/nouveau/nouveau_context.h
deleted file mode 100644
index 6a28d40da7..0000000000
--- a/src/gallium/drivers/nouveau/nouveau_context.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef __NOUVEAU_CONTEXT_H__
-#define __NOUVEAU_CONTEXT_H__
-
-unsigned int
-nouveau_is_texture_referenced(struct pipe_context *, struct pipe_texture *,
- unsigned face, unsigned level);
-
-unsigned int
-nouveau_is_buffer_referenced(struct pipe_context *, struct pipe_buffer *);
-
-#endif
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c
index b1ad686022..a0bbc3e38d 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -15,6 +15,7 @@
/* XXX this should go away */
#include "state_tracker/drm_api.h"
+#include "util/u_simple_screen.h"
static const char *
nouveau_screen_get_name(struct pipe_screen *pscreen)
@@ -32,56 +33,42 @@ nouveau_screen_get_vendor(struct pipe_screen *pscreen)
return "nouveau";
}
-static struct pipe_buffer *
-nouveau_screen_bo_skel(struct pipe_screen *pscreen, struct nouveau_bo *bo,
- unsigned alignment, unsigned usage, unsigned size)
-{
- struct pipe_buffer *pb;
-
- pb = CALLOC(1, sizeof(struct pipe_buffer)+sizeof(struct nouveau_bo *));
- if (!pb) {
- nouveau_bo_ref(NULL, &bo);
- return NULL;
- }
- pipe_reference_init(&pb->reference, 1);
- pb->screen = pscreen;
- pb->alignment = alignment;
- pb->usage = usage;
- pb->size = size;
- *(struct nouveau_bo **)(pb + 1) = bo;
- return pb;
-}
-static struct pipe_buffer *
+struct nouveau_bo *
nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
- unsigned usage, unsigned size)
+ unsigned usage, unsigned bind, unsigned size)
{
struct nouveau_device *dev = nouveau_screen(pscreen)->device;
struct nouveau_bo *bo = NULL;
uint32_t flags = NOUVEAU_BO_MAP, tile_mode = 0, tile_flags = 0;
int ret;
- if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER)
- flags |= NOUVEAU_BO_GART;
- else
- if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+ if (bind & PIPE_BIND_VERTEX_BUFFER) {
if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF))
flags |= NOUVEAU_BO_GART;
} else
- if (usage & PIPE_BUFFER_USAGE_INDEX) {
+ if (usage & PIPE_BIND_INDEX_BUFFER) {
if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF))
flags |= NOUVEAU_BO_GART;
}
- if (usage & PIPE_BUFFER_USAGE_PIXEL) {
- if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE)
+ if (bind & (PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_DEPTH_STENCIL |
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SAMPLER_VIEW))
+ {
+ /* TODO: this may be incorrect or suboptimal */
+ if (!(bind & PIPE_BIND_SCANOUT))
flags |= NOUVEAU_BO_GART;
- if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE))
+ if (usage != PIPE_USAGE_DYNAMIC)
flags |= NOUVEAU_BO_VRAM;
if (dev->chipset == 0x50 || dev->chipset >= 0x80) {
- if (usage & NOUVEAU_BUFFER_USAGE_ZETA)
+ if (bind & PIPE_BIND_DEPTH_STENCIL)
tile_flags = 0x2800;
else
tile_flags = 0x7000;
@@ -93,10 +80,10 @@ nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
if (ret)
return NULL;
- return nouveau_screen_bo_skel(pscreen, bo, alignment, usage, size);
+ return bo;
}
-static struct pipe_buffer *
+struct nouveau_bo *
nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes)
{
struct nouveau_device *dev = nouveau_screen(pscreen)->device;
@@ -107,47 +94,17 @@ nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes)
if (ret)
return NULL;
- return nouveau_screen_bo_skel(pscreen, bo, 0, 0, bytes);
+ return bo;
}
-static inline uint32_t
-nouveau_screen_map_flags(unsigned pipe)
+void *
+nouveau_screen_bo_map(struct pipe_screen *pscreen,
+ struct nouveau_bo *bo,
+ unsigned map_flags)
{
- uint32_t flags = 0;
-
- if (pipe & PIPE_BUFFER_USAGE_CPU_READ)
- flags |= NOUVEAU_BO_RD;
- if (pipe & PIPE_BUFFER_USAGE_CPU_WRITE)
- flags |= NOUVEAU_BO_WR;
- if (pipe & PIPE_BUFFER_USAGE_DISCARD)
- flags |= NOUVEAU_BO_INVAL;
- if (pipe & PIPE_BUFFER_USAGE_DONTBLOCK)
- flags |= NOUVEAU_BO_NOWAIT;
- else
- if (pipe & PIPE_BUFFER_USAGE_UNSYNCHRONIZED)
- flags |= NOUVEAU_BO_NOSYNC;
-
- return flags;
-}
-
-static void *
-nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb,
- unsigned usage)
-{
- struct nouveau_bo *bo = nouveau_bo(pb);
- struct nouveau_screen *nscreen = nouveau_screen(pscreen);
int ret;
- if (nscreen->pre_pipebuffer_map_callback) {
- ret = nscreen->pre_pipebuffer_map_callback(pscreen, pb, usage);
- if (ret) {
- debug_printf("pre_pipebuffer_map_callback failed %d\n",
- ret);
- return NULL;
- }
- }
-
- ret = nouveau_bo_map(bo, nouveau_screen_map_flags(usage));
+ ret = nouveau_bo_map(bo, map_flags);
if (ret) {
debug_printf("map failed: %d\n", ret);
return NULL;
@@ -156,24 +113,12 @@ nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb,
return bo->map;
}
-static void *
-nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb,
- unsigned offset, unsigned length, unsigned usage)
+void *
+nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct nouveau_bo *bo,
+ unsigned offset, unsigned length, unsigned flags)
{
- struct nouveau_bo *bo = nouveau_bo(pb);
- struct nouveau_screen *nscreen = nouveau_screen(pscreen);
- uint32_t flags = nouveau_screen_map_flags(usage);
int ret;
- if (nscreen->pre_pipebuffer_map_callback) {
- ret = nscreen->pre_pipebuffer_map_callback(pscreen, pb, usage);
- if (ret) {
- debug_printf("pre_pipebuffer_map_callback failed %d\n",
- ret);
- return NULL;
- }
- }
-
ret = nouveau_bo_map_range(bo, offset, length, flags);
if (ret) {
nouveau_bo_unmap(bo);
@@ -185,30 +130,23 @@ nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb,
return (char *)bo->map - offset; /* why gallium? why? */
}
-static void
-nouveau_screen_bo_map_flush(struct pipe_screen *pscreen, struct pipe_buffer *pb,
- unsigned offset, unsigned length)
+void
+nouveau_screen_bo_map_flush_range(struct pipe_screen *pscreen, struct nouveau_bo *bo,
+ unsigned offset, unsigned length)
{
- struct nouveau_bo *bo = nouveau_bo(pb);
-
nouveau_bo_map_flush(bo, offset, length);
}
-static void
-nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct pipe_buffer *pb)
+void
+nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct nouveau_bo *bo)
{
- struct nouveau_bo *bo = nouveau_bo(pb);
-
nouveau_bo_unmap(bo);
}
-static void
-nouveau_screen_bo_del(struct pipe_buffer *pb)
+void
+nouveau_screen_bo_release(struct pipe_screen *pscreen, struct nouveau_bo *bo)
{
- struct nouveau_bo *bo = nouveau_bo(pb);
-
nouveau_bo_ref(NULL, &bo);
- FREE(pb);
}
static void
@@ -236,71 +174,65 @@ nouveau_screen_fence_finish(struct pipe_screen *screen,
}
-/*
- * Both texture_{from|get}_handle use drm api defines directly which they
- * shouldn't do. The problem is that from|get are pipe functions and as
- * such they should be defined in the pipe level. If nouveau had a propper
- * winsys interface we would have added from|get to that interface using
- * the winsys_handle struct as done with other drivers. However this code
- * calls directly into the libdrm_nouveau.so functions (nouveau_bo_*). So
- * we need to translate the handle into something they understand.
- */
-static struct pipe_texture *
-nouveau_screen_texture_from_handle(struct pipe_screen *pscreen,
- const struct pipe_texture *templ,
- struct winsys_handle *whandle)
+struct nouveau_bo *
+nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
+ struct winsys_handle *whandle,
+ unsigned *out_stride)
{
struct nouveau_device *dev = nouveau_screen(pscreen)->device;
- struct pipe_texture *pt;
- struct pipe_buffer *pb;
+ struct nouveau_bo *bo = 0;
int ret;
-
- pb = CALLOC(1, sizeof(struct pipe_buffer) + sizeof(struct nouveau_bo*));
- if (!pb)
- return NULL;
-
- ret = nouveau_bo_handle_ref(dev, whandle->handle, (struct nouveau_bo**)(pb+1));
+
+ ret = nouveau_bo_handle_ref(dev, whandle->handle, &bo);
if (ret) {
debug_printf("%s: ref name 0x%08x failed with %d\n",
__func__, whandle->handle, ret);
- FREE(pb);
return NULL;
}
- pipe_reference_init(&pb->reference, 1);
- pb->screen = pscreen;
- pb->alignment = 0;
- pb->usage = PIPE_BUFFER_USAGE_GPU_READ_WRITE |
- PIPE_BUFFER_USAGE_CPU_READ_WRITE;
- pb->size = nouveau_bo(pb)->size;
- pt = nouveau_screen(pscreen)->texture_blanket(pscreen, templ,
- &whandle->stride, pb);
- pipe_buffer_reference(&pb, NULL);
- return pt;
+ *out_stride = whandle->stride;
+ return bo;
}
-static boolean
-nouveau_screen_texture_get_handle(struct pipe_screen *pscreen,
- struct pipe_texture *pt,
- struct winsys_handle *whandle)
-{
- struct nouveau_miptree *mt = nouveau_miptree(pt);
-
- if (!mt || !mt->bo)
- return false;
- whandle->stride = util_format_get_stride(mt->base.format, mt->base.width0);
+boolean
+nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
+ struct nouveau_bo *bo,
+ unsigned stride,
+ struct winsys_handle *whandle)
+{
+ whandle->stride = stride;
if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) {
- return nouveau_bo_handle_get(mt->bo, &whandle->handle) == 0;
+ return nouveau_bo_handle_get(bo, &whandle->handle) == 0;
} else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
- whandle->handle = mt->bo->handle;
+ whandle->handle = bo->handle;
return TRUE;
} else {
return FALSE;
}
}
+
+unsigned int
+nouveau_reference_flags(struct nouveau_bo *bo)
+{
+ uint32_t bo_flags;
+ int flags = 0;
+
+ bo_flags = nouveau_bo_pending(bo);
+ if (bo_flags & NOUVEAU_BO_RD)
+ flags |= PIPE_REFERENCED_FOR_READ;
+ if (bo_flags & NOUVEAU_BO_WR)
+ flags |= PIPE_REFERENCED_FOR_WRITE;
+
+ return flags;
+}
+
+
+
+
+
int
nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
{
@@ -316,21 +248,10 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev)
pscreen->get_name = nouveau_screen_get_name;
pscreen->get_vendor = nouveau_screen_get_vendor;
- pscreen->buffer_create = nouveau_screen_bo_new;
- pscreen->user_buffer_create = nouveau_screen_bo_user;
- pscreen->buffer_map = nouveau_screen_bo_map;
- pscreen->buffer_map_range = nouveau_screen_bo_map_range;
- pscreen->buffer_flush_mapped_range = nouveau_screen_bo_map_flush;
- pscreen->buffer_unmap = nouveau_screen_bo_unmap;
- pscreen->buffer_destroy = nouveau_screen_bo_del;
-
pscreen->fence_reference = nouveau_screen_fence_ref;
pscreen->fence_signalled = nouveau_screen_fence_signalled;
pscreen->fence_finish = nouveau_screen_fence_finish;
- pscreen->texture_from_handle = nouveau_screen_texture_from_handle;
- pscreen->texture_get_handle = nouveau_screen_texture_get_handle;
-
return 0;
}
diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h
index f4a7a2bc23..c0ec6e4895 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.h
+++ b/src/gallium/drivers/nouveau/nouveau_screen.h
@@ -5,21 +5,6 @@ struct nouveau_screen {
struct pipe_screen base;
struct nouveau_device *device;
struct nouveau_channel *channel;
-
- /**
- * Create a new texture object, using the given template info, but on top of
- * existing memory.
- *
- * It is assumed that the buffer data is layed out according to the expected
- * by the hardware. NULL will be returned if any inconsistency is found.
- */
- struct pipe_texture * (*texture_blanket)(struct pipe_screen *,
- const struct pipe_texture *templat,
- const unsigned *stride,
- struct pipe_buffer *buffer);
-
- int (*pre_pipebuffer_map_callback) (struct pipe_screen *pscreen,
- struct pipe_buffer *pb, unsigned usage);
};
static inline struct nouveau_screen *
@@ -28,24 +13,51 @@ nouveau_screen(struct pipe_screen *pscreen)
return (struct nouveau_screen *)pscreen;
}
-static inline struct nouveau_bo *
-nouveau_bo(struct pipe_buffer *pb)
-{
- return pb ? *(struct nouveau_bo **)(pb + 1) : NULL;
-}
+
+
+/* Not really sure if this is needed, or whether the individual
+ * drivers are happy to talk to the bo functions themselves. In a way
+ * this is what we'd expect from a regular winsys interface.
+ */
+struct nouveau_bo *
+nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment,
+ unsigned usage, unsigned bind, unsigned size);
+struct nouveau_bo *
+nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes);
+void *
+nouveau_screen_bo_map(struct pipe_screen *pscreen,
+ struct nouveau_bo *pb,
+ unsigned usage);
+void *
+nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct nouveau_bo *bo,
+ unsigned offset, unsigned length, unsigned usage);
+void
+nouveau_screen_bo_map_flush_range(struct pipe_screen *pscreen, struct nouveau_bo *bo,
+ unsigned offset, unsigned length);
+void
+nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct nouveau_bo *bo);
+void
+nouveau_screen_bo_release(struct pipe_screen *pscreen, struct nouveau_bo *bo);
+
+boolean
+nouveau_screen_bo_get_handle(struct pipe_screen *pscreen,
+ struct nouveau_bo *bo,
+ unsigned stride,
+ struct winsys_handle *whandle);
+struct nouveau_bo *
+nouveau_screen_bo_from_handle(struct pipe_screen *pscreen,
+ struct winsys_handle *whandle,
+ unsigned *out_stride);
+
+unsigned int
+nouveau_reference_flags(struct nouveau_bo *bo);
+
+
int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *);
void nouveau_screen_fini(struct nouveau_screen *);
-struct nouveau_miptree {
- struct pipe_texture base;
- struct nouveau_bo *bo;
-};
-static inline struct nouveau_miptree *
-nouveau_miptree(struct pipe_texture *pt)
-{
- return (struct nouveau_miptree *)pt;
-}
+
#endif
diff --git a/src/gallium/drivers/nouveau/nouveau_util.h b/src/gallium/drivers/nouveau/nouveau_util.h
index ab7761a31d..ed6e643785 100644
--- a/src/gallium/drivers/nouveau/nouveau_util.h
+++ b/src/gallium/drivers/nouveau/nouveau_util.h
@@ -98,9 +98,9 @@ struct u_split_prim {
unsigned p_start;
unsigned p_end;
- int repeat_first:1;
- int close_first:1;
- int edgeflag_off:1;
+ uint repeat_first:1;
+ uint close_first:1;
+ uint edgeflag_off:1;
};
static inline void
diff --git a/src/gallium/drivers/nouveau/nouveau_winsys.h b/src/gallium/drivers/nouveau/nouveau_winsys.h
index bed014b9ce..b144bef5e6 100644
--- a/src/gallium/drivers/nouveau/nouveau_winsys.h
+++ b/src/gallium/drivers/nouveau/nouveau_winsys.h
@@ -2,7 +2,6 @@
#define NOUVEAU_WINSYS_H
#include <stdint.h>
-#include "util/u_simple_screen.h"
#include "pipe/p_defines.h"
#include "nouveau/nouveau_bo.h"
@@ -17,14 +16,25 @@
#define NOUVEAU_CAP_HW_VTXBUF (0xbeef0000)
#define NOUVEAU_CAP_HW_IDXBUF (0xbeef0001)
-#define NOUVEAU_TEXTURE_USAGE_LINEAR (1 << 16)
-
-#define NOUVEAU_BUFFER_USAGE_TEXTURE (1 << 16)
-#define NOUVEAU_BUFFER_USAGE_ZETA (1 << 17)
-#define NOUVEAU_BUFFER_USAGE_TRANSFER (1 << 18)
-
-/* use along with GPU_WRITE for 2D-only writes */
-#define NOUVEAU_BUFFER_USAGE_NO_RENDER (1 << 19)
+static inline uint32_t
+nouveau_screen_transfer_flags(unsigned pipe)
+{
+ uint32_t flags = 0;
+
+ if (pipe & PIPE_TRANSFER_READ)
+ flags |= NOUVEAU_BO_RD;
+ if (pipe & PIPE_TRANSFER_WRITE)
+ flags |= NOUVEAU_BO_WR;
+ if (pipe & PIPE_TRANSFER_DISCARD)
+ flags |= NOUVEAU_BO_INVAL;
+ if (pipe & PIPE_TRANSFER_DONTBLOCK)
+ flags |= NOUVEAU_BO_NOWAIT;
+ else
+ if (pipe & PIPE_TRANSFER_UNSYNCHRONIZED)
+ flags |= NOUVEAU_BO_NOSYNC;
+
+ return flags;
+}
extern struct pipe_screen *
nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *);
diff --git a/src/gallium/drivers/nv50/Makefile b/src/gallium/drivers/nv50/Makefile
index 5d622e1c13..e31e6f8662 100644
--- a/src/gallium/drivers/nv50/Makefile
+++ b/src/gallium/drivers/nv50/Makefile
@@ -4,12 +4,14 @@ include $(TOP)/configs/current
LIBNAME = nv50
C_SOURCES = \
+ nv50_buffer.c \
nv50_clear.c \
nv50_context.c \
nv50_draw.c \
nv50_miptree.c \
nv50_query.c \
nv50_program.c \
+ nv50_resource.c \
nv50_screen.c \
nv50_state.c \
nv50_state_validate.c \
diff --git a/src/gallium/drivers/nv50/nv50_buffer.c b/src/gallium/drivers/nv50/nv50_buffer.c
new file mode 100644
index 0000000000..094e05e9bb
--- /dev/null
+++ b/src/gallium/drivers/nv50/nv50_buffer.c
@@ -0,0 +1,150 @@
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "nouveau/nouveau_screen.h"
+#include "nouveau/nouveau_winsys.h"
+#include "nv50_resource.h"
+
+
+
+static void nv50_buffer_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *presource)
+{
+ struct nv50_resource *buffer = nv50_resource(presource);
+
+ nouveau_screen_bo_release(pscreen, buffer->bo);
+ FREE(buffer);
+}
+
+
+
+
+/* Utility functions for transfer create/destroy are hooked in and
+ * just record the arguments to those functions.
+ */
+static void *
+nv50_buffer_transfer_map( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct nv50_resource *buffer = nv50_resource(transfer->resource);
+ uint8_t *map;
+
+ map = nouveau_screen_bo_map_range( pipe->screen,
+ buffer->bo,
+ transfer->box.x,
+ transfer->box.width,
+ nouveau_screen_transfer_flags(transfer->usage) );
+ if (map == NULL)
+ return NULL;
+
+ return map + transfer->box.x;
+}
+
+
+
+static void nv50_buffer_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ struct nv50_resource *buffer = nv50_resource(transfer->resource);
+
+ nouveau_screen_bo_map_flush_range(pipe->screen,
+ buffer->bo,
+ transfer->box.x + box->x,
+ box->width);
+}
+
+static void nv50_buffer_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct nv50_resource *buffer = nv50_resource(transfer->resource);
+
+ nouveau_screen_bo_unmap(pipe->screen, buffer->bo);
+}
+
+
+
+
+struct u_resource_vtbl nv50_buffer_vtbl =
+{
+ u_default_resource_get_handle, /* get_handle */
+ nv50_buffer_destroy, /* resource_destroy */
+ NULL, /* is_resource_referenced */
+ u_default_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ nv50_buffer_transfer_map, /* transfer_map */
+ nv50_buffer_transfer_flush_region, /* transfer_flush_region */
+ nv50_buffer_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+
+struct pipe_resource *
+nv50_buffer_create(struct pipe_screen *pscreen,
+ const struct pipe_resource *template)
+{
+ struct nv50_resource *buffer;
+
+ buffer = CALLOC_STRUCT(nv50_resource);
+ if (!buffer)
+ return NULL;
+
+ buffer->base = *template;
+ buffer->vtbl = &nv50_buffer_vtbl;
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.screen = pscreen;
+
+ buffer->bo = nouveau_screen_bo_new(pscreen,
+ 16,
+ buffer->base._usage,
+ buffer->base.bind,
+ buffer->base.width0);
+
+ if (buffer->bo == NULL)
+ goto fail;
+
+ return &buffer->base;
+
+fail:
+ FREE(buffer);
+ return NULL;
+}
+
+
+struct pipe_resource *
+nv50_user_buffer_create(struct pipe_screen *pscreen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind)
+{
+ struct nv50_resource *buffer;
+
+ buffer = CALLOC_STRUCT(nv50_resource);
+ if (!buffer)
+ return NULL;
+
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->vtbl = &nv50_buffer_vtbl;
+ buffer->base.screen = pscreen;
+ buffer->base.format = PIPE_FORMAT_R8_UNORM;
+ buffer->base._usage = PIPE_USAGE_IMMUTABLE;
+ buffer->base.bind = bind;
+ buffer->base.width0 = bytes;
+ buffer->base.height0 = 1;
+ buffer->base.depth0 = 1;
+
+ buffer->bo = nouveau_screen_bo_user(pscreen, ptr, bytes);
+ if (!buffer->bo)
+ goto fail;
+
+ return &buffer->base;
+
+fail:
+ FREE(buffer);
+ return NULL;
+}
+
diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c
index aa14e17872..f543b3c504 100644
--- a/src/gallium/drivers/nv50/nv50_context.c
+++ b/src/gallium/drivers/nv50/nv50_context.c
@@ -25,6 +25,7 @@
#include "nv50_context.h"
#include "nv50_screen.h"
+#include "nv50_resource.h"
static void
nv50_flush(struct pipe_context *pipe, unsigned flags,
@@ -89,15 +90,12 @@ nv50_create(struct pipe_screen *pscreen, void *priv)
nv50->pipe.flush = nv50_flush;
- nv50->pipe.is_texture_referenced = nouveau_is_texture_referenced;
- nv50->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
-
screen->base.channel->user_private = nv50;
nv50_init_surface_functions(nv50);
nv50_init_state_functions(nv50);
nv50_init_query_functions(nv50);
- nv50_init_transfer_functions(nv50);
+ nv50_init_resource_functions(&nv50->pipe);
nv50->draw = draw_create();
assert(nv50->draw);
diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h
index bc7831d9ac..8bf465378e 100644
--- a/src/gallium/drivers/nv50/nv50_context.h
+++ b/src/gallium/drivers/nv50/nv50_context.h
@@ -16,7 +16,6 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_stateobj.h"
-#include "nouveau/nouveau_context.h"
#include "nv50_screen.h"
#include "nv50_program.h"
@@ -101,27 +100,6 @@ get_tile_depth(uint32_t tile_mode)
return 1 << (tile_mode >> 4);
}
-struct nv50_miptree_level {
- int *image_offset;
- unsigned pitch;
- unsigned tile_mode;
-};
-
-#define NV50_MAX_TEXTURE_LEVELS 16
-
-struct nv50_miptree {
- struct nouveau_miptree base;
-
- struct nv50_miptree_level level[NV50_MAX_TEXTURE_LEVELS];
- int image_nr;
- int total_size;
-};
-
-static INLINE struct nv50_miptree *
-nv50_miptree(struct pipe_texture *pt)
-{
- return (struct nv50_miptree *)pt;
-}
struct nv50_surface {
struct pipe_surface base;
@@ -165,7 +143,7 @@ struct nv50_context {
struct nv50_program *vertprog;
struct nv50_program *fragprog;
struct nv50_program *geomprog;
- struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
+ struct pipe_resource *constbuf[PIPE_SHADER_TYPES];
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
unsigned vtxbuf_nr;
struct nv50_vtxelt_stateobj *vtxelt;
@@ -206,12 +184,12 @@ extern void nv50_draw_arrays_instanced(struct pipe_context *, unsigned mode,
unsigned startInstance,
unsigned instanceCount);
extern void nv50_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start,
unsigned count);
extern void nv50_draw_elements_instanced(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start,
unsigned count,
@@ -222,7 +200,7 @@ extern struct nouveau_stateobj *nv50_vbo_validate(struct nv50_context *nv50);
/* nv50_push.c */
extern void
-nv50_push_elements_instanced(struct pipe_context *, struct pipe_buffer *,
+nv50_push_elements_instanced(struct pipe_context *, struct pipe_resource *,
unsigned idxsize, unsigned mode, unsigned start,
unsigned count, unsigned i_start,
unsigned i_count);
@@ -258,13 +236,6 @@ extern boolean nv50_tex_construct(struct nv50_sampler_view *view);
extern void nv50_tex_relocs(struct nv50_context *);
extern struct nouveau_stateobj *nv50_tex_validate(struct nv50_context *);
-/* nv50_transfer.c */
-extern void
-nv50_upload_sifc(struct nv50_context *nv50,
- struct nouveau_bo *bo, unsigned dst_offset, unsigned reloc,
- unsigned dst_format, int dst_w, int dst_h, int dst_pitch,
- void *src, unsigned src_format, int src_pitch,
- int x, int y, int w, int h, int cpp);
/* nv50_context.c */
struct pipe_context *
diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c
index 85b0aef20c..6484f924d0 100644
--- a/src/gallium/drivers/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nv50/nv50_miptree.c
@@ -26,6 +26,8 @@
#include "util/u_format.h"
#include "nv50_context.h"
+#include "nv50_resource.h"
+#include "nv50_transfer.h"
/* The restrictions in tile mode selection probably aren't necessary. */
static INLINE uint32_t
@@ -70,12 +72,66 @@ get_zslice_offset(unsigned tile_mode, unsigned z, unsigned pitch, unsigned nb_h)
return (z % tile_d) * pitch_2d + (z / tile_d) * pitch_3d;
}
-static struct pipe_texture *
-nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
+
+
+
+static void
+nv50_miptree_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *pt)
+{
+ struct nv50_miptree *mt = nv50_miptree(pt);
+ unsigned l;
+
+ for (l = 0; l <= pt->last_level; ++l)
+ FREE(mt->level[l].image_offset);
+
+ nouveau_screen_bo_release(pscreen, mt->base.bo);
+ FREE(mt);
+}
+
+static boolean
+nv50_miptree_get_handle(struct pipe_screen *pscreen,
+ struct pipe_resource *pt,
+ struct winsys_handle *whandle)
+{
+ struct nv50_miptree *mt = nv50_miptree(pt);
+ unsigned stride;
+
+
+ if (!mt || !mt->base.bo)
+ return FALSE;
+
+ stride = util_format_get_stride(mt->base.base.format,
+ mt->base.base.width0);
+
+ return nouveau_screen_bo_get_handle(pscreen,
+ mt->base.bo,
+ stride,
+ whandle);
+}
+
+
+struct u_resource_vtbl nv50_miptree_vtbl =
+{
+ nv50_miptree_get_handle, /* get_handle */
+ nv50_miptree_destroy, /* resource_destroy */
+ NULL, /* is_resource_referenced */
+ nv50_miptree_transfer_new, /* get_transfer */
+ nv50_miptree_transfer_del, /* transfer_destroy */
+ nv50_miptree_transfer_map, /* transfer_map */
+ u_default_transfer_flush_region, /* transfer_flush_region */
+ nv50_miptree_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+struct pipe_resource *
+nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *tmp)
{
struct nouveau_device *dev = nouveau_screen(pscreen)->device;
struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
- struct pipe_texture *pt = &mt->base.base;
+ struct pipe_resource *pt = &mt->base.base;
unsigned width = tmp->width0, height = tmp->height0;
unsigned depth = tmp->depth0, image_alignment;
uint32_t tile_flags;
@@ -104,7 +160,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
tile_flags = 0x7400;
break;
default:
- if ((pt->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) &&
+ if ((pt->bind & PIPE_BIND_SCANOUT) &&
util_format_get_blocksizebits(pt->format) == 32)
tile_flags = 0x7a00;
else
@@ -165,49 +221,53 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
return pt;
}
-static struct pipe_texture *
-nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
- const unsigned *stride, struct pipe_buffer *pb)
+
+struct pipe_resource *
+nv50_miptree_from_handle(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
{
- struct nouveau_bo *bo = nouveau_bo(pb);
struct nv50_miptree *mt;
+ unsigned stride;
/* Only supports 2D, non-mipmapped textures for the moment */
- if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
- pt->depth0 != 1)
+ if (template->target != PIPE_TEXTURE_2D ||
+ template->last_level != 0 ||
+ template->depth0 != 1)
return NULL;
mt = CALLOC_STRUCT(nv50_miptree);
if (!mt)
return NULL;
- mt->base.base = *pt;
+ mt->base.bo = nouveau_screen_bo_from_handle(pscreen, whandle, &stride);
+ if (mt->base.bo == NULL) {
+ FREE(mt);
+ return NULL;
+ }
+
+
+ mt->base.base = *template;
pipe_reference_init(&mt->base.base.reference, 1);
mt->base.base.screen = pscreen;
mt->image_nr = 1;
- mt->level[0].pitch = *stride;
+ mt->level[0].pitch = stride;
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- mt->level[0].tile_mode = bo->tile_mode;
+ mt->level[0].tile_mode = mt->base.bo->tile_mode;
- nouveau_bo_ref(bo, &mt->base.bo);
+ /* XXX: Need to adjust bo refcount??
+ */
+ /* nouveau_bo_ref(bo, &mt->base.bo); */
return &mt->base.base;
}
-static void
-nv50_miptree_destroy(struct pipe_texture *pt)
-{
- struct nv50_miptree *mt = nv50_miptree(pt);
- unsigned l;
- for (l = 0; l <= pt->last_level; ++l)
- FREE(mt->level[l].image_offset);
- nouveau_bo_ref(NULL, &mt->base.bo);
- FREE(mt);
-}
+/* Surface functions
+ */
-static struct pipe_surface *
-nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
+struct pipe_surface *
+nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
unsigned face, unsigned level, unsigned zslice,
unsigned flags)
{
@@ -222,7 +282,7 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ps = CALLOC_STRUCT(pipe_surface);
if (!ps)
return NULL;
- pipe_texture_reference(&ps->texture, pt);
+ pipe_resource_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = u_minify(pt->width0, level);
ps->height = u_minify(pt->height0, level);
@@ -242,23 +302,11 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
return ps;
}
-static void
+void
nv50_miptree_surface_del(struct pipe_surface *ps)
{
struct nv50_surface *s = nv50_surface(ps);
- pipe_texture_reference(&ps->texture, NULL);
+ pipe_resource_reference(&ps->texture, NULL);
FREE(s);
}
-
-void
-nv50_screen_init_miptree_functions(struct pipe_screen *pscreen)
-{
- pscreen->texture_create = nv50_miptree_create;
- pscreen->texture_destroy = nv50_miptree_destroy;
- pscreen->get_tex_surface = nv50_miptree_surface_new;
- pscreen->tex_surface_destroy = nv50_miptree_surface_del;
-
- nouveau_screen(pscreen)->texture_blanket = nv50_miptree_blanket;
-}
-
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 2f61888ed9..11ca2a2117 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -30,6 +30,7 @@
#include "tgsi/tgsi_util.h"
#include "nv50_context.h"
+#include "nv50_transfer.h"
#define NV50_SU_MAX_TEMP 127
#define NV50_SU_MAX_ADDR 4
@@ -4157,7 +4158,8 @@ nv50_program_upload_data(struct nv50_context *nv50, uint32_t *map,
static void
nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
{
- struct pipe_screen *pscreen = nv50->pipe.screen;
+ struct pipe_context *pipe = &nv50->pipe;
+ struct pipe_transfer *transfer;
if (!p->data[0] && p->immd_nr) {
struct nouveau_resource *heap = nv50->screen->immd_heap[0];
@@ -4182,9 +4184,10 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
if (p->param_nr) {
unsigned cb;
- uint32_t *map = pipe_buffer_map(pscreen,
+ uint32_t *map = pipe_buffer_map(pipe,
nv50->constbuf[p->type],
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &transfer);
switch (p->type) {
case PIPE_SHADER_GEOMETRY: cb = NV50_CB_PGP; break;
case PIPE_SHADER_FRAGMENT: cb = NV50_CB_PFP; break;
@@ -4195,7 +4198,8 @@ nv50_program_validate_data(struct nv50_context *nv50, struct nv50_program *p)
}
nv50_program_upload_data(nv50, map, 0, p->param_nr, cb);
- pipe_buffer_unmap(pscreen, nv50->constbuf[p->type]);
+ pipe_buffer_unmap(pipe, nv50->constbuf[p->type],
+ transfer);
}
}
diff --git a/src/gallium/drivers/nv50/nv50_push.c b/src/gallium/drivers/nv50/nv50_push.c
index 96a1f32d30..6981e5b919 100644
--- a/src/gallium/drivers/nv50/nv50_push.c
+++ b/src/gallium/drivers/nv50/nv50_push.c
@@ -5,6 +5,7 @@
#include "nouveau/nouveau_util.h"
#include "nv50_context.h"
+#include "nv50_resource.h"
struct push_context {
struct nv50_context *nv50;
@@ -171,7 +172,7 @@ emit_verts(void *priv, unsigned start, unsigned count)
void
nv50_push_elements_instanced(struct pipe_context *pipe,
- struct pipe_buffer *idxbuf, unsigned idxsize,
+ struct pipe_resource *idxbuf, unsigned idxsize,
unsigned mode, unsigned start, unsigned count,
unsigned i_start, unsigned i_count)
{
@@ -199,7 +200,7 @@ nv50_push_elements_instanced(struct pipe_context *pipe,
for (i = 0; i < nv50->vtxelt->num_elements; i++) {
struct pipe_vertex_element *ve = &nv50->vtxelt->pipe[i];
struct pipe_vertex_buffer *vb = &nv50->vtxbuf[ve->vertex_buffer_index];
- struct nouveau_bo *bo = nouveau_bo(vb->buffer);
+ struct nouveau_bo *bo = nv50_resource(vb->buffer)->bo;
unsigned size, nr_components, n;
if (!(nv50->vbo_fifo & (1 << i)))
@@ -260,7 +261,7 @@ nv50_push_elements_instanced(struct pipe_context *pipe,
/* map index buffer, if present */
if (idxbuf) {
- struct nouveau_bo *bo = nouveau_bo(idxbuf);
+ struct nouveau_bo *bo = nv50_resource(idxbuf)->bo;
if (nouveau_bo_map(bo, NOUVEAU_BO_RD)) {
assert(bo->map);
diff --git a/src/gallium/drivers/nv50/nv50_resource.c b/src/gallium/drivers/nv50/nv50_resource.c
new file mode 100644
index 0000000000..cfdb60418b
--- /dev/null
+++ b/src/gallium/drivers/nv50/nv50_resource.c
@@ -0,0 +1,67 @@
+
+#include "pipe/p_context.h"
+#include "nv50_resource.h"
+#include "nouveau/nouveau_screen.h"
+
+
+/* This doesn't look quite right - this query is supposed to ask
+ * whether the particular context has references to the resource in
+ * any unflushed rendering command buffer, and hence requires a
+ * pipe->flush() for serializing some modification to that resource.
+ *
+ * This seems to be answering the question of whether the resource is
+ * currently on hardware.
+ */
+static unsigned int
+nv50_resource_is_referenced(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level)
+{
+ return nouveau_reference_flags(nv50_resource(resource)->bo);
+}
+
+static struct pipe_resource *
+nv50_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ if (template->target == PIPE_BUFFER)
+ return nv50_buffer_create(screen, template);
+ else
+ return nv50_miptree_create(screen, template);
+}
+
+static struct pipe_resource *
+nv50_resource_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
+{
+ if (template->target == PIPE_BUFFER)
+ return NULL;
+ else
+ return nv50_miptree_from_handle(screen, template, whandle);
+}
+
+void
+nv50_init_resource_functions(struct pipe_context *pcontext)
+{
+ pcontext->get_transfer = u_get_transfer_vtbl;
+ pcontext->transfer_map = u_transfer_map_vtbl;
+ pcontext->transfer_flush_region = u_transfer_flush_region_vtbl;
+ pcontext->transfer_unmap = u_transfer_unmap_vtbl;
+ pcontext->transfer_destroy = u_transfer_destroy_vtbl;
+ pcontext->transfer_inline_write = u_transfer_inline_write_vtbl;
+ pcontext->is_resource_referenced = nv50_resource_is_referenced;
+}
+
+void
+nv50_screen_init_resource_functions(struct pipe_screen *pscreen)
+{
+ pscreen->resource_create = nv50_resource_create;
+ pscreen->resource_from_handle = nv50_resource_from_handle;
+ pscreen->resource_get_handle = u_resource_get_handle_vtbl;
+ pscreen->resource_destroy = u_resource_destroy_vtbl;
+ pscreen->user_buffer_create = nv50_user_buffer_create;
+
+ pscreen->get_tex_surface = nv50_miptree_surface_new;
+ pscreen->tex_surface_destroy = nv50_miptree_surface_del;
+}
diff --git a/src/gallium/drivers/nv50/nv50_resource.h b/src/gallium/drivers/nv50/nv50_resource.h
new file mode 100644
index 0000000000..963a1100ce
--- /dev/null
+++ b/src/gallium/drivers/nv50/nv50_resource.h
@@ -0,0 +1,90 @@
+
+#ifndef NV50_RESOURCE_H
+#define NV50_RESOURCE_H
+
+#include "util/u_transfer.h"
+
+struct pipe_resource;
+struct nouveau_bo;
+
+
+/* This gets further specialized into either buffer or texture
+ * structures. In the future we'll want to remove much of that
+ * distinction, but for now try to keep as close to the existing code
+ * as possible and use the vtbl struct to choose between the two
+ * underlying implementations.
+ */
+struct nv50_resource {
+ struct pipe_resource base;
+ struct u_resource_vtbl *vtbl;
+ struct nouveau_bo *bo;
+};
+
+struct nv50_miptree_level {
+ int *image_offset;
+ unsigned pitch;
+ unsigned tile_mode;
+};
+
+#define NV50_MAX_TEXTURE_LEVELS 16
+
+struct nv50_miptree {
+ struct nv50_resource base;
+
+ struct nv50_miptree_level level[NV50_MAX_TEXTURE_LEVELS];
+ int image_nr;
+ int total_size;
+};
+
+static INLINE struct nv50_miptree *
+nv50_miptree(struct pipe_resource *pt)
+{
+ return (struct nv50_miptree *)pt;
+}
+
+
+static INLINE
+struct nv50_resource *nv50_resource(struct pipe_resource *resource)
+{
+ return (struct nv50_resource *)resource;
+}
+
+
+void
+nv50_init_resource_functions(struct pipe_context *pcontext);
+
+void
+nv50_screen_init_resource_functions(struct pipe_screen *pscreen);
+
+/* Internal functions
+ */
+struct pipe_resource *
+nv50_miptree_create(struct pipe_screen *pscreen,
+ const struct pipe_resource *tmp);
+
+struct pipe_resource *
+nv50_miptree_from_handle(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle);
+
+struct pipe_resource *
+nv50_buffer_create(struct pipe_screen *pscreen,
+ const struct pipe_resource *template);
+
+struct pipe_resource *
+nv50_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage);
+
+
+struct pipe_surface *
+nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
+ unsigned face, unsigned level, unsigned zslice,
+ unsigned flags);
+
+void
+nv50_miptree_surface_del(struct pipe_surface *ps);
+
+
+#endif
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 551e893569..a0fe4c5913 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -24,6 +24,7 @@
#include "nv50_context.h"
#include "nv50_screen.h"
+#include "nv50_resource.h"
#include "nouveau/nouveau_stateobj.h"
@@ -33,7 +34,7 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
enum pipe_texture_target target,
unsigned tex_usage, unsigned geom_flags)
{
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
+ if (tex_usage & PIPE_BIND_RENDER_TARGET) {
switch (format) {
case PIPE_FORMAT_B8G8R8X8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
@@ -48,7 +49,7 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen,
break;
}
} else
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
+ if (tex_usage & PIPE_BIND_DEPTH_STENCIL) {
switch (format) {
case PIPE_FORMAT_Z32_FLOAT:
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
@@ -280,7 +281,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
pscreen->is_format_supported = nv50_screen_is_format_supported;
pscreen->context_create = nv50_create;
- nv50_screen_init_miptree_functions(pscreen);
+ nv50_screen_init_resource_functions(pscreen);
/* DMA engine object */
ret = nouveau_grobj_alloc(chan, 0xbeef5039,
diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h
index 15bd4eed39..092333a3b1 100644
--- a/src/gallium/drivers/nv50/nv50_screen.h
+++ b/src/gallium/drivers/nv50/nv50_screen.h
@@ -22,7 +22,7 @@ struct nv50_screen {
struct nouveau_resource *immd_heap[1];
struct nouveau_resource *parm_heap[PIPE_SHADER_TYPES];
- struct pipe_buffer *strm_vbuf[16];
+ struct pipe_resource *strm_vbuf[16];
struct nouveau_bo *tic;
struct nouveau_bo *tsc;
diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c
index c162808928..e885a2b719 100644
--- a/src/gallium/drivers/nv50/nv50_state.c
+++ b/src/gallium/drivers/nv50/nv50_state.c
@@ -310,13 +310,13 @@ static void
nv50_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(nv50_sampler_view(view));
}
static struct pipe_sampler_view *
nv50_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct nv50_sampler_view *view = CALLOC_STRUCT(nv50_sampler_view);
@@ -324,7 +324,7 @@ nv50_create_sampler_view(struct pipe_context *pipe,
view->pipe = *templ;
view->pipe.reference.count = 1;
view->pipe.texture = NULL;
- pipe_texture_reference(&view->pipe.texture, texture);
+ pipe_resource_reference(&view->pipe.texture, texture);
view->pipe.context = pipe;
if (!nv50_tex_construct(view)) {
@@ -690,7 +690,7 @@ nv50_set_clip_state(struct pipe_context *pipe,
static void
nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
- struct pipe_buffer *buf )
+ struct pipe_resource *buf )
{
struct nv50_context *nv50 = nv50_context(pipe);
diff --git a/src/gallium/drivers/nv50/nv50_state_validate.c b/src/gallium/drivers/nv50/nv50_state_validate.c
index 402045416c..a4deb56ffc 100644
--- a/src/gallium/drivers/nv50/nv50_state_validate.c
+++ b/src/gallium/drivers/nv50/nv50_state_validate.c
@@ -23,6 +23,7 @@
#include "util/u_format.h"
#include "nv50_context.h"
+#include "nv50_resource.h"
#include "nouveau/nouveau_stateobj.h"
static struct nouveau_stateobj *
@@ -43,7 +44,7 @@ validate_fb(struct nv50_context *nv50)
(4 << 16) | (5 << 19) | (6 << 22) | (7 << 25));
for (i = 0; i < fb->nr_cbufs; i++) {
- struct pipe_texture *pt = fb->cbufs[i]->texture;
+ struct pipe_resource *pt = fb->cbufs[i]->texture;
struct nouveau_bo *bo = nv50_miptree(pt)->base.bo;
if (!gw) {
@@ -104,7 +105,7 @@ validate_fb(struct nv50_context *nv50)
}
if (fb->zsbuf) {
- struct pipe_texture *pt = fb->zsbuf->texture;
+ struct pipe_resource *pt = fb->zsbuf->texture;
struct nouveau_bo *bo = nv50_miptree(pt)->base.bo;
if (!gw) {
diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c
index 7a9dada531..c2d9e83526 100644
--- a/src/gallium/drivers/nv50/nv50_surface.c
+++ b/src/gallium/drivers/nv50/nv50_surface.c
@@ -24,6 +24,7 @@
#include <stdint.h>
#include "nouveau/nouveau_pushbuf.h"
#include "nv50_context.h"
+#include "nv50_resource.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
diff --git a/src/gallium/drivers/nv50/nv50_tex.c b/src/gallium/drivers/nv50/nv50_tex.c
index d094b490ed..2c628db97d 100644
--- a/src/gallium/drivers/nv50/nv50_tex.c
+++ b/src/gallium/drivers/nv50/nv50_tex.c
@@ -22,6 +22,7 @@
#include "nv50_context.h"
#include "nv50_texture.h"
+#include "nv50_resource.h"
#include "nouveau/nouveau_stateobj.h"
#include "nouveau/nouveau_reloc.h"
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index 6d16c1354b..9fefed4fef 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -5,6 +5,8 @@
#include "util/u_math.h"
#include "nv50_context.h"
+#include "nv50_transfer.h"
+#include "nv50_resource.h"
struct nv50_transfer {
struct pipe_transfer base;
@@ -121,44 +123,51 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen,
}
}
-static struct pipe_transfer *
-nv50_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
+struct pipe_transfer *
+nv50_miptree_transfer_new(struct pipe_context *pcontext,
+ struct pipe_resource *pt,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
struct pipe_screen *pscreen = pcontext->screen;
struct nouveau_device *dev = nouveau_screen(pscreen)->device;
struct nv50_miptree *mt = nv50_miptree(pt);
- struct nv50_miptree_level *lvl = &mt->level[level];
+ struct nv50_miptree_level *lvl = &mt->level[sr.level];
struct nv50_transfer *tx;
unsigned nx, ny, image = 0;
int ret;
if (pt->target == PIPE_TEXTURE_CUBE)
- image = face;
+ image = sr.face;
tx = CALLOC_STRUCT(nv50_transfer);
if (!tx)
return NULL;
- pipe_texture_reference(&tx->base.texture, pt);
- tx->nblocksx = util_format_get_nblocksx(pt->format, u_minify(pt->width0, level));
- tx->nblocksy = util_format_get_nblocksy(pt->format, u_minify(pt->height0, level));
- tx->base.width = w;
- tx->base.height = h;
+ /* Don't handle 3D transfers yet.
+ */
+ assert(box->depth == 1);
+
+
+ pipe_resource_reference(&tx->base.resource, pt);
+ tx->base.sr = sr;
+ tx->base.usage = usage;
+ tx->base.box = *box;
+ tx->nblocksx = util_format_get_nblocksx(pt->format, u_minify(pt->width0, sr.level));
+ tx->nblocksy = util_format_get_nblocksy(pt->format, u_minify(pt->height0, sr.level));
tx->base.stride = tx->nblocksx * util_format_get_blocksize(pt->format);
tx->base.usage = usage;
tx->level_pitch = lvl->pitch;
- tx->level_width = u_minify(mt->base.base.width0, level);
- tx->level_height = u_minify(mt->base.base.height0, level);
- tx->level_depth = u_minify(mt->base.base.depth0, level);
+ tx->level_width = u_minify(mt->base.base.width0, sr.level);
+ tx->level_height = u_minify(mt->base.base.height0, sr.level);
+ tx->level_depth = u_minify(mt->base.base.depth0, sr.level);
tx->level_offset = lvl->image_offset[image];
tx->level_tiling = lvl->tile_mode;
- tx->level_z = zslice;
- tx->level_x = util_format_get_nblocksx(pt->format, x);
- tx->level_y = util_format_get_nblocksy(pt->format, y);
+ tx->level_z = box->z;
+ tx->level_x = util_format_get_nblocksx(pt->format, box->x);
+ tx->level_y = util_format_get_nblocksy(pt->format, box->y);
ret = nouveau_bo_new(dev, NOUVEAU_BO_GART | NOUVEAU_BO_MAP, 0,
tx->nblocksy * tx->base.stride, &tx->bo);
if (ret) {
@@ -167,12 +176,12 @@ nv50_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
}
if (usage & PIPE_TRANSFER_READ) {
- nx = util_format_get_nblocksx(pt->format, tx->base.width);
- ny = util_format_get_nblocksy(pt->format, tx->base.height);
+ nx = util_format_get_nblocksx(pt->format, box->width);
+ ny = util_format_get_nblocksy(pt->format, box->height);
nv50_transfer_rect_m2mf(pscreen, mt->base.bo, tx->level_offset,
tx->level_pitch, tx->level_tiling,
- x, y, zslice,
+ box->x, box->y, box->z,
tx->nblocksx, tx->nblocksy,
tx->level_depth,
tx->bo, 0,
@@ -187,15 +196,16 @@ nv50_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
return &tx->base;
}
-static void
-nv50_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx)
+void
+nv50_miptree_transfer_del(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx)
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
- struct nv50_miptree *mt = nv50_miptree(ptx->texture);
- struct pipe_texture *pt = ptx->texture;
+ struct nv50_miptree *mt = nv50_miptree(ptx->resource);
+ struct pipe_resource *pt = ptx->resource;
- unsigned nx = util_format_get_nblocksx(pt->format, tx->base.width);
- unsigned ny = util_format_get_nblocksy(pt->format, tx->base.height);
+ unsigned nx = util_format_get_nblocksx(pt->format, tx->base.box.width);
+ unsigned ny = util_format_get_nblocksy(pt->format, tx->base.box.height);
if (ptx->usage & PIPE_TRANSFER_WRITE) {
struct pipe_screen *pscreen = pcontext->screen;
@@ -215,12 +225,13 @@ nv50_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx)
}
nouveau_bo_ref(NULL, &tx->bo);
- pipe_texture_reference(&ptx->texture, NULL);
+ pipe_resource_reference(&ptx->resource, NULL);
FREE(ptx);
}
-static void *
-nv50_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
+void *
+nv50_miptree_transfer_map(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx)
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
unsigned flags = 0;
@@ -242,8 +253,9 @@ nv50_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
return tx->bo->map;
}
-static void
-nv50_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
+void
+nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx)
{
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
@@ -252,14 +264,6 @@ nv50_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
nouveau_bo_unmap(tx->bo);
}
-void
-nv50_init_transfer_functions(struct nv50_context *nv50)
-{
- nv50->pipe.get_tex_transfer = nv50_transfer_new;
- nv50->pipe.tex_transfer_destroy = nv50_transfer_del;
- nv50->pipe.transfer_map = nv50_transfer_map;
- nv50->pipe.transfer_unmap = nv50_transfer_unmap;
-}
void
nv50_upload_sifc(struct nv50_context *nv50,
diff --git a/src/gallium/drivers/nv50/nv50_transfer.h b/src/gallium/drivers/nv50/nv50_transfer.h
new file mode 100644
index 0000000000..663503547c
--- /dev/null
+++ b/src/gallium/drivers/nv50/nv50_transfer.h
@@ -0,0 +1,31 @@
+
+#ifndef NV50_TRANSFER_H
+#define NV50_TRANSFER_H
+
+#include "pipe/p_state.h"
+
+
+struct pipe_transfer *
+nv50_miptree_transfer_new(struct pipe_context *pcontext,
+ struct pipe_resource *pt,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box);
+void
+nv50_miptree_transfer_del(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx);
+void *
+nv50_miptree_transfer_map(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx);
+void
+nv50_miptree_transfer_unmap(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx);
+
+extern void
+nv50_upload_sifc(struct nv50_context *nv50,
+ struct nouveau_bo *bo, unsigned dst_offset, unsigned reloc,
+ unsigned dst_format, int dst_w, int dst_h, int dst_pitch,
+ void *src, unsigned src_format, int src_pitch,
+ int x, int y, int w, int h, int cpp);
+
+#endif
diff --git a/src/gallium/drivers/nv50/nv50_vbo.c b/src/gallium/drivers/nv50/nv50_vbo.c
index 5047286806..609145db88 100644
--- a/src/gallium/drivers/nv50/nv50_vbo.c
+++ b/src/gallium/drivers/nv50/nv50_vbo.c
@@ -27,6 +27,7 @@
#include "nouveau/nouveau_util.h"
#include "nv50_context.h"
+#include "nv50_resource.h"
static INLINE uint32_t
nv50_vbo_type_to_hw(enum pipe_format format)
@@ -139,7 +140,7 @@ instance_init(struct nv50_context *nv50, struct instance *a, unsigned first)
if (a[i].divisor) {
vb = &nv50->vtxbuf[ve->vertex_buffer_index];
- a[i].bo = nouveau_bo(vb->buffer);
+ a[i].bo = nv50_resource(vb->buffer)->bo;
a[i].stride = vb->stride;
a[i].step = first % a[i].divisor;
a[i].delta = vb->buffer_offset + ve->src_offset +
@@ -307,14 +308,14 @@ inline_edgeflag(void *priv, boolean enabled)
static void
nv50_draw_elements_inline(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer, unsigned indexSize,
+ struct pipe_resource *indexBuffer, unsigned indexSize,
unsigned mode, unsigned start, unsigned count,
unsigned startInstance, unsigned instanceCount)
{
- struct pipe_screen *pscreen = pipe->screen;
struct nv50_context *nv50 = nv50_context(pipe);
struct nouveau_channel *chan = nv50->screen->tesla->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
+ struct pipe_transfer *transfer;
struct instance a[16];
struct inline_ctx ctx;
struct u_split_prim s;
@@ -337,7 +338,7 @@ nv50_draw_elements_inline(struct pipe_context *pipe,
s.edge = inline_edgeflag;
ctx.nv50 = nv50;
- ctx.map = pipe_buffer_map(pscreen, indexBuffer, PIPE_BUFFER_USAGE_CPU_READ);
+ ctx.map = pipe_buffer_map(pipe, indexBuffer, PIPE_TRANSFER_READ, &transfer);
assert(ctx.map);
if (!ctx.map)
return;
@@ -380,12 +381,12 @@ nv50_draw_elements_inline(struct pipe_context *pipe,
nzi = TRUE;
}
- pipe_buffer_unmap(pscreen, indexBuffer);
+ pipe_buffer_unmap(pipe, indexBuffer, transfer);
}
void
nv50_draw_elements_instanced(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count,
unsigned startInstance, unsigned instanceCount)
@@ -406,7 +407,7 @@ nv50_draw_elements_instanced(struct pipe_context *pipe,
instanceCount);
return;
} else
- if (!(indexBuffer->usage & PIPE_BUFFER_USAGE_INDEX) || indexSize == 1) {
+ if (!(indexBuffer->bind & PIPE_BIND_INDEX_BUFFER) || indexSize == 1) {
nv50_draw_elements_inline(pipe, indexBuffer, indexSize,
mode, start, count, startInstance,
instanceCount);
@@ -431,7 +432,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe,
if (indexSize == 4) {
BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U32 | 0x30000, 0);
OUT_RING (chan, count);
- nouveau_pushbuf_submit(chan, nouveau_bo(indexBuffer),
+ nouveau_pushbuf_submit(chan,
+ nv50_resource(indexBuffer)->bo,
start << 2, count << 2);
} else
if (indexSize == 2) {
@@ -443,7 +445,8 @@ nv50_draw_elements_instanced(struct pipe_context *pipe,
OUT_RING (chan, ((start & 1) << 31) | count);
BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16 | 0x30000, 0);
OUT_RING (chan, dwords);
- nouveau_pushbuf_submit(chan, nouveau_bo(indexBuffer),
+ nouveau_pushbuf_submit(chan,
+ nv50_resource(indexBuffer)->bo,
vb_start << 1, dwords << 2);
BEGIN_RING(chan, tesla, NV50TCL_VB_ELEMENT_U16_SETUP, 1);
OUT_RING (chan, 0);
@@ -457,7 +460,7 @@ nv50_draw_elements_instanced(struct pipe_context *pipe,
void
nv50_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer, unsigned indexSize,
+ struct pipe_resource *indexBuffer, unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
nv50_draw_elements_instanced(pipe, indexBuffer, indexSize,
@@ -473,7 +476,7 @@ nv50_vbo_static_attrib(struct nv50_context *nv50, unsigned attrib,
{
struct nouveau_stateobj *so;
struct nouveau_grobj *tesla = nv50->screen->tesla;
- struct nouveau_bo *bo = nouveau_bo(vb->buffer);
+ struct nouveau_bo *bo = nv50_resource(vb->buffer)->bo;
float v[4];
int ret;
unsigned nr_components = util_format_get_nr_components(ve->src_format);
@@ -556,7 +559,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
for (i = 0; i < nv50->vtxbuf_nr; i++) {
if (nv50->vtxbuf[i].stride &&
- !(nv50->vtxbuf[i].buffer->usage & PIPE_BUFFER_USAGE_VERTEX))
+ !(nv50->vtxbuf[i].buffer->bind & PIPE_BIND_VERTEX_BUFFER))
nv50->vbo_fifo = 0xffff;
}
@@ -571,7 +574,7 @@ nv50_vbo_validate(struct nv50_context *nv50)
struct pipe_vertex_element *ve = &nv50->vtxelt->pipe[i];
struct pipe_vertex_buffer *vb =
&nv50->vtxbuf[ve->vertex_buffer_index];
- struct nouveau_bo *bo = nouveau_bo(vb->buffer);
+ struct nouveau_bo *bo = nv50_resource(vb->buffer)->bo;
uint32_t hw = nv50->vtxelt->hw[i];
if (!vb->stride &&
@@ -608,10 +611,10 @@ nv50_vbo_validate(struct nv50_context *nv50)
/* vertex array limits */
so_method(vtxbuf, tesla, NV50TCL_VERTEX_ARRAY_LIMIT_HIGH(i), 2);
- so_reloc (vtxbuf, bo, vb->buffer->size - 1,
+ so_reloc (vtxbuf, bo, vb->buffer->width0 - 1,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
NOUVEAU_BO_HIGH, 0, 0);
- so_reloc (vtxbuf, bo, vb->buffer->size - 1,
+ so_reloc (vtxbuf, bo, vb->buffer->width0 - 1,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD |
NOUVEAU_BO_LOW, 0, 0);
}
diff --git a/src/gallium/drivers/nvfx/Makefile b/src/gallium/drivers/nvfx/Makefile
index dfe97e6ed5..c1d57ca396 100644
--- a/src/gallium/drivers/nvfx/Makefile
+++ b/src/gallium/drivers/nvfx/Makefile
@@ -5,6 +5,7 @@ LIBNAME = nvfx
C_SOURCES = \
nv04_surface_2d.c \
+ nvfx_buffer.c \
nvfx_context.c \
nvfx_clear.c \
nvfx_draw.c \
@@ -14,6 +15,7 @@ C_SOURCES = \
nv40_fragtex.c \
nvfx_miptree.c \
nvfx_query.c \
+ nvfx_resource.c \
nvfx_screen.c \
nvfx_state.c \
nvfx_state_blend.c \
@@ -29,4 +31,7 @@ C_SOURCES = \
nvfx_vbo.c \
nvfx_vertprog.c
+LIBRARY_INCLUDES = \
+ -I$(TOP)/src/gallium/drivers/nouveau/include
+
include ../../Makefile.template
diff --git a/src/gallium/drivers/nvfx/nv04_surface_2d.c b/src/gallium/drivers/nvfx/nv04_surface_2d.c
index 6784170c00..005d72b30c 100644
--- a/src/gallium/drivers/nvfx/nv04_surface_2d.c
+++ b/src/gallium/drivers/nvfx/nv04_surface_2d.c
@@ -125,8 +125,8 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
struct nouveau_channel *chan = ctx->swzsurf->channel;
struct nouveau_grobj *swzsurf = ctx->swzsurf;
struct nouveau_grobj *sifm = ctx->sifm;
- struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+ struct nouveau_bo *src_bo = ctx->buf(src);
+ struct nouveau_bo *dst_bo = ctx->buf(dst);
const unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
/* Max width & height may not be the same on all HW, but must be POT */
const unsigned max_w = 1024;
@@ -205,8 +205,8 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
{
struct nouveau_channel *chan = ctx->m2mf->channel;
struct nouveau_grobj *m2mf = ctx->m2mf;
- struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+ struct nouveau_bo *src_bo = ctx->buf(src);
+ struct nouveau_bo *dst_bo = ctx->buf(dst);
unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
unsigned dst_offset = dst->offset + dy * dst_pitch +
@@ -252,8 +252,8 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
struct nouveau_channel *chan = ctx->surf2d->channel;
struct nouveau_grobj *surf2d = ctx->surf2d;
struct nouveau_grobj *blit = ctx->blit;
- struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+ struct nouveau_bo *src_bo = ctx->buf(src);
+ struct nouveau_bo *dst_bo = ctx->buf(dst);
unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
int format;
@@ -287,8 +287,8 @@ nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
{
unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
- int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
- int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
+ int src_linear = src->texture->flags & NVFX_RESOURCE_FLAG_LINEAR;
+ int dst_linear = dst->texture->flags & NVFX_RESOURCE_FLAG_LINEAR;
assert(src->format == dst->format);
@@ -317,7 +317,7 @@ nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
struct nouveau_channel *chan = ctx->surf2d->channel;
struct nouveau_grobj *surf2d = ctx->surf2d;
struct nouveau_grobj *rect = ctx->rect;
- struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+ struct nouveau_bo *dst_bo = ctx->buf(dst);
unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
int cs2d_format, gdirect_format;
@@ -501,26 +501,19 @@ nv04_surface_2d_init(struct nouveau_screen *screen)
}
struct nv04_surface*
-nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
+nv04_surface_wrap_for_render(struct pipe_screen *pscreen,
+ struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
{
int temp_flags;
- // printf("creating temp, flags is %i!\n", flags);
+ temp_flags = (ns->base.usage |
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION);
- if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD)
- {
- temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ;
- ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD;
- }
- else
- {
- temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
- ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ;
- }
-
- ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
+ ns->base.usage = (PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION);
- struct pipe_texture templ;
+ struct pipe_resource templ;
memset(&templ, 0, sizeof(templ));
templ.format = ns->base.texture->format;
templ.target = PIPE_TEXTURE_2D;
@@ -532,14 +525,16 @@ nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d
// TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented
templ.nr_samples = ns->base.texture->nr_samples;
- templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templ.bind = ns->base.texture->bind | PIPE_BIND_RENDER_TARGET;
- struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ);
+ struct pipe_resource* temp_tex = pscreen->resource_create(pscreen, &templ);
struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
temp_ns->backing = ns;
- if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ)
- eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height);
+ if(ns->base.usage & PIPE_BIND_BLIT_SOURCE)
+ eng2d->copy(eng2d, &temp_ns->backing->base,
+ 0, 0, &ns->base,
+ 0, 0, ns->base.width, ns->base.height);
return temp_ns;
}
diff --git a/src/gallium/drivers/nvfx/nv04_surface_2d.h b/src/gallium/drivers/nvfx/nv04_surface_2d.h
index ce696a11a3..b2b237b9df 100644
--- a/src/gallium/drivers/nvfx/nv04_surface_2d.h
+++ b/src/gallium/drivers/nvfx/nv04_surface_2d.h
@@ -16,7 +16,7 @@ struct nv04_surface_2d {
struct nouveau_grobj *blit;
struct nouveau_grobj *sifm;
- struct pipe_buffer *(*buf)(struct pipe_surface *);
+ struct nouveau_bo *(*buf)(struct pipe_surface *);
void (*copy)(struct nv04_surface_2d *, struct pipe_surface *dst,
int dx, int dy, struct pipe_surface *src, int sx, int sy,
@@ -34,4 +34,6 @@ nv04_surface_2d_takedown(struct nv04_surface_2d **);
struct nv04_surface*
nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns);
+#define NVFX_RESOURCE_FLAG_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
+
#endif
diff --git a/src/gallium/drivers/nvfx/nv30_fragtex.c b/src/gallium/drivers/nvfx/nv30_fragtex.c
index d3f3edb327..e0356783ea 100644
--- a/src/gallium/drivers/nvfx/nv30_fragtex.c
+++ b/src/gallium/drivers/nvfx/nv30_fragtex.c
@@ -3,6 +3,7 @@
#include "nvfx_context.h"
#include "nouveau/nouveau_util.h"
#include "nvfx_tex.h"
+#include "nvfx_resource.h"
void
nv30_sampler_state_init(struct pipe_context *pipe,
@@ -92,8 +93,8 @@ nv30_fragtex_build(struct nvfx_context *nvfx, int unit)
{
struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
struct nvfx_miptree *nv30mt = (struct nvfx_miptree *)nvfx->fragment_sampler_views[unit]->texture;
- struct pipe_texture *pt = &nv30mt->base;
- struct nouveau_bo *bo = nouveau_bo(nv30mt->buffer);
+ struct pipe_resource *pt = &nv30mt->base.base;
+ struct nouveau_bo *bo = nv30mt->base.bo;
struct nv30_texture_format *tf;
struct nouveau_stateobj *so;
uint32_t txf, txs;
diff --git a/src/gallium/drivers/nvfx/nv40_fragtex.c b/src/gallium/drivers/nvfx/nv40_fragtex.c
index fe87cebbb6..bffdf0893c 100644
--- a/src/gallium/drivers/nvfx/nv40_fragtex.c
+++ b/src/gallium/drivers/nvfx/nv40_fragtex.c
@@ -1,6 +1,7 @@
#include "util/u_format.h"
#include "nvfx_context.h"
#include "nvfx_tex.h"
+#include "nvfx_resource.h"
void
nv40_sampler_state_init(struct pipe_context *pipe,
@@ -110,8 +111,8 @@ nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
{
struct nvfx_sampler_state *ps = nvfx->tex_sampler[unit];
struct nvfx_miptree *nv40mt = (struct nvfx_miptree *)nvfx->fragment_sampler_views[unit]->texture;
- struct nouveau_bo *bo = nouveau_bo(nv40mt->buffer);
- struct pipe_texture *pt = &nv40mt->base;
+ struct nouveau_bo *bo = nv40mt->base.bo;
+ struct pipe_resource *pt = &nv40mt->base.base;
struct nv40_texture_format *tf;
struct nouveau_stateobj *so;
uint32_t txf, txs, txp;
@@ -146,7 +147,7 @@ nv40_fragtex_build(struct nvfx_context *nvfx, int unit)
return NULL;
}
- if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+ if (!(pt->flags & NVFX_RESOURCE_FLAG_LINEAR)) {
txp = 0;
} else {
txp = nv40mt->level[0].pitch;
diff --git a/src/gallium/drivers/nvfx/nvfx_buffer.c b/src/gallium/drivers/nvfx/nvfx_buffer.c
new file mode 100644
index 0000000000..24e0a0c7f6
--- /dev/null
+++ b/src/gallium/drivers/nvfx/nvfx_buffer.c
@@ -0,0 +1,153 @@
+
+#include "util/u_inlines.h"
+#include "util/u_memory.h"
+#include "util/u_math.h"
+
+#include "nouveau/nouveau_screen.h"
+#include "nouveau/nouveau_winsys.h"
+#include "nvfx_resource.h"
+
+
+/* Currently using separate implementations for buffers and textures,
+ * even though gallium has a unified abstraction of these objects.
+ * Eventually these should be combined, and mechanisms like transfers
+ * be adapted to work for both buffer and texture uploads.
+ */
+static void nvfx_buffer_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *presource)
+{
+ struct nvfx_resource *buffer = nvfx_resource(presource);
+
+ nouveau_screen_bo_release(pscreen, buffer->bo);
+ FREE(buffer);
+}
+
+
+
+
+/* Utility functions for transfer create/destroy are hooked in and
+ * just record the arguments to those functions.
+ */
+static void *
+nvfx_buffer_transfer_map( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct nvfx_resource *buffer = nvfx_resource(transfer->resource);
+ uint8_t *map;
+
+ map = nouveau_screen_bo_map_range( pipe->screen,
+ buffer->bo,
+ transfer->box.x,
+ transfer->box.width,
+ nouveau_screen_transfer_flags(transfer->usage) );
+ if (map == NULL)
+ return NULL;
+
+ return map + transfer->box.x;
+}
+
+
+
+static void nvfx_buffer_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ struct nvfx_resource *buffer = nvfx_resource(transfer->resource);
+
+ nouveau_screen_bo_map_flush_range(pipe->screen,
+ buffer->bo,
+ transfer->box.x + box->x,
+ box->width);
+}
+
+static void nvfx_buffer_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct nvfx_resource *buffer = nvfx_resource(transfer->resource);
+
+ nouveau_screen_bo_unmap(pipe->screen, buffer->bo);
+}
+
+
+
+
+struct u_resource_vtbl nvfx_buffer_vtbl =
+{
+ u_default_resource_get_handle, /* get_handle */
+ nvfx_buffer_destroy, /* resource_destroy */
+ NULL, /* is_resource_referenced */
+ u_default_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ nvfx_buffer_transfer_map, /* transfer_map */
+ nvfx_buffer_transfer_flush_region, /* transfer_flush_region */
+ nvfx_buffer_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+struct pipe_resource *
+nvfx_buffer_create(struct pipe_screen *pscreen,
+ const struct pipe_resource *template)
+{
+ struct nvfx_resource *buffer;
+
+ buffer = CALLOC_STRUCT(nvfx_resource);
+ if (!buffer)
+ return NULL;
+
+ buffer->base = *template;
+ buffer->vtbl = &nvfx_buffer_vtbl;
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.screen = pscreen;
+
+ buffer->bo = nouveau_screen_bo_new(pscreen,
+ 16,
+ buffer->base._usage,
+ buffer->base.bind,
+ buffer->base.width0);
+
+ if (buffer->bo == NULL)
+ goto fail;
+
+ return &buffer->base;
+
+fail:
+ FREE(buffer);
+ return NULL;
+}
+
+
+struct pipe_resource *
+nvfx_user_buffer_create(struct pipe_screen *pscreen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage)
+{
+ struct nvfx_resource *buffer;
+
+ buffer = CALLOC_STRUCT(nvfx_resource);
+ if (!buffer)
+ return NULL;
+
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->vtbl = &nvfx_buffer_vtbl;
+ buffer->base.screen = pscreen;
+ buffer->base.format = PIPE_FORMAT_R8_UNORM;
+ buffer->base._usage = PIPE_USAGE_IMMUTABLE;
+ buffer->base.bind = usage;
+ buffer->base.width0 = bytes;
+ buffer->base.height0 = 1;
+ buffer->base.depth0 = 1;
+
+ buffer->bo = nouveau_screen_bo_user(pscreen, ptr, bytes);
+ if (!buffer->bo)
+ goto fail;
+
+ return &buffer->base;
+
+fail:
+ FREE(buffer);
+ return NULL;
+}
+
diff --git a/src/gallium/drivers/nvfx/nvfx_context.c b/src/gallium/drivers/nvfx/nvfx_context.c
index fc3cbdb558..61f55907e0 100644
--- a/src/gallium/drivers/nvfx/nvfx_context.c
+++ b/src/gallium/drivers/nvfx/nvfx_context.c
@@ -3,6 +3,7 @@
#include "nvfx_context.h"
#include "nvfx_screen.h"
+#include "nvfx_resource.h"
static void
nvfx_flush(struct pipe_context *pipe, unsigned flags,
@@ -65,9 +66,6 @@ nvfx_create(struct pipe_screen *pscreen, void *priv)
nvfx->pipe.clear = nvfx_clear;
nvfx->pipe.flush = nvfx_flush;
- nvfx->pipe.is_texture_referenced = nouveau_is_texture_referenced;
- nvfx->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
-
screen->base.channel->user_private = nvfx;
screen->base.channel->flush_notify = nvfx_state_flush_notify;
@@ -76,7 +74,7 @@ nvfx_create(struct pipe_screen *pscreen, void *priv)
nvfx_init_query_functions(nvfx);
nvfx_init_surface_functions(nvfx);
nvfx_init_state_functions(nvfx);
- nvfx_init_transfer_functions(nvfx);
+ nvfx_init_resource_functions(&nvfx->pipe);
/* Create, configure, and install fallback swtnl path */
nvfx->draw = draw_create();
diff --git a/src/gallium/drivers/nvfx/nvfx_context.h b/src/gallium/drivers/nvfx/nvfx_context.h
index ab7225cf6c..9d988b015c 100644
--- a/src/gallium/drivers/nvfx/nvfx_context.h
+++ b/src/gallium/drivers/nvfx/nvfx_context.h
@@ -16,7 +16,6 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
-#include "nouveau/nouveau_context.h"
#include "nouveau/nouveau_stateobj.h"
#include "nvfx_state.h"
@@ -146,7 +145,7 @@ struct nvfx_context {
struct pipe_clip_state clip;
struct nvfx_vertex_program *vertprog;
struct nvfx_fragment_program *fragprog;
- struct pipe_buffer *constbuf[PIPE_SHADER_TYPES];
+ struct pipe_resource *constbuf[PIPE_SHADER_TYPES];
unsigned constbuf_nr[PIPE_SHADER_TYPES];
struct nvfx_rasterizer_state *rasterizer;
struct nvfx_zsa_state *zsa;
@@ -155,7 +154,7 @@ struct nvfx_context {
struct pipe_stencil_ref stencil_ref;
struct pipe_viewport_state viewport;
struct pipe_framebuffer_state framebuffer;
- struct pipe_buffer *idxbuf;
+ struct pipe_resource *idxbuf;
unsigned idxbuf_format;
struct nvfx_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
@@ -210,7 +209,7 @@ extern void nvfx_clear(struct pipe_context *pipe, unsigned buffers,
/* nvfx_draw.c */
extern struct draw_stage *nvfx_draw_render_stage(struct nvfx_context *nvfx);
extern void nvfx_draw_elements_swtnl(struct pipe_context *pipe,
- struct pipe_buffer *idxbuf,
+ struct pipe_resource *idxbuf,
unsigned ib_size, unsigned mode,
unsigned start, unsigned count);
@@ -252,7 +251,7 @@ extern void nvfx_init_transfer_functions(struct nvfx_context *nvfx);
extern void nvfx_draw_arrays(struct pipe_context *, unsigned mode,
unsigned start, unsigned count);
extern void nvfx_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start,
unsigned count);
diff --git a/src/gallium/drivers/nvfx/nvfx_draw.c b/src/gallium/drivers/nvfx/nvfx_draw.c
index 68e50a3647..fc6f8d0272 100644
--- a/src/gallium/drivers/nvfx/nvfx_draw.c
+++ b/src/gallium/drivers/nvfx/nvfx_draw.c
@@ -234,11 +234,13 @@ nvfx_draw_render_stage(struct nvfx_context *nvfx)
void
nvfx_draw_elements_swtnl(struct pipe_context *pipe,
- struct pipe_buffer *idxbuf, unsigned idxbuf_size,
+ struct pipe_resource *idxbuf, unsigned idxbuf_size,
unsigned mode, unsigned start, unsigned count)
{
struct nvfx_context *nvfx = nvfx_context(pipe);
- struct pipe_screen *pscreen = pipe->screen;
+ struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
+ struct pipe_transfer *ib_transfer;
+ struct pipe_transfer *cb_transfer;
unsigned i;
void *map;
@@ -248,14 +250,16 @@ nvfx_draw_elements_swtnl(struct pipe_context *pipe,
nvfx_state_emit(nvfx);
for (i = 0; i < nvfx->vtxbuf_nr; i++) {
- map = pipe_buffer_map(pscreen, nvfx->vtxbuf[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, nvfx->vtxbuf[i].buffer,
+ PIPE_TRANSFER_READ,
+ &vb_transfer[i]);
draw_set_mapped_vertex_buffer(nvfx->draw, i, map);
}
if (idxbuf) {
- map = pipe_buffer_map(pscreen, idxbuf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, idxbuf,
+ PIPE_TRANSFER_READ,
+ &ib_transfer);
draw_set_mapped_element_buffer(nvfx->draw, idxbuf_size, map);
} else {
draw_set_mapped_element_buffer(nvfx->draw, 0, NULL);
@@ -264,9 +268,10 @@ nvfx_draw_elements_swtnl(struct pipe_context *pipe,
if (nvfx->constbuf[PIPE_SHADER_VERTEX]) {
const unsigned nr = nvfx->constbuf_nr[PIPE_SHADER_VERTEX];
- map = pipe_buffer_map(pscreen,
+ map = pipe_buffer_map(pipe,
nvfx->constbuf[PIPE_SHADER_VERTEX],
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &cb_transfer);
draw_set_mapped_constant_buffer(nvfx->draw, PIPE_SHADER_VERTEX, 0,
map, nr);
}
@@ -274,13 +279,14 @@ nvfx_draw_elements_swtnl(struct pipe_context *pipe,
draw_arrays(nvfx->draw, mode, start, count);
for (i = 0; i < nvfx->vtxbuf_nr; i++)
- pipe_buffer_unmap(pscreen, nvfx->vtxbuf[i].buffer);
+ pipe_buffer_unmap(pipe, nvfx->vtxbuf[i].buffer, vb_transfer[i]);
if (idxbuf)
- pipe_buffer_unmap(pscreen, idxbuf);
+ pipe_buffer_unmap(pipe, idxbuf, ib_transfer);
if (nvfx->constbuf[PIPE_SHADER_VERTEX])
- pipe_buffer_unmap(pscreen, nvfx->constbuf[PIPE_SHADER_VERTEX]);
+ pipe_buffer_unmap(pipe, nvfx->constbuf[PIPE_SHADER_VERTEX],
+ cb_transfer);
draw_flush(nvfx->draw);
pipe->flush(pipe, 0, NULL);
diff --git a/src/gallium/drivers/nvfx/nvfx_fragprog.c b/src/gallium/drivers/nvfx/nvfx_fragprog.c
index b9c91cec8c..c600f28444 100644
--- a/src/gallium/drivers/nvfx/nvfx_fragprog.c
+++ b/src/gallium/drivers/nvfx/nvfx_fragprog.c
@@ -9,6 +9,7 @@
#include "nvfx_context.h"
#include "nvfx_shader.h"
+#include "nvfx_resource.h"
#define MAX_CONSTS 128
#define MAX_IMM 32
@@ -826,12 +827,8 @@ static void
nvfx_fragprog_upload(struct nvfx_context *nvfx,
struct nvfx_fragment_program *fp)
{
- struct pipe_screen *pscreen = nvfx->pipe.screen;
+ struct pipe_context *pipe = &nvfx->pipe;
const uint32_t le = 1;
- uint32_t *map;
- int i;
-
- map = pipe_buffer_map(pscreen, fp->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
#if 0
for (i = 0; i < fp->insn_len; i++) {
@@ -842,25 +839,37 @@ nvfx_fragprog_upload(struct nvfx_context *nvfx,
#endif
if ((*(const uint8_t *)&le)) {
- for (i = 0; i < fp->insn_len; i++) {
- map[i] = fp->insn[i];
- }
+ /* Can do this with an inline transfer */
+ pipe_buffer_write(pipe,
+ fp->buffer,
+ 0,
+ fp->insn_len * sizeof fp->insn[0],
+ fp->insn);
} else {
+ struct pipe_transfer *transfer;
+ uint32_t *map;
+ int i;
+
+ map = pipe_buffer_map(pipe, fp->buffer,
+ PIPE_TRANSFER_WRITE,
+ &transfer);
+
/* Weird swapping for big-endian chips */
for (i = 0; i < fp->insn_len; i++) {
map[i] = ((fp->insn[i] & 0xffff) << 16) |
((fp->insn[i] >> 16) & 0xffff);
}
- }
- pipe_buffer_unmap(pscreen, fp->buffer);
+ pipe_buffer_unmap(pipe, fp->buffer, transfer);
+ }
}
static boolean
nvfx_fragprog_validate(struct nvfx_context *nvfx)
{
+ struct pipe_context *pipe = &nvfx->pipe;
struct nvfx_fragment_program *fp = nvfx->fragprog;
- struct pipe_buffer *constbuf =
+ struct pipe_resource *constbuf =
nvfx->constbuf[PIPE_SHADER_FRAGMENT];
struct pipe_screen *pscreen = nvfx->pipe.screen;
struct nouveau_stateobj *so;
@@ -877,12 +886,16 @@ nvfx_fragprog_validate(struct nvfx_context *nvfx)
return FALSE;
}
- fp->buffer = pscreen->buffer_create(pscreen, 0x100, 0, fp->insn_len * 4);
+ fp->buffer = pipe_buffer_create(pscreen,
+ /* XXX: no alignment, maybe use a priv bind flag
+ * 0x100,
+ */
+ 0, fp->insn_len * 4);
nvfx_fragprog_upload(nvfx, fp);
so = so_new(4, 4, 1);
so_method(so, nvfx->screen->eng3d, NV34TCL_FP_ACTIVE_PROGRAM, 1);
- so_reloc (so, nouveau_bo(fp->buffer), 0, NOUVEAU_BO_VRAM |
+ so_reloc (so, nvfx_resource(fp->buffer)->bo, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_GART | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
NOUVEAU_BO_OR, NV34TCL_FP_ACTIVE_PROGRAM_DMA0,
NV34TCL_FP_ACTIVE_PROGRAM_DMA1);
@@ -900,10 +913,18 @@ nvfx_fragprog_validate(struct nvfx_context *nvfx)
update_constants:
if (fp->nr_consts) {
+ struct pipe_transfer *transfer;
float *map;
- map = pipe_buffer_map(pscreen, constbuf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, constbuf,
+ PIPE_TRANSFER_READ,
+ &transfer);
+
+ /* XXX: probably a bad idea to be reading back data
+ * from a buffer the gpu has been using. Not really
+ * sure what this code is doing though, or how to
+ * avoid it - kw.
+ */
for (i = 0; i < fp->nr_consts; i++) {
struct nvfx_fragment_program_data *fpd = &fp->consts[i];
uint32_t *p = &fp->insn[fpd->offset];
@@ -914,7 +935,7 @@ update_constants:
memcpy(p, cb, 4 * sizeof(float));
new_consts = TRUE;
}
- pipe_buffer_unmap(pscreen, constbuf);
+ pipe_buffer_unmap(pipe, constbuf, transfer);
if (new_consts)
nvfx_fragprog_upload(nvfx, fp);
@@ -933,7 +954,7 @@ nvfx_fragprog_destroy(struct nvfx_context *nvfx,
struct nvfx_fragment_program *fp)
{
if (fp->buffer)
- pipe_buffer_reference(&fp->buffer, NULL);
+ pipe_resource_reference(&fp->buffer, NULL);
if (fp->so)
so_ref(NULL, &fp->so);
diff --git a/src/gallium/drivers/nvfx/nvfx_miptree.c b/src/gallium/drivers/nvfx/nvfx_miptree.c
index 9de25175e7..a5965ca4a3 100644
--- a/src/gallium/drivers/nvfx/nvfx_miptree.c
+++ b/src/gallium/drivers/nvfx/nvfx_miptree.c
@@ -5,22 +5,30 @@
#include "util/u_math.h"
#include "nvfx_context.h"
+#include "nvfx_resource.h"
+#include "nvfx_transfer.h"
#include "nv04_surface_2d.h"
+#include "nouveau/nouveau_util.h"
+/* Currently using separate implementations for buffers and textures,
+ * even though gallium has a unified abstraction of these objects.
+ * Eventually these should be combined, and mechanisms like transfers
+ * be adapted to work for both buffer and texture uploads.
+ */
static void
nvfx_miptree_layout(struct nvfx_miptree *mt)
{
- struct pipe_texture *pt = &mt->base;
+ struct pipe_resource *pt = &mt->base.base;
uint width = pt->width0;
uint offset = 0;
int nr_faces, l, f;
- uint wide_pitch = pt->tex_usage & (PIPE_TEXTURE_USAGE_SAMPLER |
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
- PIPE_TEXTURE_USAGE_RENDER_TARGET |
- PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT);
+ uint wide_pitch = pt->bind & (PIPE_BIND_SAMPLER_VIEW |
+ PIPE_BIND_DEPTH_STENCIL |
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT);
if (pt->target == PIPE_TEXTURE_CUBE) {
nr_faces = 6;
@@ -32,7 +40,7 @@ nvfx_miptree_layout(struct nvfx_miptree *mt)
}
for (l = 0; l <= pt->last_level; l++) {
- if (wide_pitch && (pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR))
+ if (wide_pitch && (pt->flags & NVFX_RESOURCE_FLAG_LINEAR))
mt->level[l].pitch = align(util_format_get_stride(pt->format, pt->width0), 64);
else
mt->level[l].pitch = util_format_get_stride(pt->format, width);
@@ -47,7 +55,7 @@ nvfx_miptree_layout(struct nvfx_miptree *mt)
for (l = 0; l < pt->last_level; l++) {
mt->level[l].image_offset[f] = offset;
- if (!(pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR) &&
+ if (!(pt->flags & NVFX_RESOURCE_FLAG_LINEAR) &&
u_minify(pt->width0, l + 1) > 1 && u_minify(pt->height0, l + 1) > 1)
offset += align(mt->level[l].pitch * u_minify(pt->height0, l), 64);
else
@@ -61,35 +69,86 @@ nvfx_miptree_layout(struct nvfx_miptree *mt)
mt->total_size = offset;
}
-static struct pipe_texture *
-nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
+static boolean
+nvfx_miptree_get_handle(struct pipe_screen *pscreen,
+ struct pipe_resource *ptexture,
+ struct winsys_handle *whandle)
+{
+ struct nvfx_miptree* mt = (struct nvfx_miptree*)ptexture;
+
+ if (!mt || !mt->base.bo)
+ return FALSE;
+
+ return nouveau_screen_bo_get_handle(pscreen,
+ mt->base.bo,
+ mt->level[0].pitch,
+ whandle);
+}
+
+
+static void
+nvfx_miptree_destroy(struct pipe_screen *screen, struct pipe_resource *pt)
+{
+ struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
+ int l;
+
+ nouveau_screen_bo_release(screen, mt->base.bo);
+
+ for (l = 0; l <= pt->last_level; l++) {
+ if (mt->level[l].image_offset)
+ FREE(mt->level[l].image_offset);
+ }
+
+ FREE(mt);
+}
+
+
+
+
+struct u_resource_vtbl nvfx_miptree_vtbl =
+{
+ nvfx_miptree_get_handle, /* get_handle */
+ nvfx_miptree_destroy, /* resource_destroy */
+ NULL, /* is_resource_referenced */
+ nvfx_miptree_transfer_new, /* get_transfer */
+ nvfx_miptree_transfer_del, /* transfer_destroy */
+ nvfx_miptree_transfer_map, /* transfer_map */
+ u_default_transfer_flush_region, /* transfer_flush_region */
+ nvfx_miptree_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+struct pipe_resource *
+nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt)
{
struct nvfx_miptree *mt;
- unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
- NOUVEAU_BUFFER_USAGE_TEXTURE;
static int no_swizzle = -1;
if(no_swizzle < 0)
no_swizzle = debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE);
- mt = MALLOC(sizeof(struct nvfx_miptree));
+ mt = CALLOC_STRUCT(nvfx_miptree);
if (!mt)
return NULL;
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
+
+ mt->base.base = *pt;
+ mt->base.vtbl = &nvfx_miptree_vtbl;
+ pipe_reference_init(&mt->base.base.reference, 1);
+ mt->base.base.screen = pscreen;
/* Swizzled textures must be POT */
if (pt->width0 & (pt->width0 - 1) ||
pt->height0 & (pt->height0 - 1))
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
else
- if (pt->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ if (pt->bind & (PIPE_BIND_SCANOUT |
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_DEPTH_STENCIL))
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
else
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ if (pt->_usage == PIPE_USAGE_DYNAMIC)
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
else {
switch (pt->format) {
case PIPE_FORMAT_B5G6R5_UNORM:
@@ -101,7 +160,7 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
are just preserving the pre-unification behavior.
The whole 2D code is going to be rewritten anyway. */
if(nvfx_screen(pscreen)->is_nv4x) {
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
break;
}
/* TODO: Figure out which formats can be swizzled */
@@ -110,80 +169,82 @@ nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
case PIPE_FORMAT_R16_SNORM:
{
if (no_swizzle)
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
break;
}
default:
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
}
}
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
- buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
-
/* apparently we can't render to swizzled surfaces smaller than 64 bytes, so make them linear.
* If the user did not ask for a render target, they can still render to it, but it will cost them an extra copy.
* This also happens for small mipmaps of large textures. */
- if (pt->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET && util_format_get_stride(pt->format, pt->width0) < 64)
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ if (pt->bind & PIPE_BIND_RENDER_TARGET &&
+ util_format_get_stride(pt->format, pt->width0) < 64)
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
nvfx_miptree_layout(mt);
- mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage, mt->total_size);
- if (!mt->buffer) {
+ mt->base.bo = nouveau_screen_bo_new(pscreen, 256,
+ pt->_usage, pt->bind, mt->total_size);
+ if (!mt->base.bo) {
FREE(mt);
return NULL;
}
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
+ return &mt->base.base;
}
-static struct pipe_texture *
-nvfx_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
- const unsigned *stride, struct pipe_buffer *pb)
+
+
+
+struct pipe_resource *
+nvfx_miptree_from_handle(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
{
struct nvfx_miptree *mt;
+ unsigned stride;
/* Only supports 2D, non-mipmapped textures for the moment */
- if (pt->target != PIPE_TEXTURE_2D || pt->last_level != 0 ||
- pt->depth0 != 1)
+ if (template->target != PIPE_TEXTURE_2D ||
+ template->last_level != 0 ||
+ template->depth0 != 1)
return NULL;
mt = CALLOC_STRUCT(nvfx_miptree);
if (!mt)
return NULL;
- mt->base = *pt;
- pipe_reference_init(&mt->base.reference, 1);
- mt->base.screen = pscreen;
- mt->level[0].pitch = stride[0];
+ mt->base.bo = nouveau_screen_bo_from_handle(pscreen, whandle, &stride);
+ if (mt->base.bo == NULL) {
+ FREE(mt);
+ return NULL;
+ }
+
+ mt->base.base = *template;
+ pipe_reference_init(&mt->base.base.reference, 1);
+ mt->base.base.screen = pscreen;
+ mt->level[0].pitch = stride;
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
/* Assume whoever created this buffer expects it to be linear for now */
- mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+ mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
- pipe_buffer_reference(&mt->buffer, pb);
- mt->bo = nouveau_bo(mt->buffer);
- return &mt->base;
+ /* XXX: Need to adjust bo refcount??
+ */
+ /* nouveau_bo_ref(bo, &mt->base.bo); */
+ return &mt->base.base;
}
-static void
-nvfx_miptree_destroy(struct pipe_texture *pt)
-{
- struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
- int l;
- pipe_buffer_reference(&mt->buffer, NULL);
- for (l = 0; l <= pt->last_level; l++) {
- if (mt->level[l].image_offset)
- FREE(mt->level[l].image_offset);
- }
- FREE(mt);
-}
-static struct pipe_surface *
-nvfx_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
+
+/* Surface helpers, not strictly required to implement the resource vtbl:
+ */
+struct pipe_surface *
+nvfx_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
unsigned face, unsigned level, unsigned zslice,
unsigned flags)
{
@@ -193,7 +254,7 @@ nvfx_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ns = CALLOC_STRUCT(nv04_surface);
if (!ns)
return NULL;
- pipe_texture_reference(&ns->base.texture, pt);
+ pipe_resource_reference(&ns->base.texture, pt);
ns->base.format = pt->format;
ns->base.width = u_minify(pt->width0, level);
ns->base.height = u_minify(pt->height0, level);
@@ -213,38 +274,38 @@ nvfx_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ns->base.offset = mt->level[level].image_offset[0];
}
- /* create a linear temporary that we can render into if necessary.
- * Note that ns->pitch is always a multiple of 64 for linear surfaces and swizzled surfaces are POT, so
- * ns->pitch & 63 is equivalent to (ns->pitch < 64 && swizzled)*/
- if((ns->pitch & 63) && (ns->base.usage & (PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER)) == PIPE_BUFFER_USAGE_GPU_WRITE)
- return &nv04_surface_wrap_for_render(pscreen, ((struct nvfx_screen*)pscreen)->eng2d, ns)->base;
+ /* create a linear temporary that we can render into if
+ * necessary.
+ *
+ * Note that ns->pitch is always a multiple of 64 for linear
+ * surfaces and swizzled surfaces are POT, so ns->pitch & 63
+ * is equivalent to (ns->pitch < 64 && swizzled)
+ */
+
+ if ((ns->pitch & 63) &&
+ (ns->base.usage & PIPE_BIND_RENDER_TARGET))
+ {
+ struct nv04_surface_2d* eng2d =
+ ((struct nvfx_screen*)pscreen)->eng2d;
+
+ ns = nv04_surface_wrap_for_render(pscreen, eng2d, ns);
+ }
return &ns->base;
}
-static void
+void
nvfx_miptree_surface_del(struct pipe_surface *ps)
{
struct nv04_surface* ns = (struct nv04_surface*)ps;
if(ns->backing)
{
struct nvfx_screen* screen = (struct nvfx_screen*)ps->texture->screen;
- if(ns->backing->base.usage & PIPE_BUFFER_USAGE_GPU_WRITE)
+ if(ns->backing->base.usage & PIPE_BIND_RENDER_TARGET)
screen->eng2d->copy(screen->eng2d, &ns->backing->base, 0, 0, ps, 0, 0, ns->base.width, ns->base.height);
nvfx_miptree_surface_del(&ns->backing->base);
}
- pipe_texture_reference(&ps->texture, NULL);
+ pipe_resource_reference(&ps->texture, NULL);
FREE(ps);
}
-
-void
-nvfx_screen_init_miptree_functions(struct pipe_screen *pscreen)
-{
- pscreen->texture_create = nvfx_miptree_create;
- pscreen->texture_destroy = nvfx_miptree_destroy;
- pscreen->get_tex_surface = nvfx_miptree_surface_new;
- pscreen->tex_surface_destroy = nvfx_miptree_surface_del;
-
- nouveau_screen(pscreen)->texture_blanket = nvfx_miptree_blanket;
-}
diff --git a/src/gallium/drivers/nvfx/nvfx_resource.c b/src/gallium/drivers/nvfx/nvfx_resource.c
new file mode 100644
index 0000000000..10cdeed2a3
--- /dev/null
+++ b/src/gallium/drivers/nvfx/nvfx_resource.c
@@ -0,0 +1,67 @@
+
+#include "pipe/p_context.h"
+#include "nvfx_resource.h"
+#include "nouveau/nouveau_screen.h"
+
+
+/* This doesn't look quite right - this query is supposed to ask
+ * whether the particular context has references to the resource in
+ * any unflushed rendering command buffer, and hence requires a
+ * pipe->flush() for serializing some modification to that resource.
+ *
+ * This seems to be answering the question of whether the resource is
+ * currently on hardware.
+ */
+static unsigned int
+nvfx_resource_is_referenced(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ unsigned face, unsigned level)
+{
+ return nouveau_reference_flags(nvfx_resource(resource)->bo);
+}
+
+static struct pipe_resource *
+nvfx_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ if (template->target == PIPE_BUFFER)
+ return nvfx_buffer_create(screen, template);
+ else
+ return nvfx_miptree_create(screen, template);
+}
+
+static struct pipe_resource *
+nvfx_resource_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
+{
+ if (template->target == PIPE_BUFFER)
+ return NULL;
+ else
+ return nvfx_miptree_from_handle(screen, template, whandle);
+}
+
+void
+nvfx_init_resource_functions(struct pipe_context *pipe)
+{
+ pipe->get_transfer = u_get_transfer_vtbl;
+ pipe->transfer_map = u_transfer_map_vtbl;
+ pipe->transfer_flush_region = u_transfer_flush_region_vtbl;
+ pipe->transfer_unmap = u_transfer_unmap_vtbl;
+ pipe->transfer_destroy = u_transfer_destroy_vtbl;
+ pipe->transfer_inline_write = u_transfer_inline_write_vtbl;
+ pipe->is_resource_referenced = nvfx_resource_is_referenced;
+}
+
+void
+nvfx_screen_init_resource_functions(struct pipe_screen *pscreen)
+{
+ pscreen->resource_create = nvfx_resource_create;
+ pscreen->resource_from_handle = nvfx_resource_from_handle;
+ pscreen->resource_get_handle = u_resource_get_handle_vtbl;
+ pscreen->resource_destroy = u_resource_destroy_vtbl;
+ pscreen->user_buffer_create = nvfx_user_buffer_create;
+
+ pscreen->get_tex_surface = nvfx_miptree_surface_new;
+ pscreen->tex_surface_destroy = nvfx_miptree_surface_del;
+}
diff --git a/src/gallium/drivers/nvfx/nvfx_resource.h b/src/gallium/drivers/nvfx/nvfx_resource.h
new file mode 100644
index 0000000000..a68c14cf3f
--- /dev/null
+++ b/src/gallium/drivers/nvfx/nvfx_resource.h
@@ -0,0 +1,91 @@
+
+#ifndef NVFX_RESOURCE_H
+#define NVFX_RESOURCE_H
+
+#include "util/u_transfer.h"
+
+struct pipe_resource;
+struct nouveau_bo;
+
+
+/* This gets further specialized into either buffer or texture
+ * structures. In the future we'll want to remove much of that
+ * distinction, but for now try to keep as close to the existing code
+ * as possible and use the vtbl struct to choose between the two
+ * underlying implementations.
+ */
+struct nvfx_resource {
+ struct pipe_resource base;
+ struct u_resource_vtbl *vtbl;
+ struct nouveau_bo *bo;
+};
+
+#define NVFX_MAX_TEXTURE_LEVELS 16
+
+struct nvfx_miptree {
+ struct nvfx_resource base;
+ uint total_size;
+
+ struct {
+ uint pitch;
+ uint *image_offset;
+ } level[NVFX_MAX_TEXTURE_LEVELS];
+
+ unsigned image_nr;
+};
+
+static INLINE
+struct nvfx_resource *nvfx_resource(struct pipe_resource *resource)
+{
+ return (struct nvfx_resource *)resource;
+}
+
+static INLINE struct nouveau_bo *
+nvfx_surface_buffer(struct pipe_surface *surf)
+{
+ struct nvfx_resource *mt = nvfx_resource(surf->texture);
+
+ return mt->bo;
+}
+
+
+void
+nvfx_init_resource_functions(struct pipe_context *pipe);
+
+void
+nvfx_screen_init_resource_functions(struct pipe_screen *pscreen);
+
+
+/* Internal:
+ */
+
+struct pipe_resource *
+nvfx_miptree_create(struct pipe_screen *pscreen, const struct pipe_resource *pt);
+
+struct pipe_resource *
+nvfx_miptree_from_handle(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle);
+
+struct pipe_resource *
+nvfx_buffer_create(struct pipe_screen *pscreen,
+ const struct pipe_resource *template);
+
+struct pipe_resource *
+nvfx_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage);
+
+
+
+void
+nvfx_miptree_surface_del(struct pipe_surface *ps);
+
+struct pipe_surface *
+nvfx_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_resource *pt,
+ unsigned face, unsigned level, unsigned zslice,
+ unsigned flags);
+
+
+#endif
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c
index 1a103520a3..1f6e6e3497 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.c
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c
@@ -1,10 +1,12 @@
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
+#include "util/u_simple_screen.h"
#include "nouveau/nouveau_screen.h"
#include "nvfx_context.h"
#include "nvfx_screen.h"
+#include "nvfx_resource.h"
#define NV30TCL_CHIPSET_3X_MASK 0x00000003
#define NV34TCL_CHIPSET_3X_MASK 0x00000010
@@ -122,7 +124,7 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
struct nvfx_screen *screen = nvfx_screen(pscreen);
struct pipe_surface *front = ((struct nouveau_winsys *) pscreen->winsys)->front;
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
+ if (tex_usage & PIPE_BIND_RENDER_TARGET) {
switch (format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_B5G6R5_UNORM:
@@ -131,7 +133,7 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
break;
}
} else
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) {
+ if (tex_usage & PIPE_BIND_DEPTH_STENCIL) {
switch (format) {
case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
@@ -172,13 +174,6 @@ nvfx_screen_surface_format_supported(struct pipe_screen *pscreen,
return FALSE;
}
-static struct pipe_buffer *
-nvfx_surface_buffer(struct pipe_surface *surf)
-{
- struct nvfx_miptree *mt = (struct nvfx_miptree *)surf->texture;
-
- return mt->buffer;
-}
static void
nvfx_screen_destroy(struct pipe_screen *pscreen)
@@ -380,8 +375,8 @@ nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
return NULL;
}
+ nvfx_screen_init_resource_functions(pscreen);
nvfx_screen_init_buffer_functions(screen);
- nvfx_screen_init_miptree_functions(pscreen);
ret = nouveau_grobj_alloc(chan, 0xbeef3097, eng3d_class, &screen->eng3d);
if (ret) {
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.h b/src/gallium/drivers/nvfx/nvfx_screen.h
index baa848c47a..3302e1aa58 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.h
+++ b/src/gallium/drivers/nvfx/nvfx_screen.h
@@ -3,6 +3,7 @@
#include "nouveau/nouveau_screen.h"
#include "nv04_surface_2d.h"
+#include "nvfx_context.h"
struct nvfx_screen {
struct nouveau_screen base;
diff --git a/src/gallium/drivers/nvfx/nvfx_state.c b/src/gallium/drivers/nvfx/nvfx_state.c
index ecaa0dcb16..e11ab46c42 100644
--- a/src/gallium/drivers/nvfx/nvfx_state.c
+++ b/src/gallium/drivers/nvfx/nvfx_state.c
@@ -163,7 +163,7 @@ nvfx_set_fragment_sampler_views(struct pipe_context *pipe,
static struct pipe_sampler_view *
nvfx_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -172,7 +172,7 @@ nvfx_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}
@@ -184,7 +184,7 @@ static void
nvfx_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
@@ -499,12 +499,12 @@ nvfx_set_clip_state(struct pipe_context *pipe,
static void
nvfx_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
- struct pipe_buffer *buf )
+ struct pipe_resource *buf )
{
struct nvfx_context *nvfx = nvfx_context(pipe);
nvfx->constbuf[shader] = buf;
- nvfx->constbuf_nr[shader] = buf->size / (4 * sizeof(float));
+ nvfx->constbuf_nr[shader] = buf->width0 / (4 * sizeof(float));
if (shader == PIPE_SHADER_VERTEX) {
nvfx->dirty |= NVFX_NEW_VERTPROG;
diff --git a/src/gallium/drivers/nvfx/nvfx_state.h b/src/gallium/drivers/nvfx/nvfx_state.h
index e585246879..1f612ea95f 100644
--- a/src/gallium/drivers/nvfx/nvfx_state.h
+++ b/src/gallium/drivers/nvfx/nvfx_state.h
@@ -58,26 +58,14 @@ struct nvfx_fragment_program {
struct nvfx_fragment_program_data *consts;
unsigned nr_consts;
-
- struct pipe_buffer *buffer;
+
+ /* XXX: just use a nouveau_bo for this?
+ */
+ struct pipe_resource *buffer;
uint32_t fp_control;
struct nouveau_stateobj *so;
};
-#define NVFX_MAX_TEXTURE_LEVELS 16
-
-struct nvfx_miptree {
- struct pipe_texture base;
- struct nouveau_bo *bo;
-
- struct pipe_buffer *buffer;
- uint total_size;
-
- struct {
- uint pitch;
- uint *image_offset;
- } level[NVFX_MAX_TEXTURE_LEVELS];
-};
#endif
diff --git a/src/gallium/drivers/nvfx/nvfx_state_fb.c b/src/gallium/drivers/nvfx/nvfx_state_fb.c
index 1923184163..c64ba27eaa 100644
--- a/src/gallium/drivers/nvfx/nvfx_state_fb.c
+++ b/src/gallium/drivers/nvfx/nvfx_state_fb.c
@@ -1,14 +1,8 @@
#include "nvfx_context.h"
+#include "nvfx_resource.h"
#include "nouveau/nouveau_util.h"
-static struct pipe_buffer *
-nvfx_do_surface_buffer(struct pipe_surface *surface)
-{
- struct nvfx_miptree *mt = (struct nvfx_miptree *)surface->texture;
- return mt->buffer;
-}
-#define nvfx_surface_buffer(ps) nouveau_bo(nvfx_do_surface_buffer(ps))
static boolean
nvfx_state_framebuffer_validate(struct nvfx_context *nvfx)
@@ -53,10 +47,10 @@ nvfx_state_framebuffer_validate(struct nvfx_context *nvfx)
if (rt_enable & (NV34TCL_RT_ENABLE_COLOR0 | NV34TCL_RT_ENABLE_COLOR1 |
NV40TCL_RT_ENABLE_COLOR2 | NV40TCL_RT_ENABLE_COLOR3)) {
/* Render to at least a colour buffer */
- if (!(rt[0]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+ if (!(rt[0]->base.texture->flags & NVFX_RESOURCE_FLAG_LINEAR)) {
assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
for (i = 1; i < fb->nr_cbufs; i++)
- assert(!(rt[i]->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR));
+ assert(!(rt[i]->base.texture->flags & NVFX_RESOURCE_FLAG_LINEAR));
rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
(log2i(rt[0]->base.width) << NV34TCL_RT_FORMAT_LOG2_WIDTH_SHIFT) |
@@ -68,7 +62,7 @@ nvfx_state_framebuffer_validate(struct nvfx_context *nvfx)
depth_only = 1;
/* Render to depth buffer only */
- if (!(zeta->base.texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)) {
+ if (!(zeta->base.texture->flags & NVFX_RESOURCE_FLAG_LINEAR)) {
assert(!(fb->width & (fb->width - 1)) && !(fb->height & (fb->height - 1)));
rt_format = NV34TCL_RT_FORMAT_TYPE_SWIZZLED |
diff --git a/src/gallium/drivers/nvfx/nvfx_transfer.c b/src/gallium/drivers/nvfx/nvfx_transfer.c
index 1c250e9fe4..59ab14826c 100644
--- a/src/gallium/drivers/nvfx/nvfx_transfer.c
+++ b/src/gallium/drivers/nvfx/nvfx_transfer.c
@@ -8,6 +8,8 @@
#include "nvfx_context.h"
#include "nvfx_screen.h"
#include "nvfx_state.h"
+#include "nvfx_resource.h"
+#include "nvfx_transfer.h"
struct nvfx_transfer {
struct pipe_transfer base;
@@ -16,10 +18,11 @@ struct nvfx_transfer {
};
static void
-nvfx_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned height,
- struct pipe_texture *template)
+nvfx_compatible_transfer_tex(struct pipe_resource *pt, unsigned width, unsigned height,
+ unsigned bind,
+ struct pipe_resource *template)
{
- memset(template, 0, sizeof(struct pipe_texture));
+ memset(template, 0, sizeof(struct pipe_resource));
template->target = pt->target;
template->format = pt->format;
template->width0 = width;
@@ -27,56 +30,77 @@ nvfx_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned h
template->depth0 = 1;
template->last_level = 0;
template->nr_samples = pt->nr_samples;
+ template->bind = bind;
+ template->_usage = PIPE_USAGE_DYNAMIC;
+ template->flags = NVFX_RESOURCE_FLAG_LINEAR;
+}
+
+
+static unsigned nvfx_transfer_bind_flags( unsigned transfer_usage )
+{
+ unsigned bind = 0;
+
+ if (transfer_usage & PIPE_TRANSFER_WRITE)
+ bind |= PIPE_BIND_BLIT_DESTINATION;
- template->tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
- NOUVEAU_TEXTURE_USAGE_LINEAR;
+ if (transfer_usage & PIPE_TRANSFER_READ)
+ bind |= PIPE_BIND_BLIT_SOURCE;
+
+ return bind;
}
-static struct pipe_transfer *
-nvfx_transfer_new(struct pipe_context *pipe, struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
+struct pipe_transfer *
+nvfx_miptree_transfer_new(struct pipe_context *pipe,
+ struct pipe_resource *pt,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
struct pipe_screen *pscreen = pipe->screen;
struct nvfx_miptree *mt = (struct nvfx_miptree *)pt;
struct nvfx_transfer *tx;
- struct pipe_texture tx_tex_template, *tx_tex;
+ struct pipe_resource tx_tex_template, *tx_tex;
static int no_transfer = -1;
+ unsigned bind = nvfx_transfer_bind_flags(usage);
if(no_transfer < 0)
no_transfer = debug_get_bool_option("NOUVEAU_NO_TRANSFER", TRUE/*XXX:FALSE*/);
+
tx = CALLOC_STRUCT(nvfx_transfer);
if (!tx)
return NULL;
- pipe_texture_reference(&tx->base.texture, pt);
- tx->base.x = x;
- tx->base.y = y;
- tx->base.width = w;
- tx->base.height = h;
- tx->base.stride = mt->level[level].pitch;
+ /* Don't handle 3D transfers yet.
+ */
+ assert(box->depth == 1);
+
+ pipe_resource_reference(&tx->base.resource, pt);
+ tx->base.sr = sr;
tx->base.usage = usage;
- tx->base.face = face;
- tx->base.level = level;
- tx->base.zslice = zslice;
+ tx->base.box = *box;
+ tx->base.stride = mt->level[sr.level].pitch;
/* Direct access to texture */
- if ((pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC || no_transfer) &&
- pt->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR)
+ if ((pt->_usage == PIPE_USAGE_DYNAMIC ||
+ no_transfer) &&
+ pt->flags & NVFX_RESOURCE_FLAG_LINEAR)
{
tx->direct = true;
+
+ /* XXX: just call the internal nvfx function.
+ */
tx->surface = pscreen->get_tex_surface(pscreen, pt,
- face, level, zslice,
- pipe_transfer_buffer_flags(&tx->base));
+ sr.face, sr.level,
+ box->z,
+ bind);
return &tx->base;
}
tx->direct = false;
- nvfx_compatible_transfer_tex(pt, w, h, &tx_tex_template);
+ nvfx_compatible_transfer_tex(pt, box->width, box->height, bind, &tx_tex_template);
- tx_tex = pscreen->texture_create(pscreen, &tx_tex_template);
+ tx_tex = pscreen->resource_create(pscreen, &tx_tex_template);
if (!tx_tex)
{
FREE(tx);
@@ -87,9 +111,9 @@ nvfx_transfer_new(struct pipe_context *pipe, struct pipe_texture *pt,
tx->surface = pscreen->get_tex_surface(pscreen, tx_tex,
0, 0, 0,
- pipe_transfer_buffer_flags(&tx->base));
+ bind);
- pipe_texture_reference(&tx_tex, NULL);
+ pipe_resource_reference(&tx_tex, NULL);
if (!tx->surface)
{
@@ -103,15 +127,16 @@ nvfx_transfer_new(struct pipe_context *pipe, struct pipe_texture *pt,
struct pipe_surface *src;
src = pscreen->get_tex_surface(pscreen, pt,
- face, level, zslice,
- PIPE_BUFFER_USAGE_GPU_READ);
+ sr.face, sr.level, box->z,
+ PIPE_BIND_BLIT_SOURCE);
/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
/* TODO: Check if SIFM can un-swizzle */
nvscreen->eng2d->copy(nvscreen->eng2d,
tx->surface, 0, 0,
- src, x, y,
- w, h);
+ src,
+ box->x, box->y,
+ box->width, box->height);
pipe_surface_reference(&src, NULL);
}
@@ -119,9 +144,9 @@ nvfx_transfer_new(struct pipe_context *pipe, struct pipe_texture *pt,
return &tx->base;
}
-static void
-nvfx_transfer_del(struct pipe_context *pipe,
- struct pipe_transfer *ptx)
+void
+nvfx_miptree_transfer_del(struct pipe_context *pipe,
+ struct pipe_transfer *ptx)
{
struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
@@ -130,55 +155,51 @@ nvfx_transfer_del(struct pipe_context *pipe,
struct nvfx_screen *nvscreen = nvfx_screen(pscreen);
struct pipe_surface *dst;
- dst = pscreen->get_tex_surface(pscreen, ptx->texture,
- ptx->face, ptx->level, ptx->zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER);
+ dst = pscreen->get_tex_surface(pscreen,
+ ptx->resource,
+ ptx->sr.face,
+ ptx->sr.level,
+ ptx->box.z,
+ PIPE_BIND_BLIT_DESTINATION);
/* TODO: Check if SIFM can deal with x,y,w,h when swizzling */
nvscreen->eng2d->copy(nvscreen->eng2d,
- dst, tx->base.x, tx->base.y,
+ dst, ptx->box.x, ptx->box.y,
tx->surface, 0, 0,
- tx->base.width, tx->base.height);
+ ptx->box.width, ptx->box.height);
pipe_surface_reference(&dst, NULL);
}
pipe_surface_reference(&tx->surface, NULL);
- pipe_texture_reference(&ptx->texture, NULL);
+ pipe_resource_reference(&ptx->resource, NULL);
FREE(ptx);
}
-static void *
-nvfx_transfer_map(struct pipe_context *pipe, struct pipe_transfer *ptx)
+void *
+nvfx_miptree_transfer_map(struct pipe_context *pipe, struct pipe_transfer *ptx)
{
struct pipe_screen *pscreen = pipe->screen;
struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
- void *map = pipe_buffer_map(pscreen, mt->buffer,
- pipe_transfer_buffer_flags(ptx));
+ uint8_t *map = nouveau_screen_bo_map(pscreen, mt->base.bo,
+ nouveau_screen_transfer_flags(ptx->usage));
if(!tx->direct)
return map + ns->base.offset;
else
- return map + ns->base.offset + ptx->y * ns->pitch + ptx->x * util_format_get_blocksize(ptx->texture->format);
+ return (map + ns->base.offset +
+ ptx->box.y * ns->pitch +
+ ptx->box.x * util_format_get_blocksize(ptx->resource->format));
}
-static void
-nvfx_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *ptx)
+void
+nvfx_miptree_transfer_unmap(struct pipe_context *pipe, struct pipe_transfer *ptx)
{
struct pipe_screen *pscreen = pipe->screen;
struct nvfx_transfer *tx = (struct nvfx_transfer *)ptx;
struct nvfx_miptree *mt = (struct nvfx_miptree *)tx->surface->texture;
- pipe_buffer_unmap(pscreen, mt->buffer);
-}
-
-void
-nvfx_init_transfer_functions(struct nvfx_context *nvfx)
-{
- nvfx->pipe.get_tex_transfer = nvfx_transfer_new;
- nvfx->pipe.tex_transfer_destroy = nvfx_transfer_del;
- nvfx->pipe.transfer_map = nvfx_transfer_map;
- nvfx->pipe.transfer_unmap = nvfx_transfer_unmap;
+ nouveau_screen_bo_unmap(pscreen, mt->base.bo);
}
diff --git a/src/gallium/drivers/nvfx/nvfx_transfer.h b/src/gallium/drivers/nvfx/nvfx_transfer.h
new file mode 100644
index 0000000000..3e3317b2c7
--- /dev/null
+++ b/src/gallium/drivers/nvfx/nvfx_transfer.h
@@ -0,0 +1,26 @@
+
+#ifndef NVFX_TRANSFER_H
+#define NVFX_TRANSFER_H
+
+#include "util/u_transfer.h"
+#include "pipe/p_state.h"
+
+
+struct pipe_transfer *
+nvfx_miptree_transfer_new(struct pipe_context *pcontext,
+ struct pipe_resource *pt,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box);
+void
+nvfx_miptree_transfer_del(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx);
+void *
+nvfx_miptree_transfer_map(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx);
+void
+nvfx_miptree_transfer_unmap(struct pipe_context *pcontext,
+ struct pipe_transfer *ptx);
+
+
+#endif
diff --git a/src/gallium/drivers/nvfx/nvfx_vbo.c b/src/gallium/drivers/nvfx/nvfx_vbo.c
index c26536b0e7..b9566f9ee2 100644
--- a/src/gallium/drivers/nvfx/nvfx_vbo.c
+++ b/src/gallium/drivers/nvfx/nvfx_vbo.c
@@ -5,6 +5,7 @@
#include "nvfx_context.h"
#include "nvfx_state.h"
+#include "nvfx_resource.h"
#include "nouveau/nouveau_channel.h"
#include "nouveau/nouveau_pushbuf.h"
@@ -76,7 +77,7 @@ nvfx_vbo_format_to_hw(enum pipe_format pipe, unsigned *fmt, unsigned *ncomp)
}
static boolean
-nvfx_vbo_set_idxbuf(struct nvfx_context *nvfx, struct pipe_buffer *ib,
+nvfx_vbo_set_idxbuf(struct nvfx_context *nvfx, struct pipe_resource *ib,
unsigned ib_size)
{
struct pipe_screen *pscreen = &nvfx->screen->base.base;
@@ -117,21 +118,22 @@ nvfx_vbo_static_attrib(struct nvfx_context *nvfx, struct nouveau_stateobj *so,
int attrib, struct pipe_vertex_element *ve,
struct pipe_vertex_buffer *vb)
{
- struct pipe_screen *pscreen = nvfx->pipe.screen;
+ struct pipe_context *pipe = &nvfx->pipe;
struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
+ struct pipe_transfer *transfer;
unsigned type, ncomp;
- void *map;
+ uint8_t *map;
if (nvfx_vbo_format_to_hw(ve->src_format, &type, &ncomp))
return FALSE;
- map = pipe_buffer_map(pscreen, vb->buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, vb->buffer, PIPE_TRANSFER_READ, &transfer);
map += vb->buffer_offset + ve->src_offset;
switch (type) {
case NV34TCL_VTXFMT_TYPE_FLOAT:
{
- float *v = map;
+ float *v = (float *)map;
switch (ncomp) {
case 4:
@@ -157,17 +159,17 @@ nvfx_vbo_static_attrib(struct nvfx_context *nvfx, struct nouveau_stateobj *so,
so_data (so, fui(v[0]));
break;
default:
- pipe_buffer_unmap(pscreen, vb->buffer);
+ pipe_buffer_unmap(pipe, vb->buffer, transfer);
return FALSE;
}
}
break;
default:
- pipe_buffer_unmap(pscreen, vb->buffer);
+ pipe_buffer_unmap(pipe, vb->buffer, transfer);
return FALSE;
}
- pipe_buffer_unmap(pscreen, vb->buffer);
+ pipe_buffer_unmap(pipe, vb->buffer, transfer);
return TRUE;
}
@@ -379,14 +381,14 @@ nvfx_draw_elements_u32(struct nvfx_context *nvfx, void *ib,
static void
nvfx_draw_elements_inline(struct pipe_context *pipe,
- struct pipe_buffer *ib, unsigned ib_size,
+ struct pipe_resource *ib, unsigned ib_size,
unsigned mode, unsigned start, unsigned count)
{
struct nvfx_context *nvfx = nvfx_context(pipe);
- struct pipe_screen *pscreen = pipe->screen;
+ struct pipe_transfer *transfer;
void *map;
- map = pipe_buffer_map(pscreen, ib, PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, ib, PIPE_TRANSFER_READ, &transfer);
if (!ib) {
NOUVEAU_ERR("failed mapping ib\n");
return;
@@ -407,7 +409,7 @@ nvfx_draw_elements_inline(struct pipe_context *pipe,
break;
}
- pipe_buffer_unmap(pscreen, ib);
+ pipe_buffer_unmap(pipe, ib, transfer);
}
static void
@@ -465,7 +467,7 @@ nvfx_draw_elements_vbo(struct pipe_context *pipe,
void
nvfx_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer, unsigned indexSize,
+ struct pipe_resource *indexBuffer, unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
struct nvfx_context *nvfx = nvfx_context(pipe);
@@ -493,7 +495,7 @@ nvfx_vbo_validate(struct nvfx_context *nvfx)
{
struct nouveau_stateobj *vtxbuf, *vtxfmt, *sattr = NULL;
struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
- struct pipe_buffer *ib = nvfx->idxbuf;
+ struct pipe_resource *ib = nvfx->idxbuf;
unsigned ib_format = nvfx->idxbuf_format;
unsigned vb_flags = nvfx->screen->vertex_buffer_flags | NOUVEAU_BO_RD;
int hw;
@@ -529,7 +531,7 @@ nvfx_vbo_validate(struct nvfx_context *nvfx)
return FALSE;
}
- so_reloc(vtxbuf, nouveau_bo(vb->buffer),
+ so_reloc(vtxbuf, nvfx_resource(vb->buffer)->bo,
vb->buffer_offset + ve->src_offset,
vb_flags | NOUVEAU_BO_LOW | NOUVEAU_BO_OR,
0, NV34TCL_VTXBUF_ADDRESS_DMA1);
@@ -538,7 +540,7 @@ nvfx_vbo_validate(struct nvfx_context *nvfx)
}
if (ib) {
- struct nouveau_bo *bo = nouveau_bo(ib);
+ struct nouveau_bo *bo = nvfx_resource(ib)->bo;
so_method(vtxbuf, eng3d, NV34TCL_IDXBUF_ADDRESS, 2);
so_reloc (vtxbuf, bo, 0, vb_flags | NOUVEAU_BO_LOW, 0, 0);
diff --git a/src/gallium/drivers/nvfx/nvfx_vertprog.c b/src/gallium/drivers/nvfx/nvfx_vertprog.c
index 2d243be16a..3547cad6ae 100644
--- a/src/gallium/drivers/nvfx/nvfx_vertprog.c
+++ b/src/gallium/drivers/nvfx/nvfx_vertprog.c
@@ -833,12 +833,13 @@ out_err:
static boolean
nvfx_vertprog_validate(struct nvfx_context *nvfx)
{
- struct pipe_screen *pscreen = nvfx->pipe.screen;
+ struct pipe_context *pipe = &nvfx->pipe;
struct nvfx_screen *screen = nvfx->screen;
struct nouveau_channel *chan = screen->base.channel;
struct nouveau_grobj *eng3d = screen->eng3d;
struct nvfx_vertex_program *vp;
- struct pipe_buffer *constbuf;
+ struct pipe_resource *constbuf;
+ struct pipe_transfer *transfer;
boolean upload_code = FALSE, upload_data = FALSE;
int i;
@@ -962,8 +963,9 @@ check_gpu_resources:
float *map = NULL;
if (constbuf) {
- map = pipe_buffer_map(pscreen, constbuf,
- PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, constbuf,
+ PIPE_TRANSFER_READ,
+ &transfer);
}
for (i = 0; i < vp->nr_consts; i++) {
@@ -984,7 +986,7 @@ check_gpu_resources:
}
if (constbuf)
- pipe_buffer_unmap(pscreen, constbuf);
+ pipe_buffer_unmap(pipe, constbuf, transfer);
}
/* Upload vtxprog */
diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
index a6529b2060..5a8e00f15a 100644
--- a/src/gallium/drivers/r300/Makefile
+++ b/src/gallium/drivers/r300/Makefile
@@ -13,6 +13,7 @@ C_SOURCES = \
r300_fs.c \
r300_query.c \
r300_render.c \
+ r300_resource.c \
r300_screen.c \
r300_screen_buffer.c \
r300_state.c \
diff --git a/src/gallium/drivers/r300/r300_blit.c b/src/gallium/drivers/r300/r300_blit.c
index bcdf950df9..b99879afdd 100644
--- a/src/gallium/drivers/r300/r300_blit.c
+++ b/src/gallium/drivers/r300/r300_blit.c
@@ -137,8 +137,8 @@ void r300_surface_copy(struct pipe_context* pipe,
if (!pipe->screen->is_format_supported(pipe->screen,
old_format, src->texture->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET |
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
switch (util_format_get_blocksize(old_format)) {
case 1:
new_format = PIPE_FORMAT_I8_UNORM;
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 55850e09c3..490f77341f 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -47,7 +47,7 @@ static void r300_destroy_context(struct pipe_context* context)
draw_destroy(r300->draw);
/* Free the OQ BO. */
- context->screen->buffer_destroy(r300->oqbo);
+ context->screen->resource_destroy(context->screen, r300->oqbo);
/* If there are any queries pending or not destroyed, remove them now. */
foreach_s(query, temp, &r300->query_list) {
@@ -70,25 +70,6 @@ static void r300_destroy_context(struct pipe_context* context)
FREE(r300);
}
-static unsigned int
-r300_is_texture_referenced(struct pipe_context *context,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- struct r300_context* r300 = r300_context(context);
- struct r300_texture* tex = r300_texture(texture);
-
- return r300->rws->is_buffer_referenced(r300->rws, tex->buffer);
-}
-
-static unsigned int
-r300_is_buffer_referenced(struct pipe_context *context,
- struct pipe_buffer *buf)
-{
- struct r300_context* r300 = r300_context(context);
-
- return r300_buffer_is_referenced(r300, buf);
-}
static void r300_flush_cb(void *data)
{
@@ -201,23 +182,17 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
draw_set_viewport_state(r300->draw, &r300_viewport_identity);
}
- r300->context.is_texture_referenced = r300_is_texture_referenced;
- r300->context.is_buffer_referenced = r300_is_buffer_referenced;
-
r300_setup_atoms(r300);
/* Open up the OQ BO. */
- r300->oqbo = screen->buffer_create(screen, 4096,
- PIPE_BUFFER_USAGE_PIXEL, 4096);
+ r300->oqbo = pipe_buffer_create(screen,
+ R300_BIND_OQBO, 4096);
make_empty_list(&r300->query_list);
r300_init_flush_functions(r300);
-
r300_init_query_functions(r300);
-
- r300_init_transfer_functions(r300);
-
r300_init_state_functions(r300);
+ r300_init_resource_functions(r300);
r300->invariant_state.dirty = TRUE;
@@ -226,16 +201,16 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
r300->blitter = util_blitter_create(&r300->context);
- r300->upload_ib = u_upload_create(screen,
+ r300->upload_ib = u_upload_create(&r300->context,
32 * 1024, 16,
- PIPE_BUFFER_USAGE_INDEX);
+ PIPE_BIND_INDEX_BUFFER);
if (r300->upload_ib == NULL)
goto no_upload_ib;
- r300->upload_vb = u_upload_create(screen,
+ r300->upload_vb = u_upload_create(&r300->context,
128 * 1024, 16,
- PIPE_BUFFER_USAGE_VERTEX);
+ PIPE_BIND_VERTEX_BUFFER);
if (r300->upload_vb == NULL)
goto no_upload_vb;
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index be01db5b44..8d770853a4 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -29,6 +29,7 @@
#include "pipe/p_context.h"
#include "util/u_inlines.h"
+#include "util/u_transfer.h"
#include "r300_defines.h"
#include "r300_screen.h"
@@ -228,7 +229,7 @@ struct r300_query {
struct r300_texture {
/* Parent class */
- struct pipe_texture tex;
+ struct u_resource b;
/* Offsets into the buffer. */
unsigned offset[R300_MAX_TEXTURE_LEVELS];
@@ -305,7 +306,7 @@ struct r300_context {
unsigned mode, unsigned count);
void (*emit_draw_elements)(
- struct r300_context *r300, struct pipe_buffer* indexBuffer,
+ struct r300_context *r300, struct pipe_resource* indexBuffer,
unsigned indexSize, unsigned minIndex, unsigned maxIndex,
unsigned mode, unsigned start, unsigned count);
@@ -320,12 +321,12 @@ struct r300_context {
struct blitter_context* blitter;
/* Vertex buffer for rendering. */
- struct pipe_buffer* vbo;
+ struct pipe_resource* vbo;
/* Offset into the VBO. */
size_t vbo_offset;
/* Occlusion query buffer. */
- struct pipe_buffer* oqbo;
+ struct pipe_resource* oqbo;
/* Query list. */
struct r300_query *query_current;
struct r300_query query_list;
@@ -411,7 +412,7 @@ struct r300_context {
};
/* Convenience cast wrapper. */
-static INLINE struct r300_texture* r300_texture(struct pipe_texture* tex)
+static INLINE struct r300_texture* r300_texture(struct pipe_resource* tex)
{
return (struct r300_texture*)tex;
}
@@ -428,8 +429,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
/* Context initialization. */
struct draw_stage* r300_draw_stage(struct r300_context* r300);
void r300_init_state_functions(struct r300_context* r300);
-void r300_init_surface_functions(struct r300_context* r300);
-void r300_init_tex_functions( struct pipe_context *pipe );
+void r300_init_resource_functions(struct r300_context* r300);
static INLINE boolean CTX_DBG_ON(struct r300_context * ctx, unsigned flags)
{
diff --git a/src/gallium/drivers/r300/r300_defines.h b/src/gallium/drivers/r300/r300_defines.h
index 2e04876de9..1cc8a8674f 100644
--- a/src/gallium/drivers/r300/r300_defines.h
+++ b/src/gallium/drivers/r300/r300_defines.h
@@ -28,7 +28,7 @@
#define R300_MAX_TEXTURE_LEVELS 13
#define R300_MAX_DRAW_VBO_SIZE (1024 * 1024)
-#define R300_TEXTURE_USAGE_TRANSFER PIPE_TEXTURE_USAGE_CUSTOM
+#define R300_RESOURCE_FLAG_TRANSFER PIPE_RESOURCE_FLAG_DRV_PRIV
/* Non-atom dirty state flags. */
#define R300_NEW_FRAGMENT_SHADER 0x00000020
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 79988a0caa..350c538ebc 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -145,7 +145,7 @@ static const float * get_shader_constant(
struct r300_viewport_state* viewport = r300->viewport_state.state;
struct r300_textures_state* texstate = r300->textures_state.state;
static float vec[4] = { 0.0, 0.0, 0.0, 1.0 };
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
switch(constant->Type) {
case RC_CONSTANT_EXTERNAL:
@@ -973,7 +973,7 @@ void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, voi
void r300_emit_buffer_validate(struct r300_context *r300,
boolean do_validate_vertex_buffers,
- struct pipe_buffer *index_buffer)
+ struct pipe_resource *index_buffer)
{
struct pipe_framebuffer_state* fb =
(struct pipe_framebuffer_state*)r300->fb_state.state;
@@ -982,7 +982,7 @@ void r300_emit_buffer_validate(struct r300_context *r300,
struct r300_texture* tex;
struct pipe_vertex_buffer *vbuf = r300->vertex_buffer;
struct pipe_vertex_element *velem = r300->velems->velem;
- struct pipe_buffer *pbuf;
+ struct pipe_resource *pbuf;
unsigned i;
boolean invalid = FALSE;
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index 7db2fc6a1a..27251a60ab 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -102,6 +102,6 @@ void r300_emit_dirty_state(struct r300_context* r300);
void r300_emit_buffer_validate(struct r300_context *r300,
boolean do_validate_vertex_buffers,
- struct pipe_buffer *index_buffer);
+ struct pipe_resource *index_buffer);
#endif /* R300_EMIT_H */
diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
index bc40fcfb5b..3348a0ada6 100644
--- a/src/gallium/drivers/r300/r300_query.c
+++ b/src/gallium/drivers/r300/r300_query.c
@@ -78,17 +78,17 @@ static void r300_destroy_query(struct pipe_context* pipe,
static void r300_begin_query(struct pipe_context* pipe,
struct pipe_query* query)
{
- uint32_t* map;
+ uint32_t value = ~0U;
struct r300_context* r300 = r300_context(pipe);
struct r300_query* q = (struct r300_query*)query;
assert(r300->query_current == NULL);
- map = pipe->screen->buffer_map(pipe->screen, r300->oqbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- map += q->offset / 4;
- *map = ~0U;
- pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
+ pipe_buffer_write(pipe,
+ r300->oqbo,
+ q->offset,
+ sizeof value,
+ &value);
q->flushed = FALSE;
r300->query_current = q;
@@ -114,7 +114,8 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
struct r300_context* r300 = r300_context(pipe);
struct r300_screen* r300screen = r300->screen;
struct r300_query *q = (struct r300_query*)query;
- unsigned flags = PIPE_BUFFER_USAGE_CPU_READ;
+ struct pipe_transfer *transfer;
+ unsigned flags = PIPE_TRANSFER_READ;
uint32_t* map;
uint32_t temp = 0;
unsigned i, num_results;
@@ -122,10 +123,10 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
if (q->flushed == FALSE)
pipe->flush(pipe, 0, NULL);
if (!wait) {
- flags |= PIPE_BUFFER_USAGE_DONTBLOCK;
+ flags |= PIPE_TRANSFER_DONTBLOCK;
}
- map = pipe->screen->buffer_map(pipe->screen, r300->oqbo, flags);
+ map = pipe_buffer_map(pipe, r300->oqbo, flags, &transfer);
if (!map)
return FALSE;
map += q->offset / 4;
@@ -148,7 +149,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
temp += *map;
map++;
}
- pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
+ pipe_buffer_unmap(pipe, r300->oqbo, transfer);
if (temp == ~0U) {
/* Our results haven't been written yet... */
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 09355569fb..44da7aa377 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -152,7 +152,9 @@ static boolean immd_is_good_idea(struct r300_context *r300,
if (!checked[vbi]) {
vbuf = &r300->vertex_buffer[vbi];
- if (r300_buffer_is_referenced(r300, vbuf->buffer)) {
+ if (r300->context.is_resource_referenced(&r300->context,
+ vbuf->buffer,
+ 0, 0)) {
/* It's a very bad idea to map it... */
return FALSE;
}
@@ -192,6 +194,7 @@ void r500_emit_draw_arrays_immediate(struct r300_context *r300,
/* Mapped vertex buffers. */
uint32_t* map[PIPE_MAX_ATTRIBS] = {0};
+ struct pipe_transfer* transfer[PIPE_MAX_ATTRIBS] = {NULL};
CS_LOCALS(r300);
@@ -206,9 +209,10 @@ void r500_emit_draw_arrays_immediate(struct r300_context *r300,
/* Map the buffer. */
if (!map[vbi]) {
vbuf = &r300->vertex_buffer[vbi];
- map[vbi] = (uint32_t*)pipe_buffer_map(r300->context.screen,
+ map[vbi] = (uint32_t*)pipe_buffer_map(&r300->context,
vbuf->buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &transfer[vbi]);
map[vbi] += vbuf->buffer_offset / 4;
stride[vbi] = vbuf->stride / 4;
}
@@ -251,7 +255,7 @@ void r500_emit_draw_arrays_immediate(struct r300_context *r300,
if (map[vbi]) {
vbuf = &r300->vertex_buffer[vbi];
- pipe_buffer_unmap(r300->context.screen, vbuf->buffer);
+ pipe_buffer_unmap(&r300->context, vbuf->buffer, transfer[vbi]);
map[vbi] = NULL;
}
}
@@ -288,7 +292,7 @@ void r500_emit_draw_arrays(struct r300_context *r300,
}
void r500_emit_draw_elements(struct r300_context *r300,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -428,7 +432,7 @@ void r300_emit_draw_arrays(struct r300_context *r300,
}
void r300_emit_draw_elements(struct r300_context *r300,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -451,24 +455,24 @@ void r300_emit_draw_elements(struct r300_context *r300,
}
static void r300_shorten_ubyte_elts(struct r300_context* r300,
- struct pipe_buffer** elts,
+ struct pipe_resource** elts,
unsigned start,
unsigned count)
{
+ struct pipe_context* context = &r300->context;
struct pipe_screen* screen = r300->context.screen;
- struct pipe_buffer* new_elts;
+ struct pipe_resource* new_elts;
unsigned char *in_map;
unsigned short *out_map;
+ struct pipe_transfer *src_transfer, *dst_transfer;
unsigned i;
- new_elts = screen->buffer_create(screen, 32,
- PIPE_BUFFER_USAGE_INDEX |
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ,
- 2 * count);
+ new_elts = pipe_buffer_create(screen,
+ PIPE_BIND_INDEX_BUFFER,
+ 2 * count);
- in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ);
- out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE);
+ in_map = pipe_buffer_map(context, *elts, PIPE_TRANSFER_READ, &src_transfer);
+ out_map = pipe_buffer_map(context, new_elts, PIPE_TRANSFER_WRITE, &dst_transfer);
in_map += start;
@@ -478,41 +482,43 @@ static void r300_shorten_ubyte_elts(struct r300_context* r300,
out_map++;
}
- pipe_buffer_unmap(screen, *elts);
- pipe_buffer_unmap(screen, new_elts);
+ pipe_buffer_unmap(context, *elts, src_transfer);
+ pipe_buffer_unmap(context, new_elts, dst_transfer);
*elts = new_elts;
}
static void r300_align_ushort_elts(struct r300_context *r300,
- struct pipe_buffer **elts,
+ struct pipe_resource **elts,
unsigned start, unsigned count)
{
- struct pipe_screen* screen = r300->context.screen;
- struct pipe_buffer* new_elts;
+ struct pipe_context* context = &r300->context;
+ struct pipe_transfer *in_transfer = NULL;
+ struct pipe_transfer *out_transfer = NULL;
+ struct pipe_resource* new_elts;
unsigned short *in_map;
unsigned short *out_map;
- new_elts = screen->buffer_create(screen, 32,
- PIPE_BUFFER_USAGE_INDEX |
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ,
- 2 * count);
+ new_elts = pipe_buffer_create(context->screen,
+ PIPE_BIND_INDEX_BUFFER,
+ 2 * count);
- in_map = pipe_buffer_map(screen, *elts, PIPE_BUFFER_USAGE_CPU_READ);
- out_map = pipe_buffer_map(screen, new_elts, PIPE_BUFFER_USAGE_CPU_WRITE);
+ in_map = pipe_buffer_map(context, *elts,
+ PIPE_TRANSFER_READ, &in_transfer);
+ out_map = pipe_buffer_map(context, new_elts,
+ PIPE_TRANSFER_WRITE, &out_transfer);
memcpy(out_map, in_map+start, 2 * count);
- pipe_buffer_unmap(screen, *elts);
- pipe_buffer_unmap(screen, new_elts);
+ pipe_buffer_unmap(context, *elts, in_transfer);
+ pipe_buffer_unmap(context, new_elts, out_transfer);
*elts = new_elts;
}
/* This is the fast-path drawing & emission for HW TCL. */
void r300_draw_range_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -521,7 +527,7 @@ void r300_draw_range_elements(struct pipe_context* pipe,
unsigned count)
{
struct r300_context* r300 = r300_context(pipe);
- struct pipe_buffer* orgIndexBuffer = indexBuffer;
+ struct pipe_resource* orgIndexBuffer = indexBuffer;
#if defined(ENABLE_ALT_NUM_VERTS)
boolean alt_num_verts = r300->screen->caps.is_r500 &&
count > 65536;
@@ -581,13 +587,13 @@ void r300_draw_range_elements(struct pipe_context* pipe,
}
if (indexBuffer != orgIndexBuffer) {
- pipe_buffer_reference( &indexBuffer, NULL );
+ pipe_resource_reference( &indexBuffer, NULL );
}
}
/* Simple helpers for context setup. Should probably be moved to util. */
void r300_draw_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize, unsigned mode,
unsigned start, unsigned count)
{
@@ -665,6 +671,7 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe,
unsigned count)
{
struct r300_context* r300 = r300_context(pipe);
+ struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
int i;
if (r300->skip_rendering) {
@@ -676,9 +683,10 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe,
}
for (i = 0; i < r300->vertex_buffer_count; i++) {
- void* buf = pipe_buffer_map(pipe->screen,
+ void* buf = pipe_buffer_map(pipe,
r300->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &vb_transfer[i]);
draw_set_mapped_vertex_buffer(r300->draw, i, buf);
}
@@ -687,14 +695,15 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe,
draw_arrays(r300->draw, mode, start, count);
for (i = 0; i < r300->vertex_buffer_count; i++) {
- pipe_buffer_unmap(pipe->screen, r300->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe, r300->vertex_buffer[i].buffer,
+ vb_transfer[i]);
draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
}
}
/* SW TCL elements, using Draw. */
void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -703,6 +712,8 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
unsigned count)
{
struct r300_context* r300 = r300_context(pipe);
+ struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
+ struct pipe_transfer *ib_transfer;
int i;
void* indices;
@@ -715,25 +726,28 @@ void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
}
for (i = 0; i < r300->vertex_buffer_count; i++) {
- void* buf = pipe_buffer_map(pipe->screen,
+ void* buf = pipe_buffer_map(pipe,
r300->vertex_buffer[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &vb_transfer[i]);
draw_set_mapped_vertex_buffer(r300->draw, i, buf);
}
- indices = pipe_buffer_map(pipe->screen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ indices = pipe_buffer_map(pipe, indexBuffer,
+ PIPE_TRANSFER_READ, &ib_transfer);
draw_set_mapped_element_buffer_range(r300->draw, indexSize,
minIndex, maxIndex, indices);
draw_arrays(r300->draw, mode, start, count);
for (i = 0; i < r300->vertex_buffer_count; i++) {
- pipe_buffer_unmap(pipe->screen, r300->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe, r300->vertex_buffer[i].buffer,
+ vb_transfer[i]);
draw_set_mapped_vertex_buffer(r300->draw, i, NULL);
}
- pipe_buffer_unmap(pipe->screen, indexBuffer);
+ pipe_buffer_unmap(pipe, indexBuffer,
+ ib_transfer);
draw_set_mapped_element_buffer_range(r300->draw, 0, start,
start + count - 1, NULL);
}
@@ -752,11 +766,13 @@ struct r300_render {
unsigned hwprim;
/* VBO */
- struct pipe_buffer* vbo;
+ struct pipe_resource* vbo;
size_t vbo_size;
size_t vbo_offset;
size_t vbo_max_used;
void * vbo_ptr;
+
+ struct pipe_transfer *vbo_transfer;
};
static INLINE struct r300_render*
@@ -787,10 +803,9 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render,
if (size + r300render->vbo_offset > r300render->vbo_size)
{
- pipe_buffer_reference(&r300->vbo, NULL);
+ pipe_resource_reference(&r300->vbo, NULL);
r300render->vbo = pipe_buffer_create(screen,
- 64,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
R300_MAX_DRAW_VBO_SIZE);
r300render->vbo_offset = 0;
r300render->vbo_size = R300_MAX_DRAW_VBO_SIZE;
@@ -806,10 +821,11 @@ static boolean r300_render_allocate_vertices(struct vbuf_render* render,
static void* r300_render_map_vertices(struct vbuf_render* render)
{
struct r300_render* r300render = r300_render(render);
- struct pipe_screen* screen = r300render->r300->context.screen;
- r300render->vbo_ptr = pipe_buffer_map(screen, r300render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ r300render->vbo_ptr = pipe_buffer_map(&r300render->r300->context,
+ r300render->vbo,
+ PIPE_TRANSFER_WRITE,
+ &r300render->vbo_transfer);
return ((uint8_t*)r300render->vbo_ptr + r300render->vbo_offset);
}
@@ -819,7 +835,7 @@ static void r300_render_unmap_vertices(struct vbuf_render* render,
ushort max)
{
struct r300_render* r300render = r300_render(render);
- struct pipe_screen* screen = r300render->r300->context.screen;
+ struct pipe_context* context = &r300render->r300->context;
CS_LOCALS(r300render->r300);
BEGIN_CS(2);
OUT_CS_REG(R300_VAP_VF_MAX_VTX_INDX, max);
@@ -827,7 +843,7 @@ static void r300_render_unmap_vertices(struct vbuf_render* render,
r300render->vbo_max_used = MAX2(r300render->vbo_max_used,
r300render->vertex_size * (max + 1));
- pipe_buffer_unmap(screen, r300render->vbo);
+ pipe_buffer_unmap(context, r300render->vbo, r300render->vbo_transfer);
}
static void r300_render_release_vertices(struct vbuf_render* render)
diff --git a/src/gallium/drivers/r300/r300_render.h b/src/gallium/drivers/r300/r300_render.h
index 870e1fb53d..b8307c84d3 100644
--- a/src/gallium/drivers/r300/r300_render.h
+++ b/src/gallium/drivers/r300/r300_render.h
@@ -35,7 +35,7 @@ void r500_emit_draw_arrays(struct r300_context *r300,
unsigned count);
void r500_emit_draw_elements(struct r300_context *r300,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -53,7 +53,7 @@ void r300_emit_draw_arrays(struct r300_context *r300,
unsigned count);
void r300_emit_draw_elements(struct r300_context *r300,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -62,7 +62,7 @@ void r300_emit_draw_elements(struct r300_context *r300,
unsigned count);
void r300_draw_range_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -71,7 +71,7 @@ void r300_draw_range_elements(struct pipe_context* pipe,
unsigned count);
void r300_draw_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize, unsigned mode,
unsigned start, unsigned count);
@@ -84,7 +84,7 @@ void r300_swtcl_draw_arrays(struct pipe_context* pipe,
unsigned count);
void r300_swtcl_draw_range_elements(struct pipe_context* pipe,
- struct pipe_buffer* indexBuffer,
+ struct pipe_resource* indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
diff --git a/src/gallium/drivers/r300/r300_resource.c b/src/gallium/drivers/r300/r300_resource.c
new file mode 100644
index 0000000000..84e3fdd137
--- /dev/null
+++ b/src/gallium/drivers/r300/r300_resource.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2010 Red Hat Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Dave Airlie
+ */
+#include <stdio.h>
+
+#include "util/u_inlines.h"
+#include "util/u_format.h"
+#include "util/u_memory.h"
+#include "util/u_upload_mgr.h"
+#include "util/u_math.h"
+
+#include "r300_context.h"
+#include "r300_texture.h"
+#include "r300_transfer.h"
+#include "r300_screen.h"
+#include "r300_state_inlines.h"
+#include "r300_screen_buffer.h"
+
+#include "r300_winsys.h"
+
+
+
+
+static struct pipe_resource *
+r300_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ if (template->target == PIPE_BUFFER)
+ return r300_buffer_create(screen, template);
+ else
+ return r300_texture_create(screen, template);
+
+}
+
+static struct pipe_resource *
+r300_resource_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
+{
+ if (template->target == PIPE_BUFFER)
+ return NULL;
+ else
+ return r300_texture_from_handle(screen, template, whandle);
+}
+
+
+
+void
+r300_init_resource_functions(struct r300_context *r300)
+{
+ r300->context.get_transfer = u_get_transfer_vtbl;
+ r300->context.transfer_map = u_transfer_map_vtbl;
+ r300->context.transfer_flush_region = u_transfer_flush_region_vtbl;
+ r300->context.transfer_unmap = u_transfer_unmap_vtbl;
+ r300->context.transfer_destroy = u_transfer_destroy_vtbl;
+ r300->context.transfer_inline_write = u_transfer_inline_write_vtbl;
+ r300->context.is_resource_referenced = u_is_resource_referenced_vtbl;
+}
+
+void
+r300_init_screen_resource_functions(struct r300_screen *r300screen)
+{
+ r300screen->screen.resource_create = r300_resource_create;
+ r300screen->screen.resource_from_handle = r300_resource_from_handle;
+ r300screen->screen.resource_get_handle = u_resource_get_handle_vtbl;
+ r300screen->screen.resource_destroy = u_resource_destroy_vtbl;
+ r300screen->screen.user_buffer_create = r300_user_buffer_create;
+
+ r300screen->screen.get_tex_surface = r300_get_tex_surface;
+ r300screen->screen.tex_surface_destroy = r300_tex_surface_destroy;
+}
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 00c16b8662..2eae5756e3 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -218,7 +218,7 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
}
/* Check sampler format support. */
- if ((usage & PIPE_TEXTURE_USAGE_SAMPLER) &&
+ if ((usage & PIPE_BIND_SAMPLER_VIEW) &&
/* Z24 cannot be sampled from on non-r5xx. */
(is_r500 || !is_z24) &&
/* ATI1N is r5xx-only. */
@@ -226,28 +226,28 @@ static boolean r300_is_format_supported(struct pipe_screen* screen,
/* ATI2N is supported on r4xx-r5xx. */
(is_r400 || is_r500 || !is_ati2n) &&
r300_is_sampler_format_supported(format)) {
- retval |= PIPE_TEXTURE_USAGE_SAMPLER;
+ retval |= PIPE_BIND_SAMPLER_VIEW;
}
/* Check colorbuffer format support. */
- if ((usage & (PIPE_TEXTURE_USAGE_RENDER_TARGET |
- PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) &&
+ if ((usage & (PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) &&
/* 2101010 cannot be rendered to on non-r5xx. */
(is_r500 || !is_color2101010) &&
r300_is_colorbuffer_format_supported(format)) {
retval |= usage &
- (PIPE_TEXTURE_USAGE_RENDER_TARGET |
- PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED);
+ (PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED);
}
/* Check depth-stencil format support. */
- if (usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL &&
+ if (usage & PIPE_BIND_DEPTH_STENCIL &&
r300_is_zs_format_supported(format)) {
- retval |= PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ retval |= PIPE_BIND_DEPTH_STENCIL;
}
return retval == usage;
@@ -314,9 +314,8 @@ struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws)
r300screen->screen.fence_signalled = r300_fence_signalled;
r300screen->screen.fence_finish = r300_fence_finish;
- r300_init_screen_texture_functions(&r300screen->screen);
+ r300_init_screen_resource_functions(r300screen);
- r300_screen_init_buffer_functions(r300screen);
return &r300screen->screen;
}
diff --git a/src/gallium/drivers/r300/r300_screen.h b/src/gallium/drivers/r300/r300_screen.h
index 159805840d..2f951c7097 100644
--- a/src/gallium/drivers/r300/r300_screen.h
+++ b/src/gallium/drivers/r300/r300_screen.h
@@ -89,5 +89,7 @@ static INLINE void SCREEN_DBG(struct r300_screen * screen, unsigned flags,
void r300_init_debug(struct r300_screen* ctx);
+void r300_init_screen_resource_functions(struct r300_screen *r300screen);
+
#endif /* R300_SCREEN_H */
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index a1cd48ee73..cb47ba1688 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -34,23 +34,31 @@
#include "r300_winsys.h"
-boolean r300_buffer_is_referenced(struct r300_context *r300,
- struct pipe_buffer *buf)
+static unsigned r300_buffer_is_referenced(struct pipe_context *context,
+ struct pipe_resource *buf,
+ unsigned face, unsigned level)
{
+ struct r300_context *r300 = r300_context(context);
struct r300_buffer *rbuf = r300_buffer(buf);
+
if (r300_buffer_is_user_buffer(buf))
- return FALSE;
+ return PIPE_UNREFERENCED;
+
+ if (r300->rws->is_buffer_referenced(r300->rws, rbuf->buf))
+ return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
- return r300->rws->is_buffer_referenced(r300->rws, rbuf->buf);
-
+ return PIPE_UNREFERENCED;
}
+
+/* External helper, not required to implent u_resource_vtbl:
+ */
int r300_upload_index_buffer(struct r300_context *r300,
- struct pipe_buffer **index_buffer,
+ struct pipe_resource **index_buffer,
unsigned index_size,
unsigned start,
unsigned count)
{
- struct pipe_buffer *upload_buffer = NULL;
+ struct pipe_resource *upload_buffer = NULL;
unsigned index_offset = start * index_size;
int ret = 0;
@@ -68,10 +76,12 @@ int r300_upload_index_buffer(struct r300_context *r300,
}
done:
// if (upload_buffer)
- // pipe_buffer_reference(&upload_buffer, NULL);
+ // pipe_resource_reference(&upload_buffer, NULL);
return ret;
}
+/* External helper, not required to implent u_resource_vtbl:
+ */
int r300_upload_user_buffers(struct r300_context *r300)
{
enum pipe_error ret = PIPE_OK;
@@ -82,9 +92,9 @@ int r300_upload_user_buffers(struct r300_context *r300)
for (i = 0; i < nr; i++) {
if (r300_buffer_is_user_buffer(r300->vertex_buffer[i].buffer)) {
- struct pipe_buffer *upload_buffer = NULL;
+ struct pipe_resource *upload_buffer = NULL;
unsigned offset = 0; /*r300->vertex_buffer[i].buffer_offset * 4;*/
- unsigned size = r300->vertex_buffer[i].buffer->size;
+ unsigned size = r300->vertex_buffer[i].buffer->width0;
unsigned upload_offset;
ret = u_upload_buffer(r300->upload_vb,
offset, size,
@@ -93,7 +103,7 @@ int r300_upload_user_buffers(struct r300_context *r300)
if (ret)
return ret;
- pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL);
+ pipe_resource_reference(&r300->vertex_buffer[i].buffer, NULL);
r300->vertex_buffer[i].buffer = upload_buffer;
r300->vertex_buffer[i].buffer_offset = upload_offset;
}
@@ -125,70 +135,11 @@ static void r300_winsys_buffer_destroy(struct r300_screen *r300screen,
}
}
-static struct pipe_buffer *r300_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct r300_screen *r300screen = r300_screen(screen);
- struct r300_buffer *rbuf;
-
- rbuf = CALLOC_STRUCT(r300_buffer);
- if (!rbuf)
- goto error1;
-
- rbuf->magic = R300_BUFFER_MAGIC;
-
- pipe_reference_init(&rbuf->base.reference, 1);
- rbuf->base.screen = screen;
- rbuf->base.alignment = alignment;
- rbuf->base.usage = usage;
- rbuf->base.size = size;
- rbuf->buf = r300_winsys_buffer_create(r300screen,
- alignment,
- usage,
- size);
-
- if (!rbuf->buf)
- goto error2;
-
- return &rbuf->base;
-error2:
- FREE(rbuf);
-error1:
- return NULL;
-}
-
-
-static struct pipe_buffer *r300_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
+static void r300_buffer_destroy(struct pipe_screen *screen,
+ struct pipe_resource *buf)
{
- struct r300_buffer *rbuf;
-
- rbuf = CALLOC_STRUCT(r300_buffer);
- if (!rbuf)
- goto no_rbuf;
-
- rbuf->magic = R300_BUFFER_MAGIC;
-
- pipe_reference_init(&rbuf->base.reference, 1);
- rbuf->base.screen = screen;
- rbuf->base.alignment = 1;
- rbuf->base.usage = 0;
- rbuf->base.size = bytes;
-
- rbuf->user_buffer = ptr;
- return &rbuf->base;
-
-no_rbuf:
- return NULL;
-}
-
-static void r300_buffer_destroy(struct pipe_buffer *buf)
-{
- struct r300_screen *r300screen = r300_screen(buf->screen);
+ struct r300_screen *r300screen = r300_screen(screen);
struct r300_buffer *rbuf = r300_buffer(buf);
r300_winsys_buffer_destroy(r300screen, rbuf);
@@ -197,7 +148,7 @@ static void r300_buffer_destroy(struct pipe_buffer *buf)
static void *
r300_buffer_map_range(struct pipe_screen *screen,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned offset, unsigned length,
unsigned usage )
{
@@ -211,11 +162,12 @@ r300_buffer_map_range(struct pipe_screen *screen,
if (rbuf->user_buffer)
return rbuf->user_buffer;
- if (rbuf->base.usage & PIPE_BUFFER_USAGE_CONSTANT)
+ if (rbuf->b.b.bind & PIPE_BIND_CONSTANT_BUFFER) {
goto just_map;
+ }
/* check if the mapping is to a range we already flushed */
- if (usage & PIPE_BUFFER_USAGE_DISCARD) {
+ if (usage & PIPE_TRANSFER_DISCARD) {
for (i = 0; i < rbuf->num_ranges; i++) {
if ((offset >= rbuf->ranges[i].start) &&
@@ -229,9 +181,9 @@ r300_buffer_map_range(struct pipe_screen *screen,
rbuf->num_ranges = 0;
rbuf->map = NULL;
rbuf->buf = r300_winsys_buffer_create(r300screen,
- rbuf->base.alignment,
- rbuf->base.usage,
- rbuf->base.size);
+ 16,
+ rbuf->b.b.bind, /* XXX */
+ rbuf->b.b.width0);
break;
}
}
@@ -244,7 +196,7 @@ just_map:
static void
r300_buffer_flush_mapped_range( struct pipe_screen *screen,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned offset,
unsigned length )
{
@@ -254,7 +206,7 @@ r300_buffer_flush_mapped_range( struct pipe_screen *screen,
if (rbuf->user_buffer)
return;
- if (rbuf->base.usage & PIPE_BUFFER_USAGE_CONSTANT)
+ if (rbuf->b.b.bind & PIPE_BIND_CONSTANT_BUFFER)
return;
/* mark the range as used */
@@ -271,44 +223,152 @@ r300_buffer_flush_mapped_range( struct pipe_screen *screen,
rbuf->num_ranges++;
}
-static void *
-r300_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned usage)
+
+static void
+r300_buffer_unmap(struct pipe_screen *screen,
+ struct pipe_resource *buf)
{
struct r300_screen *r300screen = r300_screen(screen);
struct r300_winsys_screen *rws = r300screen->rws;
struct r300_buffer *rbuf = r300_buffer(buf);
- void *map;
- if (rbuf->user_buffer)
- return rbuf->user_buffer;
+ if (rbuf->buf) {
+ rws->buffer_unmap(rws, rbuf->buf);
+ }
+}
- map = rws->buffer_map(rws, rbuf->buf, usage);
- return map;
+
+
+/* As a first step, keep the original code intact, implement buffer
+ * transfers in terms of the old map/unmap functions.
+ *
+ * Utility functions for transfer create/destroy are hooked in and
+ * just record the arguments to those functions.
+ */
+static void *
+r300_buffer_transfer_map( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ uint8_t *map = r300_buffer_map_range( pipe->screen,
+ transfer->resource,
+ transfer->box.x,
+ transfer->box.width,
+ transfer->usage );
+ if (map == NULL)
+ return NULL;
+
+ /* map_buffer() returned a pointer to the beginning of the buffer,
+ * but transfers are expected to return a pointer to just the
+ * region specified in the box.
+ */
+ return map + transfer->box.x;
}
-static void
-r300_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
+
+
+static void r300_buffer_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ assert(box->x + box->width <= transfer->box.width);
+
+ r300_buffer_flush_mapped_range(pipe->screen,
+ transfer->resource,
+ transfer->box.x + box->x,
+ box->width);
+}
+
+static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ r300_buffer_unmap(pipe->screen,
+ transfer->resource);
+}
+
+
+
+
+struct u_resource_vtbl r300_buffer_vtbl =
+{
+ u_default_resource_get_handle, /* get_handle */
+ r300_buffer_destroy, /* resource_destroy */
+ r300_buffer_is_referenced, /* is_buffer_referenced */
+ u_default_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ r300_buffer_transfer_map, /* transfer_map */
+ r300_buffer_transfer_flush_region, /* transfer_flush_region */
+ r300_buffer_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+
+struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
{
struct r300_screen *r300screen = r300_screen(screen);
- struct r300_winsys_screen *rws = r300screen->rws;
- struct r300_buffer *rbuf = r300_buffer(buf);
+ struct r300_buffer *rbuf;
+ unsigned alignment = 16;
- if (rbuf->buf) {
- rws->buffer_unmap(rws, rbuf->buf);
- }
+ rbuf = CALLOC_STRUCT(r300_buffer);
+ if (!rbuf)
+ goto error1;
+
+ rbuf->magic = R300_BUFFER_MAGIC;
+
+ rbuf->b.b = *template;
+ rbuf->b.vtbl = &r300_buffer_vtbl;
+ pipe_reference_init(&rbuf->b.b.reference, 1);
+ rbuf->b.b.screen = screen;
+
+ if (rbuf->b.b.bind & R300_BIND_OQBO)
+ alignment = 4096;
+
+ rbuf->buf = r300_winsys_buffer_create(r300screen,
+ alignment,
+ rbuf->b.b.bind,
+ rbuf->b.b.width0);
+
+ if (!rbuf->buf)
+ goto error2;
+
+ return &rbuf->b.b;
+error2:
+ FREE(rbuf);
+error1:
+ return NULL;
}
-void r300_screen_init_buffer_functions(struct r300_screen *r300screen)
+
+struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind)
{
- r300screen->screen.buffer_create = r300_buffer_create;
- r300screen->screen.user_buffer_create = r300_user_buffer_create;
- r300screen->screen.buffer_map = r300_buffer_map;
- r300screen->screen.buffer_map_range = r300_buffer_map_range;
- r300screen->screen.buffer_flush_mapped_range = r300_buffer_flush_mapped_range;
- r300screen->screen.buffer_unmap = r300_buffer_unmap;
- r300screen->screen.buffer_destroy = r300_buffer_destroy;
+ struct r300_buffer *rbuf;
+
+ rbuf = CALLOC_STRUCT(r300_buffer);
+ if (!rbuf)
+ goto no_rbuf;
+
+ rbuf->magic = R300_BUFFER_MAGIC;
+
+ pipe_reference_init(&rbuf->b.b.reference, 1);
+ rbuf->b.vtbl = &r300_buffer_vtbl;
+ rbuf->b.b.screen = screen;
+ rbuf->b.b.format = PIPE_FORMAT_R8_UNORM;
+ rbuf->b.b._usage = PIPE_USAGE_IMMUTABLE;
+ rbuf->b.b.bind = bind;
+ rbuf->b.b.width0 = bytes;
+ rbuf->b.b.height0 = 1;
+ rbuf->b.b.depth0 = 1;
+
+ rbuf->user_buffer = ptr;
+ return &rbuf->b.b;
+
+no_rbuf:
+ return NULL;
}
+
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.h b/src/gallium/drivers/r300/r300_screen_buffer.h
index 0cf349c25c..93009ea02f 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.h
+++ b/src/gallium/drivers/r300/r300_screen_buffer.h
@@ -3,6 +3,7 @@
#include <stdio.h>
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
+#include "util/u_transfer.h"
#include "r300_screen.h"
#include "r300_winsys.h"
@@ -18,7 +19,7 @@ struct r300_buffer_range {
struct r300_buffer
{
- struct pipe_buffer base;
+ struct u_resource b;
uint32_t magic;
@@ -32,7 +33,7 @@ struct r300_buffer
};
static INLINE struct r300_buffer *
-r300_buffer(struct pipe_buffer *buffer)
+r300_buffer(struct pipe_resource *buffer)
{
if (buffer) {
assert(((struct r300_buffer *)buffer)->magic == R300_BUFFER_MAGIC);
@@ -42,13 +43,13 @@ r300_buffer(struct pipe_buffer *buffer)
}
static INLINE boolean
-r300_buffer_is_user_buffer(struct pipe_buffer *buffer)
+r300_buffer_is_user_buffer(struct pipe_resource *buffer)
{
return r300_buffer(buffer)->user_buffer ? true : false;
}
static INLINE boolean r300_add_buffer(struct r300_winsys_screen *rws,
- struct pipe_buffer *buffer,
+ struct pipe_resource *buffer,
int rd, int wr)
{
struct r300_buffer *buf = r300_buffer(buffer);
@@ -67,7 +68,6 @@ static INLINE boolean r300_add_texture(struct r300_winsys_screen *rws,
return rws->add_buffer(rws, tex->buffer, rd, wr);
}
-void r300_screen_init_buffer_functions(struct r300_screen *r300screen);
static INLINE void r300_buffer_write_reloc(struct r300_winsys_screen *rws,
struct r300_buffer *buf,
@@ -89,11 +89,18 @@ static INLINE void r300_texture_write_reloc(struct r300_winsys_screen *rws,
int r300_upload_user_buffers(struct r300_context *r300);
int r300_upload_index_buffer(struct r300_context *r300,
- struct pipe_buffer **index_buffer,
+ struct pipe_resource **index_buffer,
unsigned index_size,
unsigned start,
unsigned count);
-boolean r300_buffer_is_referenced(struct r300_context *r300,
- struct pipe_buffer *buf);
+
+struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template);
+
+struct pipe_resource *r300_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage);
+
#endif
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 6549833983..52b89104b9 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -1019,7 +1019,7 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
static struct pipe_sampler_view *
r300_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -1028,7 +1028,7 @@ r300_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}
@@ -1039,7 +1039,7 @@ static void
r300_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
@@ -1133,7 +1133,7 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
vbo = (struct pipe_vertex_buffer*)&buffers[i];
/* Reference our buffer. */
- pipe_buffer_reference(&r300->vertex_buffer[i].buffer, vbo->buffer);
+ pipe_resource_reference(&r300->vertex_buffer[i].buffer, vbo->buffer);
/* Skip NULL buffers */
if (!buffers[i].buffer) {
@@ -1147,7 +1147,7 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
if (vbo->max_index == ~0) {
/* Bogus value from broken state tracker; hax it. */
vbo->max_index =
- (vbo->buffer->size - vbo->buffer_offset) / vbo->stride;
+ (vbo->buffer->width0 - vbo->buffer_offset) / vbo->stride;
}
max_index = MIN2(vbo->max_index, max_index);
@@ -1155,7 +1155,7 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
for (; i < r300->vertex_buffer_count; i++) {
/* Dereference any old buffers. */
- pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL);
+ pipe_resource_reference(&r300->vertex_buffer[i].buffer, NULL);
}
memcpy(r300->vertex_buffer, buffers,
@@ -1344,20 +1344,21 @@ static void r300_delete_vs_state(struct pipe_context* pipe, void* shader)
static void r300_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *buf)
+ struct pipe_resource *buf)
{
struct r300_context* r300 = r300_context(pipe);
+ struct pipe_transfer *tr;
void *mapped;
int max_size = 0;
- if (buf == NULL || buf->size == 0 ||
- (mapped = pipe_buffer_map(pipe->screen, buf, PIPE_BUFFER_USAGE_CPU_READ)) == NULL)
+ if (buf == NULL || buf->width0 == 0 ||
+ (mapped = pipe_buffer_map(pipe, buf, PIPE_TRANSFER_READ, &tr)) == NULL)
{
r300->shader_constants[shader].count = 0;
return;
}
- assert((buf->size % 4 * sizeof(float)) == 0);
+ assert((buf->width0 % 4 * sizeof(float)) == 0);
/* Check the size of the constant buffer. */
switch (shader) {
@@ -1379,15 +1380,15 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
}
/* XXX Subtract immediates and RC_STATE_* variables. */
- if (buf->size > (sizeof(float) * 4 * max_size)) {
+ if (buf->width0 > (sizeof(float) * 4 * max_size)) {
fprintf(stderr, "r300: Max size of the constant buffer is "
"%i*4 floats.\n", max_size);
abort();
}
- memcpy(r300->shader_constants[shader].constants, mapped, buf->size);
- r300->shader_constants[shader].count = buf->size / (4 * sizeof(float));
- pipe_buffer_unmap(pipe->screen, buf);
+ memcpy(r300->shader_constants[shader].constants, mapped, buf->width0);
+ r300->shader_constants[shader].count = buf->width0 / (4 * sizeof(float));
+ pipe_buffer_unmap(pipe, buf, tr);
if (shader == PIPE_SHADER_VERTEX) {
if (r300->screen->caps.has_tcl) {
@@ -1396,7 +1397,7 @@ static void r300_set_constant_buffer(struct pipe_context *pipe,
} else if (r300->draw) {
draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX,
0, r300->shader_constants[PIPE_SHADER_VERTEX].constants,
- buf->size);
+ buf->width0);
}
} else if (shader == PIPE_SHADER_FRAGMENT) {
r300->dirty_state |= R300_NEW_FRAGMENT_SHADER_CONSTANTS;
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index b9d3718f1c..ae54d06372 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -473,7 +473,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
tex = r300_texture(view->texture);
sampler = state->sampler_states[i];
- assert(view->format == tex->tex.format);
+ assert(view->format == tex->b.b.format);
texstate = &state->regs[i];
memcpy(texstate->format, &tex->state, sizeof(uint32_t)*3);
@@ -484,7 +484,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
R300_TXO_MICRO_TILE(tex->microtile);
/* to emulate 1D textures through 2D ones correctly */
- if (tex->tex.target == PIPE_TEXTURE_1D) {
+ if (tex->b.b.target == PIPE_TEXTURE_1D) {
texstate->filter[0] &= ~R300_TX_WRAP_T_MASK;
texstate->filter[0] |= R300_TX_WRAP_T(R300_TX_CLAMP_TO_EDGE);
}
@@ -497,7 +497,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
/* determine min/max levels */
/* the MAX_MIP level is the largest (finest) one */
max_level = MIN3(sampler->max_lod + view->first_level,
- tex->tex.last_level, view->last_level);
+ tex->b.b.last_level, view->last_level);
min_level = MIN2(sampler->min_lod + view->first_level,
max_level);
texstate->format[0] |= R300_TX_NUM_LEVELS(max_level);
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 8e5afc5082..60ea763dfa 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -29,6 +29,7 @@
#include "r300_context.h"
#include "r300_texture.h"
+#include "r300_transfer.h"
#include "r300_screen.h"
#include "r300_winsys.h"
@@ -513,7 +514,7 @@ boolean r300_is_sampler_format_supported(enum pipe_format format)
static void r300_setup_texture_state(struct r300_screen* screen, struct r300_texture* tex)
{
struct r300_texture_format_state* state = &tex->state;
- struct pipe_texture *pt = &tex->tex;
+ struct pipe_resource *pt = &tex->b.b;
unsigned i;
boolean is_r500 = screen->caps.is_r500;
@@ -554,28 +555,28 @@ static void r300_setup_texture_state(struct r300_screen* screen, struct r300_tex
pt->width0, pt->height0, pt->last_level);
/* Set framebuffer state. */
- if (util_format_is_depth_or_stencil(tex->tex.format)) {
- for (i = 0; i <= tex->tex.last_level; i++) {
+ if (util_format_is_depth_or_stencil(tex->b.b.format)) {
+ for (i = 0; i <= tex->b.b.last_level; i++) {
tex->fb_state.depthpitch[i] =
tex->pitch[i] |
R300_DEPTHMACROTILE(tex->mip_macrotile[i]) |
R300_DEPTHMICROTILE(tex->microtile);
}
- tex->fb_state.zb_format = r300_translate_zsformat(tex->tex.format);
+ tex->fb_state.zb_format = r300_translate_zsformat(tex->b.b.format);
} else {
- for (i = 0; i <= tex->tex.last_level; i++) {
+ for (i = 0; i <= tex->b.b.last_level; i++) {
tex->fb_state.colorpitch[i] =
tex->pitch[i] |
- r300_translate_colorformat(tex->tex.format) |
+ r300_translate_colorformat(tex->b.b.format) |
R300_COLOR_TILE(tex->mip_macrotile[i]) |
R300_COLOR_MICROTILE(tex->microtile);
}
- tex->fb_state.us_out_fmt = r300_translate_out_fmt(tex->tex.format);
+ tex->fb_state.us_out_fmt = r300_translate_out_fmt(tex->b.b.format);
}
}
void r300_texture_reinterpret_format(struct pipe_screen *screen,
- struct pipe_texture *tex,
+ struct pipe_resource *tex,
enum pipe_format new_format)
{
struct r300_screen *r300screen = r300_screen(screen);
@@ -593,7 +594,7 @@ unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
{
unsigned offset = tex->offset[level];
- switch (tex->tex.target) {
+ switch (tex->b.b.target) {
case PIPE_TEXTURE_3D:
assert(face == 0);
return offset + zslice * tex->layer_size[level];
@@ -617,7 +618,7 @@ static unsigned r300_texture_get_tile_size(struct r300_texture* tex,
{
unsigned pixsize, tile_size;
- pixsize = util_format_get_blocksize(tex->tex.format);
+ pixsize = util_format_get_blocksize(tex->b.b.format);
tile_size = microblock_table[util_logbase2(pixsize)][tex->microtile][dim];
if (macrotile) {
@@ -638,9 +639,9 @@ static boolean r300_texture_macro_switch(struct r300_texture *tex,
tile = r300_texture_get_tile_size(tex, dim, TRUE);
if (dim == TILE_WIDTH) {
- texdim = u_minify(tex->tex.width0, level);
+ texdim = u_minify(tex->b.b.width0, level);
} else {
- texdim = u_minify(tex->tex.height0, level);
+ texdim = u_minify(tex->b.b.height0, level);
}
/* See TX_FILTER1_n.MACRO_SWITCH. */
@@ -664,22 +665,22 @@ unsigned r300_texture_get_stride(struct r300_screen* screen,
return tex->stride_override;
/* Check the level. */
- if (level > tex->tex.last_level) {
+ if (level > tex->b.b.last_level) {
SCREEN_DBG(screen, DBG_TEX, "%s: level (%u) > last_level (%u)\n",
- __FUNCTION__, level, tex->tex.last_level);
+ __FUNCTION__, level, tex->b.b.last_level);
return 0;
}
- width = u_minify(tex->tex.width0, level);
+ width = u_minify(tex->b.b.width0, level);
- if (r300_format_is_plain(tex->tex.format)) {
+ if (r300_format_is_plain(tex->b.b.format)) {
tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH,
tex->mip_macrotile[level]);
width = align(width, tile_width);
- return util_format_get_stride(tex->tex.format, width);
+ return util_format_get_stride(tex->b.b.format, width);
} else {
- return align(util_format_get_stride(tex->tex.format, width), 32);
+ return align(util_format_get_stride(tex->b.b.format, width), 32);
}
}
@@ -688,9 +689,9 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex,
{
unsigned height, tile_height;
- height = u_minify(tex->tex.height0, level);
+ height = u_minify(tex->b.b.height0, level);
- if (r300_format_is_plain(tex->tex.format)) {
+ if (r300_format_is_plain(tex->b.b.format)) {
tile_height = r300_texture_get_tile_size(tex, TILE_HEIGHT,
tex->mip_macrotile[level]);
height = align(height, tile_height);
@@ -699,13 +700,13 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex,
height = util_next_power_of_two(height);
}
- return util_format_get_nblocksy(tex->tex.format, height);
+ return util_format_get_nblocksy(tex->b.b.format, height);
}
static void r300_setup_miptree(struct r300_screen* screen,
struct r300_texture* tex)
{
- struct pipe_texture* base = &tex->tex;
+ struct pipe_resource* base = &tex->b.b;
unsigned stride, size, layer_size, nblocksy, i;
boolean rv350_mode = screen->caps.family >= CHIP_FAMILY_RV350;
@@ -744,8 +745,8 @@ static void r300_setup_miptree(struct r300_screen* screen,
static void r300_setup_flags(struct r300_texture* tex)
{
- tex->uses_pitch = !util_is_power_of_two(tex->tex.width0) ||
- !util_is_power_of_two(tex->tex.height0) ||
+ tex->uses_pitch = !util_is_power_of_two(tex->b.b.width0) ||
+ !util_is_power_of_two(tex->b.b.height0) ||
tex->stride_override;
}
@@ -753,15 +754,15 @@ static void r300_setup_tiling(struct pipe_screen *screen,
struct r300_texture *tex)
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
- enum pipe_format format = tex->tex.format;
+ enum pipe_format format = tex->b.b.format;
boolean rv350_mode = r300_screen(screen)->caps.family >= CHIP_FAMILY_RV350;
if (!r300_format_is_plain(format)) {
return;
}
- if (tex->tex.width0 == 1 ||
- tex->tex.height0 == 1) {
+ if (tex->b.b.width0 == 1 ||
+ tex->b.b.height0 == 1) {
return;
}
@@ -787,9 +788,73 @@ static void r300_setup_tiling(struct pipe_screen *screen,
}
}
+
+static unsigned r300_texture_is_referenced(struct pipe_context *context,
+ struct pipe_resource *texture,
+ unsigned face, unsigned level)
+{
+ struct r300_context *r300 = r300_context(context);
+ struct r300_texture *rtex = (struct r300_texture *)texture;
+
+ if (r300->rws->is_buffer_referenced(r300->rws, rtex->buffer))
+ return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+
+ return PIPE_UNREFERENCED;
+}
+
+static void r300_texture_destroy(struct pipe_screen *screen,
+ struct pipe_resource* texture)
+{
+ struct r300_texture* tex = (struct r300_texture*)texture;
+ struct r300_winsys_screen *rws = (struct r300_winsys_screen *)texture->screen->winsys;
+
+ rws->buffer_reference(rws, &tex->buffer, NULL);
+ FREE(tex);
+}
+
+
+
+
+static boolean
+ r300_texture_get_handle(struct pipe_screen* screen,
+ struct pipe_resource *texture,
+ struct winsys_handle *whandle)
+{
+ struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
+ struct r300_texture* tex = (struct r300_texture*)texture;
+ unsigned stride;
+
+ if (!tex) {
+ return FALSE;
+ }
+
+ stride = r300_texture_get_stride(r300_screen(screen), tex, 0);
+
+ rws->buffer_get_handle(rws, tex->buffer, stride, whandle);
+
+ return TRUE;
+}
+
+
+
+struct u_resource_vtbl r300_texture_vtbl =
+{
+ r300_texture_get_handle, /* get_handle */
+ r300_texture_destroy, /* resource_destroy */
+ r300_texture_is_referenced, /* is_resource_referenced */
+ r300_texture_get_transfer, /* get_transfer */
+ r300_texture_transfer_destroy, /* transfer_destroy */
+ r300_texture_transfer_map, /* transfer_map */
+ u_default_transfer_flush_region, /* transfer_flush_region */
+ r300_texture_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
/* Create a new texture. */
-static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
- const struct pipe_texture* base)
+struct pipe_resource* r300_texture_create(struct pipe_screen* screen,
+ const struct pipe_resource* base)
{
struct r300_texture* tex = CALLOC_STRUCT(r300_texture);
struct r300_screen* rscreen = r300_screen(screen);
@@ -799,20 +864,21 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
return NULL;
}
- tex->tex = *base;
- pipe_reference_init(&tex->tex.reference, 1);
- tex->tex.screen = screen;
+ tex->b.b = *base;
+ tex->b.vtbl = &r300_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
r300_setup_flags(tex);
- if (!(base->tex_usage & R300_TEXTURE_USAGE_TRANSFER) &&
- !(base->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT)) {
+ if (!(base->flags & R300_RESOURCE_FLAG_TRANSFER) &&
+ !(base->bind & PIPE_BIND_SCANOUT)) {
r300_setup_tiling(screen, tex);
}
r300_setup_miptree(rscreen, tex);
r300_setup_texture_state(rscreen, tex);
tex->buffer = rws->buffer_create(rws, 2048,
- PIPE_BUFFER_USAGE_PIXEL,
+ PIPE_BIND_SAMPLER_VIEW, /* XXX */
tex->size);
rws->buffer_set_tiling(rws, tex->buffer,
tex->pitch[0],
@@ -824,24 +890,19 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
return NULL;
}
- return (struct pipe_texture*)tex;
+ return (struct pipe_resource*)tex;
}
-static void r300_texture_destroy(struct pipe_texture* texture)
-{
- struct r300_texture* tex = r300_texture(texture);
- struct r300_winsys_screen *rws = (struct r300_winsys_screen *)texture->screen->winsys;
- rws->buffer_reference(rws, &tex->buffer, NULL);
- FREE(tex);
-}
-static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
- struct pipe_texture* texture,
- unsigned face,
- unsigned level,
- unsigned zslice,
- unsigned flags)
+/* Not required to implement u_resource_vtbl, consider moving to another file:
+ */
+struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
+ struct pipe_resource* texture,
+ unsigned face,
+ unsigned level,
+ unsigned zslice,
+ unsigned flags)
{
struct r300_texture* tex = r300_texture(texture);
struct pipe_surface* surface = CALLOC_STRUCT(pipe_surface);
@@ -851,7 +912,7 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
if (surface) {
pipe_reference_init(&surface->reference, 1);
- pipe_texture_reference(&surface->texture, texture);
+ pipe_resource_reference(&surface->texture, texture);
surface->format = texture->format;
surface->width = u_minify(texture->width0, level);
surface->height = u_minify(texture->height0, level);
@@ -866,17 +927,18 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
return surface;
}
-static void r300_tex_surface_destroy(struct pipe_surface* s)
+/* Not required to implement u_resource_vtbl, consider moving to another file:
+ */
+void r300_tex_surface_destroy(struct pipe_surface* s)
{
- pipe_texture_reference(&s->texture, NULL);
+ pipe_resource_reference(&s->texture, NULL);
FREE(s);
}
-
-static struct pipe_texture*
- r300_texture_from_handle(struct pipe_screen* screen,
- const struct pipe_texture* base,
- struct winsys_handle *whandle)
+struct pipe_resource*
+r300_texture_from_handle(struct pipe_screen* screen,
+ const struct pipe_resource* base,
+ struct winsys_handle *whandle)
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen*)screen->winsys;
struct r300_screen* rscreen = r300_screen(screen);
@@ -902,9 +964,10 @@ static struct pipe_texture*
return NULL;
}
- tex->tex = *base;
- pipe_reference_init(&tex->tex.reference, 1);
- tex->tex.screen = screen;
+ tex->b.b = *base;
+ tex->b.vtbl = &r300_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
tex->stride_override = stride;
@@ -945,109 +1008,6 @@ static struct pipe_texture*
tex->microtile,
tex->macrotile);
}
- return (struct pipe_texture*)tex;
-}
-
-static boolean
- r300_texture_get_handle(struct pipe_screen* screen,
- struct pipe_texture *texture,
- struct winsys_handle *whandle)
-{
- struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
- struct r300_texture* tex = r300_texture(texture);
- unsigned stride;
-
- if (!tex) {
- return FALSE;
- }
-
- stride = r300_texture_get_stride(r300_screen(screen), tex, 0);
-
- rws->buffer_get_handle(rws, tex->buffer, stride, whandle);
-
- return TRUE;
+ return (struct pipe_resource*)tex;
}
-static struct pipe_video_surface *
-r300_video_surface_create(struct pipe_screen *screen,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
-{
- struct r300_video_surface *r300_vsfc;
- struct pipe_texture base;
-
- assert(screen);
- assert(width && height);
-
- r300_vsfc = CALLOC_STRUCT(r300_video_surface);
- if (!r300_vsfc)
- return NULL;
-
- pipe_reference_init(&r300_vsfc->base.reference, 1);
- r300_vsfc->base.screen = screen;
- r300_vsfc->base.chroma_format = chroma_format;
- r300_vsfc->base.width = width;
- r300_vsfc->base.height = height;
-
- memset(&base, 0, sizeof(struct pipe_texture));
- base.target = PIPE_TEXTURE_2D;
- base.format = PIPE_FORMAT_B8G8R8X8_UNORM;
- base.last_level = 0;
- base.width0 = util_next_power_of_two(width);
- base.height0 = util_next_power_of_two(height);
- base.depth0 = 1;
- base.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER |
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
-
- r300_vsfc->tex = screen->texture_create(screen, &base);
- if (!r300_vsfc->tex)
- {
- FREE(r300_vsfc);
- return NULL;
- }
-
- return &r300_vsfc->base;
-}
-
-static void r300_video_surface_destroy(struct pipe_video_surface *vsfc)
-{
- struct r300_video_surface *r300_vsfc = r300_video_surface(vsfc);
- pipe_texture_reference(&r300_vsfc->tex, NULL);
- FREE(r300_vsfc);
-}
-
-void r300_init_screen_texture_functions(struct pipe_screen* screen)
-{
- screen->texture_create = r300_texture_create;
- screen->texture_from_handle = r300_texture_from_handle;
- screen->texture_get_handle = r300_texture_get_handle;
- screen->texture_destroy = r300_texture_destroy;
- screen->get_tex_surface = r300_get_tex_surface;
- screen->tex_surface_destroy = r300_tex_surface_destroy;
-
- screen->video_surface_create = r300_video_surface_create;
- screen->video_surface_destroy= r300_video_surface_destroy;
-}
-
-boolean r300_get_texture_buffer(struct pipe_screen* screen,
- struct pipe_texture* texture,
- struct r300_winsys_buffer** buffer,
- unsigned* stride)
-{
- struct r300_texture* tex = r300_texture(texture);
- struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
- struct r300_winsys_buffer *buf;
-
- if (!tex) {
- return FALSE;
- }
-
- rws->buffer_reference(rws, &buf, tex->buffer);
-
- if (stride) {
- *stride = r300_texture_get_stride(r300_screen(screen), tex, 0);
- }
-
- *buffer = buf;
- return TRUE;
-}
diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
index 60c7fa8342..a545a0f221 100644
--- a/src/gallium/drivers/r300/r300_texture.h
+++ b/src/gallium/drivers/r300/r300_texture.h
@@ -23,15 +23,12 @@
#ifndef R300_TEXTURE_H
#define R300_TEXTURE_H
-#include "pipe/p_video_state.h"
#include "util/u_format.h"
#include "r300_reg.h"
struct r300_texture;
-void r300_init_screen_texture_functions(struct pipe_screen* screen);
-
unsigned r300_texture_get_stride(struct r300_screen* screen,
struct r300_texture* tex, unsigned level);
@@ -39,7 +36,7 @@ unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
unsigned zslice, unsigned face);
void r300_texture_reinterpret_format(struct pipe_screen *screen,
- struct pipe_texture *tex,
+ struct pipe_resource *tex,
enum pipe_format new_format);
boolean r300_is_colorbuffer_format_supported(enum pipe_format format);
@@ -48,23 +45,24 @@ boolean r300_is_zs_format_supported(enum pipe_format format);
boolean r300_is_sampler_format_supported(enum pipe_format format);
-struct r300_video_surface
-{
- struct pipe_video_surface base;
- struct pipe_texture *tex;
-};
-
-static INLINE struct r300_video_surface *
-r300_video_surface(struct pipe_video_surface *pvs)
-{
- return (struct r300_video_surface *)pvs;
-}
-
-/* Used internally for texture_is_referenced()
- */
-boolean r300_get_texture_buffer(struct pipe_screen* screen,
- struct pipe_texture *texture,
- struct r300_winsys_buffer** buffer,
- unsigned* stride);
+
+struct pipe_resource*
+r300_texture_from_handle(struct pipe_screen* screen,
+ const struct pipe_resource* base,
+ struct winsys_handle *whandle);
+
+struct pipe_resource*
+r300_texture_create(struct pipe_screen* screen,
+ const struct pipe_resource* template);
+
+
+struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
+ struct pipe_resource* texture,
+ unsigned face,
+ unsigned level,
+ unsigned zslice,
+ unsigned flags);
+
+void r300_tex_surface_destroy(struct pipe_surface* s);
#endif /* R300_TEXTURE_H */
diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c
index 3cc86bad38..8dc705a7d4 100644
--- a/src/gallium/drivers/r300/r300_transfer.c
+++ b/src/gallium/drivers/r300/r300_transfer.c
@@ -38,9 +38,6 @@ struct r300_transfer {
/* Pipe context. */
struct pipe_context *ctx;
- /* Parameters of get_tex_transfer. */
- unsigned x, y, level, zslice, face;
-
/* Offset from start of buffer. */
unsigned offset;
@@ -48,7 +45,7 @@ struct r300_transfer {
struct r300_texture *detiled_texture;
/* Transfer and format flags. */
- unsigned buffer_usage, render_target_usage;
+ unsigned render_target_usage;
};
/* Convenience cast wrapper. */
@@ -64,22 +61,22 @@ static void r300_copy_from_tiled_texture(struct pipe_context *ctx,
{
struct pipe_screen *screen = ctx->screen;
struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer;
- struct pipe_texture *tex = transfer->texture;
+ struct pipe_resource *tex = transfer->resource;
struct pipe_surface *src, *dst;
- src = screen->get_tex_surface(screen, tex, r300transfer->face,
- r300transfer->level, r300transfer->zslice,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_PIXEL);
+ src = screen->get_tex_surface(screen, tex,
+ transfer->sr.face,
+ transfer->sr.level,
+ transfer->box.z,
+ PIPE_BIND_BLIT_SOURCE);
- dst = screen->get_tex_surface(screen, &r300transfer->detiled_texture->tex,
+ dst = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE |
- PIPE_BUFFER_USAGE_PIXEL |
- r300transfer->buffer_usage);
+ PIPE_BIND_BLIT_DESTINATION);
- ctx->surface_copy(ctx, dst, 0, 0, src, r300transfer->x, r300transfer->y,
- transfer->width, transfer->height);
+ ctx->surface_copy(ctx, dst, 0, 0, src,
+ transfer->box.x, transfer->box.y,
+ transfer->box.width, transfer->box.height);
pipe_surface_reference(&src, NULL);
pipe_surface_reference(&dst, NULL);
@@ -91,26 +88,28 @@ static void r300_copy_into_tiled_texture(struct pipe_context *ctx,
{
struct pipe_screen *screen = ctx->screen;
struct pipe_transfer *transfer = (struct pipe_transfer*)r300transfer;
- struct pipe_texture *tex = transfer->texture;
+ struct pipe_resource *tex = transfer->resource;
struct pipe_surface *src, *dst;
- src = screen->get_tex_surface(screen, &r300transfer->detiled_texture->tex,
+ src = screen->get_tex_surface(screen, &r300transfer->detiled_texture->b.b,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_PIXEL);
+ PIPE_BIND_BLIT_SOURCE);
- dst = screen->get_tex_surface(screen, tex, r300transfer->face,
- r300transfer->level, r300transfer->zslice,
- PIPE_BUFFER_USAGE_GPU_WRITE |
- PIPE_BUFFER_USAGE_PIXEL);
+ dst = screen->get_tex_surface(screen, tex,
+ transfer->sr.face,
+ transfer->sr.level,
+ transfer->box.z,
+ PIPE_BIND_BLIT_DESTINATION);
/* XXX this flush prevents the following DRM error from occuring:
* [drm:radeon_cs_ioctl] *ERROR* Failed to parse relocation !
* Reproducible with perf/copytex. */
ctx->flush(ctx, 0, NULL);
- ctx->surface_copy(ctx, dst, r300transfer->x, r300transfer->y, src, 0, 0,
- transfer->width, transfer->height);
+ ctx->surface_copy(ctx, dst,
+ transfer->box.x, transfer->box.y,
+ src, 0, 0,
+ transfer->box.width, transfer->box.height);
/* XXX this flush fixes a few piglit tests (e.g. glean/pixelFormats). */
ctx->flush(ctx, 0, NULL);
@@ -119,72 +118,71 @@ static void r300_copy_into_tiled_texture(struct pipe_context *ctx,
pipe_surface_reference(&dst, NULL);
}
-static struct pipe_transfer*
-r300_get_tex_transfer(struct pipe_context *ctx,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage, unsigned x, unsigned y,
- unsigned w, unsigned h)
+struct pipe_transfer*
+r300_texture_get_transfer(struct pipe_context *ctx,
+ struct pipe_resource *texture,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
struct r300_texture *tex = r300_texture(texture);
struct r300_screen *r300screen = r300_screen(ctx->screen);
struct r300_transfer *trans;
- struct pipe_texture base;
+ struct pipe_resource base;
trans = CALLOC_STRUCT(r300_transfer);
if (trans) {
/* Initialize the transfer object. */
- pipe_texture_reference(&trans->transfer.texture, texture);
+ pipe_resource_reference(&trans->transfer.resource, texture);
+ trans->transfer.sr = sr;
trans->transfer.usage = usage;
- trans->transfer.width = w;
- trans->transfer.height = h;
+ trans->transfer.box = *box;
trans->ctx = ctx;
- trans->x = x;
- trans->y = y;
- trans->level = level;
- trans->zslice = zslice;
- trans->face = face;
/* If the texture is tiled, we must create a temporary detiled texture
* for this transfer. */
if (tex->microtile || tex->macrotile) {
- trans->buffer_usage = pipe_transfer_buffer_flags(&trans->transfer);
trans->render_target_usage =
util_format_is_depth_or_stencil(texture->format) ?
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ PIPE_BIND_DEPTH_STENCIL :
+ PIPE_BIND_RENDER_TARGET;
base.target = PIPE_TEXTURE_2D;
base.format = texture->format;
- base.width0 = w;
- base.height0 = h;
+ base.width0 = box->width;
+ base.height0 = box->height;
base.depth0 = 0;
base.last_level = 0;
base.nr_samples = 0;
- base.tex_usage = PIPE_TEXTURE_USAGE_DYNAMIC |
- R300_TEXTURE_USAGE_TRANSFER;
+ base._usage = PIPE_USAGE_DYNAMIC;
+ base.flags = R300_RESOURCE_FLAG_TRANSFER;
/* For texture reading, the temporary (detiled) texture is used as
* a render target when blitting from a tiled texture. */
if (usage & PIPE_TRANSFER_READ) {
- base.tex_usage |= trans->render_target_usage;
+ base.bind |= trans->render_target_usage;
}
/* For texture writing, the temporary texture is used as a sampler
* when blitting into a tiled texture. */
if (usage & PIPE_TRANSFER_WRITE) {
- base.tex_usage |= PIPE_TEXTURE_USAGE_SAMPLER;
+ base.bind |= PIPE_BIND_SAMPLER_VIEW;
}
/* Create the temporary texture. */
trans->detiled_texture = r300_texture(
- ctx->screen->texture_create(ctx->screen,
- &base));
+ ctx->screen->resource_create(ctx->screen,
+ &base));
assert(!trans->detiled_texture->microtile &&
!trans->detiled_texture->macrotile);
/* Set the stride.
- * Parameters x, y, level, zslice, and face remain zero. */
+ *
+ * Even though we are using an internal texture for this,
+ * the transfer sr, box and usage parameters still reflect
+ * the arguments received to get_transfer. We just do the
+ * right thing internally.
+ */
trans->transfer.stride =
r300_texture_get_stride(r300screen, trans->detiled_texture, 0);
@@ -194,21 +192,16 @@ r300_get_tex_transfer(struct pipe_context *ctx,
r300_copy_from_tiled_texture(ctx, trans);
}
} else {
- trans->transfer.x = x;
- trans->transfer.y = y;
trans->transfer.stride =
- r300_texture_get_stride(r300screen, tex, level);
- trans->transfer.level = level;
- trans->transfer.zslice = zslice;
- trans->transfer.face = face;
- trans->offset = r300_texture_get_offset(tex, level, zslice, face);
+ r300_texture_get_stride(r300screen, tex, sr.level);
+ trans->offset = r300_texture_get_offset(tex, sr.level, box->z, sr.face);
}
}
return &trans->transfer;
}
-static void r300_tex_transfer_destroy(struct pipe_context *ctx,
- struct pipe_transfer *trans)
+void r300_texture_transfer_destroy(struct pipe_context *ctx,
+ struct pipe_transfer *trans)
{
struct r300_transfer *r300transfer = r300_transfer(trans);
@@ -217,49 +210,49 @@ static void r300_tex_transfer_destroy(struct pipe_context *ctx,
r300_copy_into_tiled_texture(r300transfer->ctx, r300transfer);
}
- pipe_texture_reference(
- (struct pipe_texture**)&r300transfer->detiled_texture, NULL);
+ pipe_resource_reference(
+ (struct pipe_resource**)&r300transfer->detiled_texture, NULL);
}
- pipe_texture_reference(&trans->texture, NULL);
+ pipe_resource_reference(&trans->resource, NULL);
FREE(trans);
}
-static void* r300_transfer_map(struct pipe_context *ctx,
- struct pipe_transfer *transfer)
+void* r300_texture_transfer_map(struct pipe_context *ctx,
+ struct pipe_transfer *transfer)
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
struct r300_transfer *r300transfer = r300_transfer(transfer);
- struct r300_texture *tex = r300_texture(transfer->texture);
+ struct r300_texture *tex = r300_texture(transfer->resource);
char *map;
- enum pipe_format format = tex->tex.format;
+ enum pipe_format format = tex->b.b.format;
if (r300transfer->detiled_texture) {
/* The detiled texture is of the same size as the region being mapped
* (no offset needed). */
return rws->buffer_map(rws,
r300transfer->detiled_texture->buffer,
- pipe_transfer_buffer_flags(transfer));
+ transfer->usage);
} else {
/* Tiling is disabled. */
map = rws->buffer_map(rws, tex->buffer,
- pipe_transfer_buffer_flags(transfer));
+ transfer->usage);
if (!map) {
return NULL;
}
return map + r300_transfer(transfer)->offset +
- transfer->y / util_format_get_blockheight(format) * transfer->stride +
- transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+ transfer->box.y / util_format_get_blockheight(format) * transfer->stride +
+ transfer->box.x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
}
}
-static void r300_transfer_unmap(struct pipe_context *ctx,
- struct pipe_transfer *transfer)
+void r300_texture_transfer_unmap(struct pipe_context *ctx,
+ struct pipe_transfer *transfer)
{
struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
struct r300_transfer *r300transfer = r300_transfer(transfer);
- struct r300_texture *tex = r300_texture(transfer->texture);
+ struct r300_texture *tex = r300_texture(transfer->resource);
if (r300transfer->detiled_texture) {
rws->buffer_unmap(rws, r300transfer->detiled_texture->buffer);
@@ -268,13 +261,3 @@ static void r300_transfer_unmap(struct pipe_context *ctx,
}
}
-
-void r300_init_transfer_functions( struct r300_context *r300ctx )
-{
- struct pipe_context *ctx = &r300ctx->context;
-
- ctx->get_tex_transfer = r300_get_tex_transfer;
- ctx->tex_transfer_destroy = r300_tex_transfer_destroy;
- ctx->transfer_map = r300_transfer_map;
- ctx->transfer_unmap = r300_transfer_unmap;
-}
diff --git a/src/gallium/drivers/r300/r300_transfer.h b/src/gallium/drivers/r300/r300_transfer.h
index 79baf6d048..d72e54e5ed 100644
--- a/src/gallium/drivers/r300/r300_transfer.h
+++ b/src/gallium/drivers/r300/r300_transfer.h
@@ -28,6 +28,24 @@
struct r300_context;
-void r300_init_transfer_functions(struct r300_context *r300ctx);
+struct pipe_transfer*
+r300_texture_get_transfer(struct pipe_context *ctx,
+ struct pipe_resource *texture,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box);
+
+void
+r300_texture_transfer_destroy(struct pipe_context *ctx,
+ struct pipe_transfer *trans);
+
+void*
+r300_texture_transfer_map(struct pipe_context *ctx,
+ struct pipe_transfer *transfer);
+
+void
+r300_texture_transfer_unmap(struct pipe_context *ctx,
+ struct pipe_transfer *transfer);
+
#endif
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index d8d0c609d2..80abaef4ba 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -39,11 +39,12 @@ struct pipe_screen* r300_create_screen(struct r300_winsys_screen *rws);
struct r300_winsys_buffer;
+/* XXX: this is just a bandaid on larger problems in
+ * r300_screen_buffer.h which doesn't seem to be fully ported to
+ * gallium-resources.
+ */
+#define R300_BIND_OQBO (1<<21)
-boolean r300_get_texture_buffer(struct pipe_screen* screen,
- struct pipe_texture* texture,
- struct r300_winsys_buffer** buffer,
- unsigned *stride);
enum r300_value_id {
R300_VID_PCI_ID,
@@ -100,7 +101,7 @@ struct r300_winsys_screen {
unsigned offset,
unsigned length);
- /* Add a pipe_buffer to the list of buffer objects to validate. */
+ /* Add a pipe_resource to the list of buffer objects to validate. */
boolean (*add_buffer)(struct r300_winsys_screen *winsys,
struct r300_winsys_buffer *buf,
uint32_t rd,
diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile
index 239655d628..83f3e4a19b 100644
--- a/src/gallium/drivers/softpipe/Makefile
+++ b/src/gallium/drivers/softpipe/Makefile
@@ -6,7 +6,6 @@ LIBNAME = softpipe
C_SOURCES = \
sp_fs_exec.c \
sp_fs_sse.c \
- sp_buffer.c \
sp_clear.c \
sp_fence.c \
sp_flush.c \
@@ -33,7 +32,6 @@ C_SOURCES = \
sp_tex_sample.c \
sp_tex_tile_cache.c \
sp_tile_cache.c \
- sp_surface.c \
- sp_video_context.c
+ sp_surface.c
include ../../Makefile.template
diff --git a/src/gallium/drivers/softpipe/SConscript b/src/gallium/drivers/softpipe/SConscript
index 9949a53adf..b80c6dea93 100644
--- a/src/gallium/drivers/softpipe/SConscript
+++ b/src/gallium/drivers/softpipe/SConscript
@@ -7,7 +7,6 @@ softpipe = env.ConvenienceLibrary(
source = [
'sp_fs_exec.c',
'sp_fs_sse.c',
- 'sp_buffer.c',
'sp_clear.c',
'sp_context.c',
'sp_draw_arrays.c',
@@ -35,7 +34,6 @@ softpipe = env.ConvenienceLibrary(
'sp_tex_tile_cache.c',
'sp_texture.c',
'sp_tile_cache.c',
- 'sp_video_context.c'
])
Export('softpipe')
diff --git a/src/gallium/drivers/softpipe/sp_buffer.c b/src/gallium/drivers/softpipe/sp_buffer.c
deleted file mode 100644
index 8f39025086..0000000000
--- a/src/gallium/drivers/softpipe/sp_buffer.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_math.h"
-
-#include "sp_screen.h"
-#include "sp_buffer.h"
-
-
-static void *
-softpipe_buffer_map(struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned flags)
-{
- struct softpipe_buffer *softpipe_buf = softpipe_buffer(buf);
- return softpipe_buf->data;
-}
-
-
-static void
-softpipe_buffer_unmap(struct pipe_screen *screen,
- struct pipe_buffer *buf)
-{
-}
-
-
-static void
-softpipe_buffer_destroy(struct pipe_buffer *buf)
-{
- struct softpipe_buffer *sbuf = softpipe_buffer(buf);
-
- if (!sbuf->userBuffer)
- align_free(sbuf->data);
-
- FREE(sbuf);
-}
-
-
-static struct pipe_buffer *
-softpipe_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct softpipe_buffer *buffer = CALLOC_STRUCT(softpipe_buffer);
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.screen = screen;
- buffer->base.alignment = MAX2(alignment, 16);
- buffer->base.usage = usage;
- buffer->base.size = size;
-
- buffer->data = align_malloc(size, alignment);
-
- return &buffer->base;
-}
-
-
-/**
- * Create buffer which wraps user-space data.
- */
-static struct pipe_buffer *
-softpipe_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct softpipe_buffer *buffer;
-
- buffer = CALLOC_STRUCT(softpipe_buffer);
- if(!buffer)
- return NULL;
-
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.screen = screen;
- buffer->base.size = bytes;
- buffer->userBuffer = TRUE;
- buffer->data = ptr;
-
- return &buffer->base;
-}
-
-
-void
-softpipe_init_screen_buffer_funcs(struct pipe_screen *screen)
-{
- screen->buffer_create = softpipe_buffer_create;
- screen->user_buffer_create = softpipe_user_buffer_create;
- screen->buffer_map = softpipe_buffer_map;
- screen->buffer_unmap = softpipe_buffer_unmap;
- screen->buffer_destroy = softpipe_buffer_destroy;
-}
diff --git a/src/gallium/drivers/softpipe/sp_buffer.h b/src/gallium/drivers/softpipe/sp_buffer.h
deleted file mode 100644
index 9d8e56a176..0000000000
--- a/src/gallium/drivers/softpipe/sp_buffer.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef SP_BUFFER_H
-#define SP_BUFFER_H
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-
-struct softpipe_buffer
-{
- struct pipe_buffer base;
- boolean userBuffer; /** Is this a user-space buffer? */
- void *data;
-};
-
-
-/** Cast wrapper */
-static INLINE struct softpipe_buffer *
-softpipe_buffer( struct pipe_buffer *buf )
-{
- return (struct softpipe_buffer *)buf;
-}
-
-
-void
-softpipe_init_screen_buffer_funcs(struct pipe_screen *screen);
-
-
-#endif /* SP_BUFFER_H */
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 937a573092..d0c2978c24 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -117,7 +117,7 @@ softpipe_destroy( struct pipe_context *pipe )
for (j = 0; j < PIPE_MAX_CONSTANT_BUFFERS; j++) {
if (softpipe->constants[i][j]) {
- pipe_buffer_reference(&softpipe->constants[i][j], NULL);
+ pipe_resource_reference(&softpipe->constants[i][j], NULL);
}
}
}
@@ -135,13 +135,16 @@ softpipe_destroy( struct pipe_context *pipe )
* return PIPE_UNREFERENCED
*/
static unsigned int
-softpipe_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
+softpipe_is_resource_referenced( struct pipe_context *pipe,
+ struct pipe_resource *texture,
unsigned face, unsigned level)
{
struct softpipe_context *softpipe = softpipe_context( pipe );
unsigned i;
+ if (texture->target == PIPE_BUFFER)
+ return PIPE_UNREFERENCED;
+
/* check if any of the bound drawing surfaces are this texture */
if (softpipe->dirty_render_cache) {
for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) {
@@ -172,12 +175,6 @@ softpipe_is_texture_referenced( struct pipe_context *pipe,
}
-static unsigned int
-softpipe_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-{
- return PIPE_UNREFERENCED;
-}
static void
@@ -274,8 +271,7 @@ softpipe_create_context( struct pipe_screen *screen,
softpipe->pipe.clear = softpipe_clear;
softpipe->pipe.flush = softpipe_flush;
- softpipe->pipe.is_texture_referenced = softpipe_is_texture_referenced;
- softpipe->pipe.is_buffer_referenced = softpipe_is_buffer_referenced;
+ softpipe->pipe.is_resource_referenced = softpipe_is_resource_referenced;
softpipe_init_query_funcs( softpipe );
softpipe_init_texture_funcs( &softpipe->pipe );
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index 75e03c8ae6..be8f2cb3e0 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -66,7 +66,7 @@ struct softpipe_context {
struct pipe_blend_color blend_color;
struct pipe_stencil_ref stencil_ref;
struct pipe_clip_state clip;
- struct pipe_buffer *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
+ struct pipe_resource *constants[PIPE_SHADER_TYPES][PIPE_MAX_CONSTANT_BUFFERS];
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 7b77eb239f..461c9a6c4d 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -39,7 +39,7 @@
#include "sp_context.h"
#include "sp_query.h"
#include "sp_state.h"
-#include "sp_buffer.h"
+#include "sp_texture.h"
#include "draw/draw_context.h"
@@ -55,7 +55,7 @@
*/
static void
softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -85,7 +85,7 @@ softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
void
softpipe_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
@@ -106,7 +106,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
void
softpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
@@ -144,7 +144,7 @@ softpipe_draw_arrays_instanced(struct pipe_context *pipe,
void
softpipe_draw_elements_instanced(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode,
unsigned start,
@@ -166,7 +166,7 @@ softpipe_draw_elements_instanced(struct pipe_context *pipe,
static void
softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -193,13 +193,13 @@ softpipe_draw_range_elements_instanced(struct pipe_context *pipe,
/* Map vertex buffers */
for (i = 0; i < sp->num_vertex_buffers; i++) {
- void *buf = softpipe_buffer(sp->vertex_buffer[i].buffer)->data;
+ void *buf = softpipe_resource(sp->vertex_buffer[i].buffer)->data;
draw_set_mapped_vertex_buffer(draw, i, buf);
}
/* Map index buffer, if present */
if (indexBuffer) {
- void *mapped_indexes = softpipe_buffer(indexBuffer)->data;
+ void *mapped_indexes = softpipe_resource(indexBuffer)->data;
draw_set_mapped_element_buffer_range(draw,
indexSize,
minIndex,
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index be64048abf..7b1e058ac8 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -36,7 +36,6 @@
#include "sp_texture.h"
#include "sp_screen.h"
#include "sp_context.h"
-#include "sp_buffer.h"
#include "sp_fence.h"
#include "sp_public.h"
@@ -174,9 +173,9 @@ softpipe_is_format_supported( struct pipe_screen *screen,
break;
}
- if(tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) {
+ if(tex_usage & (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) {
if(!winsys->is_displaytarget_format_supported(winsys, tex_usage, format))
return FALSE;
}
@@ -209,7 +208,7 @@ softpipe_flush_frontbuffer(struct pipe_screen *_screen,
{
struct softpipe_screen *screen = softpipe_screen(_screen);
struct sw_winsys *winsys = screen->winsys;
- struct softpipe_texture *texture = softpipe_texture(surface->texture);
+ struct softpipe_resource *texture = softpipe_resource(surface->texture);
assert(texture->dt);
if (texture->dt)
@@ -244,7 +243,6 @@ softpipe_create_screen(struct sw_winsys *winsys)
util_format_s3tc_init();
softpipe_init_screen_texture_funcs(&screen->base);
- softpipe_init_screen_buffer_funcs(&screen->base);
softpipe_init_screen_fence_funcs(&screen->base);
return &screen->base;
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index ade96b0fd4..3c04c8bb07 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -150,7 +150,7 @@ void softpipe_set_clip_state( struct pipe_context *,
void softpipe_set_constant_buffer(struct pipe_context *,
uint shader, uint index,
- struct pipe_buffer *buf);
+ struct pipe_resource *buf);
void *softpipe_create_fs_state(struct pipe_context *,
const struct pipe_shader_state *);
@@ -188,7 +188,7 @@ softpipe_set_vertex_sampler_views(struct pipe_context *,
struct pipe_sampler_view *
softpipe_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ);
void
@@ -210,12 +210,12 @@ void softpipe_draw_arrays(struct pipe_context *pipe, unsigned mode,
unsigned start, unsigned count);
void softpipe_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count);
void
softpipe_draw_range_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
@@ -231,7 +231,7 @@ softpipe_draw_arrays_instanced(struct pipe_context *pipe,
void
softpipe_draw_elements_instanced(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode,
unsigned start,
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index d2eda7324c..4c6d4909f5 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -202,7 +202,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe )
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
struct softpipe_tex_tile_cache *tc = softpipe->tex_cache[i];
if (tc->texture) {
- struct softpipe_texture *spt = softpipe_texture(tc->texture);
+ struct softpipe_resource *spt = softpipe_resource(tc->texture);
if (spt->timestamp != tc->timestamp) {
sp_tex_tile_cache_validate_texture( tc );
/*
@@ -217,7 +217,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe )
struct softpipe_tex_tile_cache *tc = softpipe->vertex_tex_cache[i];
if (tc->texture) {
- struct softpipe_texture *spt = softpipe_texture(tc->texture);
+ struct softpipe_resource *spt = softpipe_resource(tc->texture);
if (spt->timestamp != tc->timestamp) {
sp_tex_tile_cache_validate_texture(tc);
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index d6f3229bed..7f072f5a26 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -28,7 +28,7 @@
#include "sp_context.h"
#include "sp_state.h"
#include "sp_fs.h"
-#include "sp_buffer.h"
+#include "sp_texture.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
@@ -167,11 +167,11 @@ softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
void
softpipe_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *constants)
+ struct pipe_resource *constants)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- unsigned size = constants ? constants->size : 0;
- const void *data = constants ? softpipe_buffer(constants)->data : NULL;
+ unsigned size = constants ? constants->width0 : 0;
+ const void *data = constants ? softpipe_resource(constants)->data : NULL;
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
@@ -179,7 +179,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
draw_flush(softpipe->draw);
/* note: reference counting */
- pipe_buffer_reference(&softpipe->constants[shader][index], constants);
+ pipe_resource_reference(&softpipe->constants[shader][index], constants);
if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) {
draw_set_mapped_constant_buffer(softpipe->draw, shader, index, data, size);
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index d501952bba..2692f06c92 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -30,6 +30,7 @@
*/
#include "util/u_memory.h"
+#include "util/u_inlines.h"
#include "draw/draw_context.h"
#include "draw/draw_context.h"
@@ -123,7 +124,7 @@ softpipe_bind_vertex_sampler_states(struct pipe_context *pipe,
struct pipe_sampler_view *
softpipe_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *resource,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -132,7 +133,7 @@ softpipe_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, resource);
view->context = pipe;
}
@@ -144,7 +145,7 @@ void
softpipe_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
@@ -223,10 +224,10 @@ softpipe_set_vertex_sampler_views(struct pipe_context *pipe,
static struct sp_sampler_varient *
get_sampler_varient( unsigned unit,
struct sp_sampler *sampler,
- struct pipe_texture *texture,
+ struct pipe_resource *resource,
unsigned processor )
{
- struct softpipe_texture *sp_texture = softpipe_texture(texture);
+ struct softpipe_resource *sp_texture = softpipe_resource(resource);
struct sp_sampler_varient *v = NULL;
union sp_sampler_key key;
@@ -274,7 +275,7 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe)
*/
for (i = 0; i <= softpipe->vs->max_sampler; i++) {
if (softpipe->vertex_samplers[i]) {
- struct pipe_texture *texture = NULL;
+ struct pipe_resource *texture = NULL;
if (softpipe->vertex_sampler_views[i]) {
texture = softpipe->vertex_sampler_views[i]->texture;
@@ -294,7 +295,7 @@ softpipe_reset_sampler_varients(struct softpipe_context *softpipe)
for (i = 0; i <= softpipe->fs->info.file_max[TGSI_FILE_SAMPLER]; i++) {
if (softpipe->sampler[i]) {
- struct pipe_texture *texture = NULL;
+ struct pipe_resource *texture = NULL;
if (softpipe->sampler_views[i]) {
texture = softpipe->sampler_views[i]->texture;
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index fa9e19b282..ff83c66d8b 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -547,7 +547,7 @@ compute_lambda_1d(const struct sp_sampler_varient *samp,
const float t[QUAD_SIZE],
const float p[QUAD_SIZE])
{
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]);
float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]);
float rho = MAX2(dsdx, dsdy) * texture->width0;
@@ -562,7 +562,7 @@ compute_lambda_2d(const struct sp_sampler_varient *samp,
const float t[QUAD_SIZE],
const float p[QUAD_SIZE])
{
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]);
float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]);
float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]);
@@ -581,7 +581,7 @@ compute_lambda_3d(const struct sp_sampler_varient *samp,
const float t[QUAD_SIZE],
const float p[QUAD_SIZE])
{
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]);
float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]);
float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]);
@@ -651,7 +651,7 @@ static INLINE const float *
get_texel_2d(const struct sp_sampler_varient *samp,
union tex_tile_address addr, int x, int y)
{
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level = addr.bits.level;
if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
@@ -744,7 +744,7 @@ static INLINE const float *
get_texel_3d(const struct sp_sampler_varient *samp,
union tex_tile_address addr, int x, int y, int z)
{
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level = addr.bits.level;
if (x < 0 || x >= (int) u_minify(texture->width0, level) ||
@@ -932,7 +932,7 @@ img_filter_1d_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level0, j;
int width;
int x[4];
@@ -968,7 +968,7 @@ img_filter_2d_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level0, j;
int width, height;
int x[4], y[4];
@@ -1016,7 +1016,7 @@ img_filter_cube_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
const unsigned *faces = samp->faces; /* zero when not cube-mapping */
unsigned level0, j;
int width, height;
@@ -1056,7 +1056,7 @@ img_filter_3d_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level0, j;
int width, height, depth;
int x[4], y[4], z[4];
@@ -1098,7 +1098,7 @@ img_filter_1d_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level0, j;
int width;
int x0[4], x1[4];
@@ -1138,7 +1138,7 @@ img_filter_2d_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level0, j;
int width, height;
int x0[4], y0[4], x1[4], y1[4];
@@ -1185,7 +1185,7 @@ img_filter_cube_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
const unsigned *faces = samp->faces; /* zero when not cube-mapping */
unsigned level0, j;
int width, height;
@@ -1234,7 +1234,7 @@ img_filter_3d_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
const struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
unsigned level0, j;
int width, height, depth;
int x0[4], x1[4], y0[4], y1[4], z0[4], z1[4];
@@ -1310,7 +1310,7 @@ mip_filter_linear(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
int level0;
float lambda;
float lod[QUAD_SIZE];
@@ -1373,7 +1373,7 @@ mip_filter_nearest(struct tgsi_sampler *tgsi_sampler,
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
float lambda;
float lod[QUAD_SIZE];
@@ -1461,7 +1461,7 @@ mip_filter_linear_2d_linear_repeat_POT(
float rgba[NUM_CHANNELS][QUAD_SIZE])
{
struct sp_sampler_varient *samp = sp_sampler_varient(tgsi_sampler);
- const struct pipe_texture *texture = samp->texture;
+ const struct pipe_resource *texture = samp->texture;
int level0;
float lambda;
float lod[QUAD_SIZE];
@@ -1867,7 +1867,7 @@ get_img_filter(const union sp_sampler_key key,
void
sp_sampler_varient_bind_texture( struct sp_sampler_varient *samp,
struct softpipe_tex_tile_cache *tex_cache,
- const struct pipe_texture *texture )
+ const struct pipe_resource *texture )
{
const struct pipe_sampler_state *sampler = samp->sampler;
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.h b/src/gallium/drivers/softpipe/sp_tex_sample.h
index b6e66c998a..6114acf737 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.h
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.h
@@ -85,7 +85,7 @@ struct sp_sampler_varient
/* Currently bound texture:
*/
- const struct pipe_texture *texture;
+ const struct pipe_resource *texture;
struct softpipe_tex_tile_cache *cache;
unsigned processor;
@@ -129,7 +129,7 @@ sp_create_sampler_varient( const struct pipe_sampler_state *sampler,
void sp_sampler_varient_bind_texture( struct sp_sampler_varient *varient,
struct softpipe_tex_tile_cache *tex_cache,
- const struct pipe_texture *tex );
+ const struct pipe_resource *tex );
void sp_sampler_varient_destroy( struct sp_sampler_varient * );
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
index 6594514c38..c79f5fb05a 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.c
@@ -69,10 +69,10 @@ sp_destroy_tex_tile_cache(struct softpipe_tex_tile_cache *tc)
/*assert(tc->entries[pos].x < 0);*/
}
if (tc->transfer) {
- tc->pipe->tex_transfer_destroy(tc->pipe, tc->transfer);
+ tc->pipe->transfer_destroy(tc->pipe, tc->transfer);
}
if (tc->tex_trans) {
- tc->pipe->tex_transfer_destroy(tc->pipe, tc->tex_trans);
+ tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
}
FREE( tc );
@@ -122,13 +122,13 @@ void
sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
struct pipe_sampler_view *view)
{
- struct pipe_texture *texture = view ? view->texture : NULL;
+ struct pipe_resource *texture = view ? view->texture : NULL;
uint i;
assert(!tc->transfer);
if (tc->texture != texture) {
- pipe_texture_reference(&tc->texture, texture);
+ pipe_resource_reference(&tc->texture, texture);
if (tc->tex_trans) {
if (tc->tex_trans_map) {
@@ -136,7 +136,7 @@ sp_tex_tile_cache_set_sampler_view(struct softpipe_tex_tile_cache *tc,
tc->tex_trans_map = NULL;
}
- tc->pipe->tex_transfer_destroy(tc->pipe, tc->tex_trans);
+ tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
tc->tex_trans = NULL;
}
@@ -239,18 +239,18 @@ sp_find_cached_tile_tex(struct softpipe_tex_tile_cache *tc,
tc->tex_trans_map = NULL;
}
- tc->pipe->tex_transfer_destroy(tc->pipe, tc->tex_trans);
+ tc->pipe->transfer_destroy(tc->pipe, tc->tex_trans);
tc->tex_trans = NULL;
}
tc->tex_trans =
- tc->pipe->get_tex_transfer(tc->pipe, tc->texture,
- addr.bits.face,
- addr.bits.level,
- addr.bits.z,
- PIPE_TRANSFER_READ, 0, 0,
- u_minify(tc->texture->width0, addr.bits.level),
- u_minify(tc->texture->height0, addr.bits.level));
+ pipe_get_transfer(tc->pipe, tc->texture,
+ addr.bits.face,
+ addr.bits.level,
+ addr.bits.z,
+ PIPE_TRANSFER_READ, 0, 0,
+ u_minify(tc->texture->width0, addr.bits.level),
+ u_minify(tc->texture->height0, addr.bits.level));
tc->tex_trans_map = tc->pipe->transfer_map(tc->pipe, tc->tex_trans);
diff --git a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
index 12ae7ba12d..0794ffa0c5 100644
--- a/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tex_tile_cache.h
@@ -74,7 +74,7 @@ struct softpipe_tex_tile_cache
struct pipe_transfer *transfer;
void *transfer_map;
- struct pipe_texture *texture; /**< if caching a texture */
+ struct pipe_resource *texture; /**< if caching a texture */
unsigned timestamp;
struct softpipe_tex_cached_tile entries[NUM_ENTRIES];
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index f4983b7c8e..27cc6f27b2 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -36,6 +36,7 @@
#include "util/u_format.h"
#include "util/u_math.h"
#include "util/u_memory.h"
+#include "util/u_transfer.h"
#include "sp_context.h"
#include "sp_texture.h"
@@ -49,10 +50,10 @@
* Use a simple, maximally packed layout.
*/
static boolean
-softpipe_texture_layout(struct pipe_screen *screen,
- struct softpipe_texture * spt)
+softpipe_resource_layout(struct pipe_screen *screen,
+ struct softpipe_resource * spt)
{
- struct pipe_texture *pt = &spt->base;
+ struct pipe_resource *pt = &spt->base;
unsigned level;
unsigned width = pt->width0;
unsigned height = pt->height0;
@@ -84,14 +85,14 @@ softpipe_texture_layout(struct pipe_screen *screen,
*/
static boolean
softpipe_displaytarget_layout(struct pipe_screen *screen,
- struct softpipe_texture * spt)
+ struct softpipe_resource * spt)
{
struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
/* Round up the surface size to a multiple of the tile size?
*/
spt->dt = winsys->displaytarget_create(winsys,
- spt->base.tex_usage,
+ spt->base.bind,
spt->base.format,
spt->base.width0,
spt->base.height0,
@@ -103,16 +104,18 @@ softpipe_displaytarget_layout(struct pipe_screen *screen,
/**
- * Create new pipe_texture given the template information.
+ * Create new pipe_resource given the template information.
*/
-static struct pipe_texture *
-softpipe_texture_create(struct pipe_screen *screen,
- const struct pipe_texture *template)
+static struct pipe_resource *
+softpipe_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
{
- struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
+ struct softpipe_resource *spt = CALLOC_STRUCT(softpipe_resource);
if (!spt)
return NULL;
+ assert(template->format != PIPE_FORMAT_NONE);
+
spt->base = *template;
pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
@@ -121,14 +124,14 @@ softpipe_texture_create(struct pipe_screen *screen,
util_is_power_of_two(template->height0) &&
util_is_power_of_two(template->depth0));
- if (spt->base.tex_usage & (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_SCANOUT |
- PIPE_TEXTURE_USAGE_SHARED)) {
+ if (spt->base.bind & (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_SCANOUT |
+ PIPE_BIND_SHARED)) {
if (!softpipe_displaytarget_layout(screen, spt))
goto fail;
}
else {
- if (!softpipe_texture_layout(screen, spt))
+ if (!softpipe_resource_layout(screen, spt))
goto fail;
}
@@ -141,17 +144,18 @@ softpipe_texture_create(struct pipe_screen *screen,
static void
-softpipe_texture_destroy(struct pipe_texture *pt)
+softpipe_resource_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *pt)
{
- struct softpipe_screen *screen = softpipe_screen(pt->screen);
- struct softpipe_texture *spt = softpipe_texture(pt);
+ struct softpipe_screen *screen = softpipe_screen(pscreen);
+ struct softpipe_resource *spt = softpipe_resource(pt);
if (spt->dt) {
/* display target */
struct sw_winsys *winsys = screen->winsys;
winsys->displaytarget_destroy(winsys, spt->dt);
}
- else {
+ else if (!spt->userBuffer) {
/* regular texture */
align_free(spt->data);
}
@@ -160,13 +164,13 @@ softpipe_texture_destroy(struct pipe_texture *pt)
}
-static struct pipe_texture *
-softpipe_texture_from_handle(struct pipe_screen *screen,
- const struct pipe_texture *template,
+static struct pipe_resource *
+softpipe_resource_from_handle(struct pipe_screen *screen,
+ const struct pipe_resource *template,
struct winsys_handle *whandle)
{
struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
- struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
+ struct softpipe_resource *spt = CALLOC_STRUCT(softpipe_resource);
if (!spt)
return NULL;
@@ -194,12 +198,12 @@ softpipe_texture_from_handle(struct pipe_screen *screen,
static boolean
-softpipe_texture_get_handle(struct pipe_screen *screen,
- struct pipe_texture *pt,
+softpipe_resource_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *pt,
struct winsys_handle *whandle)
{
struct sw_winsys *winsys = softpipe_screen(screen)->winsys;
- struct softpipe_texture *spt = softpipe_texture(pt);
+ struct softpipe_resource *spt = softpipe_resource(pt);
assert(spt->dt);
if (!spt->dt)
@@ -214,11 +218,11 @@ softpipe_texture_get_handle(struct pipe_screen *screen,
*/
static struct pipe_surface *
softpipe_get_tex_surface(struct pipe_screen *screen,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned face, unsigned level, unsigned zslice,
unsigned usage)
{
- struct softpipe_texture *spt = softpipe_texture(pt);
+ struct softpipe_resource *spt = softpipe_resource(pt);
struct pipe_surface *ps;
assert(level <= pt->last_level);
@@ -226,33 +230,13 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
pipe_reference_init(&ps->reference, 1);
- pipe_texture_reference(&ps->texture, pt);
+ 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 = spt->level_offset[level];
ps->usage = usage;
- /* Because we are softpipe, anything that the state tracker
- * thought was going to be done with the GPU will actually get
- * done with the CPU. Let's adjust the flags to take that into
- * account.
- */
- if (ps->usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
- /* GPU_WRITE means "render" and that can involve reads (blending) */
- ps->usage |= PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_CPU_READ;
- }
-
- if (ps->usage & PIPE_BUFFER_USAGE_GPU_READ)
- ps->usage |= PIPE_BUFFER_USAGE_CPU_READ;
-
- if (ps->usage & (PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_WRITE)) {
- /* Mark the surface as dirty. The tile cache will look for this. */
- spt->timestamp++;
- softpipe_screen(screen)->timestamp++;
- }
-
ps->face = face;
ps->level = level;
ps->zslice = zslice;
@@ -285,7 +269,7 @@ softpipe_tex_surface_destroy(struct pipe_surface *surf)
* where it would happen. For softpipe, nothing to do.
*/
assert(surf->texture);
- pipe_texture_reference(&surf->texture, NULL);
+ pipe_resource_reference(&surf->texture, NULL);
FREE(surf);
}
@@ -303,49 +287,52 @@ softpipe_tex_surface_destroy(struct pipe_surface *surf)
* \param height height of region to read/write
*/
static struct pipe_transfer *
-softpipe_get_tex_transfer(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
+softpipe_get_transfer(struct pipe_context *pipe,
+ struct pipe_resource *resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
- struct softpipe_texture *sptex = softpipe_texture(texture);
+ struct softpipe_resource *sptex = softpipe_resource(resource);
struct softpipe_transfer *spt;
- assert(texture);
- assert(level <= texture->last_level);
+ assert(resource);
+ assert(sr.level <= resource->last_level);
/* make sure the requested region is in the image bounds */
- assert(x + w <= u_minify(texture->width0, level));
- assert(y + h <= u_minify(texture->height0, level));
+ assert(box->x + box->width <= u_minify(resource->width0, sr.level));
+ assert(box->y + box->height <= u_minify(resource->height0, sr.level));
+ assert(box->z + box->depth <= u_minify(resource->depth0, sr.level));
spt = CALLOC_STRUCT(softpipe_transfer);
if (spt) {
struct pipe_transfer *pt = &spt->base;
- int nblocksy = util_format_get_nblocksy(texture->format, u_minify(texture->height0, level));
- pipe_texture_reference(&pt->texture, texture);
- pt->x = x;
- pt->y = y;
- pt->width = w;
- pt->height = h;
- pt->stride = sptex->stride[level];
+ enum pipe_format format = resource->format;
+ int nblocksy = util_format_get_nblocksy(resource->format,
+ u_minify(resource->height0, sr.level));
+ pipe_resource_reference(&pt->resource, resource);
+ pt->sr = sr;
pt->usage = usage;
- pt->face = face;
- pt->level = level;
- pt->zslice = zslice;
+ pt->box = *box;
+ pt->stride = sptex->stride[sr.level];
- spt->offset = sptex->level_offset[level];
+ spt->offset = sptex->level_offset[sr.level];
- if (texture->target == PIPE_TEXTURE_CUBE) {
- spt->offset += face * nblocksy * pt->stride;
+ if (resource->target == PIPE_TEXTURE_CUBE) {
+ spt->offset += sr.face * nblocksy * pt->stride;
}
- else if (texture->target == PIPE_TEXTURE_3D) {
- spt->offset += zslice * nblocksy * pt->stride;
+ else if (resource->target == PIPE_TEXTURE_3D) {
+ spt->offset += box->z * nblocksy * pt->stride;
}
else {
- assert(face == 0);
- assert(zslice == 0);
+ assert(sr.face == 0);
+ assert(box->z == 0);
}
+
+ spt->offset +=
+ box->y / util_format_get_blockheight(format) * spt->base.stride +
+ box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
+
return pt;
}
return NULL;
@@ -354,18 +341,13 @@ softpipe_get_tex_transfer(struct pipe_context *pipe,
/**
* Free a pipe_transfer object which was created with
- * softpipe_get_tex_transfer().
+ * softpipe_get_transfer().
*/
static void
-softpipe_tex_transfer_destroy(struct pipe_context *pipe,
+softpipe_transfer_destroy(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
- /* Effectively do the texture_update work here - if texture images
- * needed post-processing to put them into hardware layout, this is
- * where it would happen. For softpipe, nothing to do.
- */
- assert (transfer->texture);
- pipe_texture_reference(&transfer->texture, NULL);
+ pipe_resource_reference(&transfer->resource, NULL);
FREE(transfer);
}
@@ -377,44 +359,26 @@ static void *
softpipe_transfer_map( struct pipe_context *pipe,
struct pipe_transfer *transfer )
{
- ubyte *map, *xfer_map;
- struct softpipe_texture *spt;
- enum pipe_format format;
-
- assert(transfer->texture);
- spt = softpipe_texture(transfer->texture);
- format = transfer->texture->format;
-
- if (spt->dt) {
- /* display target */
- struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys;
-
- map = winsys->displaytarget_map(winsys, spt->dt,
- pipe_transfer_buffer_flags(transfer));
- if (map == NULL)
- return NULL;
+ struct softpipe_transfer *sp_transfer = softpipe_transfer(transfer);
+ struct softpipe_resource *sp_resource = softpipe_resource(transfer->resource);
+ struct sw_winsys *winsys = softpipe_screen(pipe->screen)->winsys;
+ uint8_t *map;
+
+ /* resources backed by display target treated specially:
+ */
+ if (sp_resource->dt) {
+ map = winsys->displaytarget_map(winsys,
+ sp_resource->dt,
+ transfer->usage);
}
else {
- map = spt->data;
- if (map == NULL)
- return NULL;
- }
-
- /* May want to different things here depending on read/write nature
- * of the map:
- */
- if (transfer->texture && (transfer->usage & PIPE_TRANSFER_WRITE)) {
- /* Do something to notify sharing contexts of a texture change.
- * In softpipe, that would mean flushing the texture cache.
- */
- softpipe_screen(pipe->screen)->timestamp++;
+ map = sp_resource->data;
}
- xfer_map = map + softpipe_transfer(transfer)->offset +
- transfer->y / util_format_get_blockheight(format) * transfer->stride +
- transfer->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
- /*printf("map = %p xfer map = %p\n", map, xfer_map);*/
- return xfer_map;
+ if (map == NULL)
+ return NULL;
+ else
+ return map + sp_transfer->offset;
}
@@ -425,10 +389,10 @@ static void
softpipe_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer)
{
- struct softpipe_texture *spt;
+ struct softpipe_resource *spt;
- assert(transfer->texture);
- spt = softpipe_texture(transfer->texture);
+ assert(transfer->resource);
+ spt = softpipe_resource(transfer->resource);
if (spt->dt) {
/* display target */
@@ -442,81 +406,64 @@ softpipe_transfer_unmap(struct pipe_context *pipe,
}
}
-
-static struct pipe_video_surface*
-softpipe_video_surface_create(struct pipe_screen *screen,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
+/**
+ * Create buffer which wraps user-space data.
+ */
+static struct pipe_resource *
+softpipe_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind_flags)
{
- struct softpipe_video_surface *sp_vsfc;
- struct pipe_texture template;
+ struct softpipe_resource *buffer;
- assert(screen);
- assert(width && height);
-
- sp_vsfc = CALLOC_STRUCT(softpipe_video_surface);
- if (!sp_vsfc)
+ buffer = CALLOC_STRUCT(softpipe_resource);
+ if(!buffer)
return NULL;
- pipe_reference_init(&sp_vsfc->base.reference, 1);
- sp_vsfc->base.screen = screen;
- sp_vsfc->base.chroma_format = chroma_format;
- /*sp_vsfc->base.surface_format = PIPE_VIDEO_SURFACE_FORMAT_VUYA;*/
- sp_vsfc->base.width = width;
- sp_vsfc->base.height = height;
-
- memset(&template, 0, sizeof(struct pipe_texture));
- template.target = PIPE_TEXTURE_2D;
- template.format = PIPE_FORMAT_B8G8R8X8_UNORM;
- template.last_level = 0;
- /* vl_mpeg12_mc_renderer expects this when it's initialized with pot_buffers=true */
- template.width0 = util_next_power_of_two(width);
- template.height0 = util_next_power_of_two(height);
- template.depth0 = 1;
- template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER | PIPE_TEXTURE_USAGE_RENDER_TARGET;
-
- sp_vsfc->tex = screen->texture_create(screen, &template);
- if (!sp_vsfc->tex) {
- FREE(sp_vsfc);
- return NULL;
- }
-
- return &sp_vsfc->base;
+
+ pipe_reference_init(&buffer->base.reference, 1);
+ buffer->base.screen = screen;
+ buffer->base.format = PIPE_FORMAT_R8_UNORM; /* ?? */
+ buffer->base.bind = bind_flags;
+ buffer->base._usage = PIPE_USAGE_IMMUTABLE;
+ buffer->base.flags = 0;
+ buffer->base.width0 = bytes;
+ buffer->base.height0 = 1;
+ buffer->base.depth0 = 1;
+ buffer->userBuffer = TRUE;
+ buffer->data = ptr;
+
+ return &buffer->base;
}
-static void
-softpipe_video_surface_destroy(struct pipe_video_surface *vsfc)
-{
- struct softpipe_video_surface *sp_vsfc = softpipe_video_surface(vsfc);
- pipe_texture_reference(&sp_vsfc->tex, NULL);
- FREE(sp_vsfc);
-}
void
softpipe_init_texture_funcs(struct pipe_context *pipe)
{
- pipe->get_tex_transfer = softpipe_get_tex_transfer;
- pipe->tex_transfer_destroy = softpipe_tex_transfer_destroy;
+ pipe->get_transfer = softpipe_get_transfer;
+ pipe->transfer_destroy = softpipe_transfer_destroy;
pipe->transfer_map = softpipe_transfer_map;
pipe->transfer_unmap = softpipe_transfer_unmap;
+
+ pipe->transfer_flush_region = u_default_transfer_flush_region;
+ pipe->transfer_inline_write = u_default_transfer_inline_write;
}
void
softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
{
- screen->texture_create = softpipe_texture_create;
- screen->texture_destroy = softpipe_texture_destroy;
- screen->texture_from_handle = softpipe_texture_from_handle;
- screen->texture_get_handle = softpipe_texture_get_handle;
+ screen->resource_create = softpipe_resource_create;
+ screen->resource_destroy = softpipe_resource_destroy;
+ screen->resource_from_handle = softpipe_resource_from_handle;
+ screen->resource_get_handle = softpipe_resource_get_handle;
+ screen->user_buffer_create = softpipe_user_buffer_create;
screen->get_tex_surface = softpipe_get_tex_surface;
screen->tex_surface_destroy = softpipe_tex_surface_destroy;
-
- screen->video_surface_create = softpipe_video_surface_create;
- screen->video_surface_destroy = softpipe_video_surface_destroy;
}
diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h
index c0e6ba8a86..500f42fb0f 100644
--- a/src/gallium/drivers/softpipe/sp_texture.h
+++ b/src/gallium/drivers/softpipe/sp_texture.h
@@ -30,7 +30,6 @@
#include "pipe/p_state.h"
-#include "pipe/p_video_state.h"
#define SP_MAX_TEXTURE_2D_LEVELS 13 /* 4K x 4K */
@@ -42,27 +41,28 @@ struct pipe_screen;
struct softpipe_context;
-struct softpipe_texture
+struct softpipe_resource
{
- struct pipe_texture base;
+ struct pipe_resource base;
unsigned long level_offset[SP_MAX_TEXTURE_2D_LEVELS];
unsigned stride[SP_MAX_TEXTURE_2D_LEVELS];
/**
- * Display target, for textures with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET
- * usage.
+ * Display target, only valid for PIPE_TEXTURE_2D with the
+ * PIPE_BIND_DISPLAY_TARGET usage.
*/
struct sw_displaytarget *dt;
/**
- * Malloc'ed data for regular textures, or a mapping to dt above.
+ * Malloc'ed data for regular buffers and textures, or a mapping to dt above.
*/
void *data;
/* True if texture images are power-of-two in all dimensions:
*/
boolean pot;
+ boolean userBuffer;
unsigned timestamp;
};
@@ -74,21 +74,13 @@ struct softpipe_transfer
unsigned long offset;
};
-struct softpipe_video_surface
-{
- struct pipe_video_surface base;
-
- /* The data is held here:
- */
- struct pipe_texture *tex;
-};
/** cast wrappers */
-static INLINE struct softpipe_texture *
-softpipe_texture(struct pipe_texture *pt)
+static INLINE struct softpipe_resource *
+softpipe_resource(struct pipe_resource *pt)
{
- return (struct softpipe_texture *) pt;
+ return (struct softpipe_resource *) pt;
}
static INLINE struct softpipe_transfer *
@@ -97,12 +89,6 @@ softpipe_transfer(struct pipe_transfer *pt)
return (struct softpipe_transfer *) pt;
}
-static INLINE struct softpipe_video_surface *
-softpipe_video_surface(struct pipe_video_surface *pvs)
-{
- return (struct softpipe_video_surface *) pvs;
-}
-
extern void
softpipe_init_screen_texture_funcs(struct pipe_screen *screen);
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 7551b923fb..d996c2a342 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -121,7 +121,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
/*assert(tc->entries[pos].x < 0);*/
}
if (tc->transfer) {
- tc->pipe->tex_transfer_destroy(tc->pipe, tc->transfer);
+ tc->pipe->transfer_destroy(tc->pipe, tc->transfer);
}
FREE( tc );
@@ -146,17 +146,17 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
tc->transfer_map = NULL;
}
- pipe->tex_transfer_destroy(pipe, tc->transfer);
+ pipe->transfer_destroy(pipe, tc->transfer);
tc->transfer = NULL;
}
tc->surface = ps;
if (ps) {
- tc->transfer = pipe->get_tex_transfer(pipe, ps->texture, ps->face,
- ps->level, ps->zslice,
- PIPE_TRANSFER_READ_WRITE,
- 0, 0, ps->width, ps->height);
+ tc->transfer = pipe_get_transfer(pipe, ps->texture, ps->face,
+ ps->level, ps->zslice,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, ps->width, ps->height);
tc->depth_stencil = (ps->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
ps->format == PIPE_FORMAT_Z24X8_UNORM ||
@@ -276,14 +276,14 @@ static void
sp_tile_cache_flush_clear(struct softpipe_tile_cache *tc)
{
struct pipe_transfer *pt = tc->transfer;
- const uint w = tc->transfer->width;
- const uint h = tc->transfer->height;
+ const uint w = tc->transfer->box.width;
+ const uint h = tc->transfer->box.height;
uint x, y;
uint numCleared = 0;
- assert(pt->texture);
+ assert(pt->resource);
/* clear the scratch tile to the clear value */
- clear_tile(&tc->tile, pt->texture->format, tc->clear_val);
+ clear_tile(&tc->tile, pt->resource->format, tc->clear_val);
/* push the tile to all positions marked as clear */
for (y = 0; y < h; y += TILE_SIZE) {
@@ -372,7 +372,7 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
if (addr.value != tile->addr.value) {
- assert(pt->texture);
+ assert(pt->resource);
if (tile->addr.bits.invalid == 0) {
/* put dirty tile back in framebuffer */
if (tc->depth_stencil) {
@@ -396,10 +396,10 @@ sp_find_cached_tile(struct softpipe_tile_cache *tc,
if (is_clear_flag_set(tc->clear_flags, addr)) {
/* don't get tile from framebuffer, just clear it */
if (tc->depth_stencil) {
- clear_tile(tile, pt->texture->format, tc->clear_val);
+ clear_tile(tile, pt->resource->format, tc->clear_val);
}
else {
- clear_tile_rgba(tile, pt->texture->format, tc->clear_color);
+ clear_tile_rgba(tile, pt->resource->format, tc->clear_color);
}
clear_clear_flag(tc->clear_flags, addr);
}
diff --git a/src/gallium/drivers/softpipe/sp_video_context.c b/src/gallium/drivers/softpipe/sp_video_context.c
deleted file mode 100644
index 242aaac466..0000000000
--- a/src/gallium/drivers/softpipe/sp_video_context.c
+++ /dev/null
@@ -1,304 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-
-#include "sp_video_context.h"
-#include "sp_texture.h"
-
-
-static void
-sp_mpeg12_destroy(struct pipe_video_context *vpipe)
-{
- struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
-
- assert(vpipe);
-
- /* Asserted in softpipe_delete_fs_state() for some reason */
- ctx->pipe->bind_vs_state(ctx->pipe, NULL);
- ctx->pipe->bind_fs_state(ctx->pipe, NULL);
-
- ctx->pipe->delete_blend_state(ctx->pipe, ctx->blend);
- ctx->pipe->delete_rasterizer_state(ctx->pipe, ctx->rast);
- ctx->pipe->delete_depth_stencil_alpha_state(ctx->pipe, ctx->dsa);
-
- pipe_video_surface_reference(&ctx->decode_target, NULL);
- vl_compositor_cleanup(&ctx->compositor);
- vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
- ctx->pipe->destroy(ctx->pipe);
-
- FREE(ctx);
-}
-
-static void
-sp_mpeg12_decode_macroblocks(struct pipe_video_context *vpipe,
- struct pipe_video_surface *past,
- struct pipe_video_surface *future,
- unsigned num_macroblocks,
- struct pipe_macroblock *macroblocks,
- struct pipe_fence_handle **fence)
-{
- struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
- struct pipe_mpeg12_macroblock *mpeg12_macroblocks = (struct pipe_mpeg12_macroblock*)macroblocks;
-
- assert(vpipe);
- assert(num_macroblocks);
- assert(macroblocks);
- assert(macroblocks->codec == PIPE_VIDEO_CODEC_MPEG12);
- assert(ctx->decode_target);
-
- vl_mpeg12_mc_renderer_render_macroblocks(&ctx->mc_renderer,
- softpipe_video_surface(ctx->decode_target)->tex,
- past ? softpipe_video_surface(past)->tex : NULL,
- future ? softpipe_video_surface(future)->tex : NULL,
- num_macroblocks, mpeg12_macroblocks, fence);
-}
-
-static void
-sp_mpeg12_clear_surface(struct pipe_video_context *vpipe,
- unsigned x, unsigned y,
- unsigned width, unsigned height,
- unsigned value,
- struct pipe_surface *surface)
-{
- struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(surface);
-
- ctx->pipe->surface_fill(ctx->pipe, surface, x, y, width, height, value);
-}
-
-static void
-sp_mpeg12_render_picture(struct pipe_video_context *vpipe,
- /*struct pipe_surface *backround,
- struct pipe_video_rect *backround_area,*/
- struct pipe_video_surface *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_video_surface *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_video_surface *future_surfaces,*/
- struct pipe_video_rect *src_area,
- struct pipe_surface *dst_surface,
- struct pipe_video_rect *dst_area,
- /*unsigned num_layers,
- struct pipe_surface *layers,
- struct pipe_video_rect *layer_src_areas,
- struct pipe_video_rect *layer_dst_areas*/
- struct pipe_fence_handle **fence)
-{
- struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(src_surface);
- assert(src_area);
- assert(dst_surface);
- assert(dst_area);
-
- vl_compositor_render(&ctx->compositor, softpipe_video_surface(src_surface)->tex,
- picture_type, src_area, dst_surface->texture, dst_area, fence);
-}
-
-static void
-sp_mpeg12_set_decode_target(struct pipe_video_context *vpipe,
- struct pipe_video_surface *dt)
-{
- struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
-
- assert(vpipe);
- assert(dt);
-
- pipe_video_surface_reference(&ctx->decode_target, dt);
-}
-
-static void sp_mpeg12_set_csc_matrix(struct pipe_video_context *vpipe, const float *mat)
-{
- struct sp_mpeg12_context *ctx = (struct sp_mpeg12_context*)vpipe;
-
- assert(vpipe);
-
- vl_compositor_set_csc_matrix(&ctx->compositor, mat);
-}
-
-static bool
-init_pipe_state(struct sp_mpeg12_context *ctx)
-{
- struct pipe_rasterizer_state rast;
- struct pipe_blend_state blend;
- struct pipe_depth_stencil_alpha_state dsa;
- unsigned i;
-
- assert(ctx);
-
- rast.flatshade = 1;
- rast.flatshade_first = 0;
- rast.light_twoside = 0;
- rast.front_winding = PIPE_WINDING_CCW;
- rast.cull_mode = PIPE_WINDING_CW;
- rast.fill_cw = PIPE_POLYGON_MODE_FILL;
- rast.fill_ccw = PIPE_POLYGON_MODE_FILL;
- rast.offset_cw = 0;
- rast.offset_ccw = 0;
- rast.scissor = 0;
- rast.poly_smooth = 0;
- rast.poly_stipple_enable = 0;
- rast.sprite_coord_enable = 0;
- rast.point_size_per_vertex = 0;
- rast.multisample = 0;
- rast.line_smooth = 0;
- rast.line_stipple_enable = 0;
- rast.line_stipple_factor = 0;
- rast.line_stipple_pattern = 0;
- rast.line_last_pixel = 0;
- rast.line_width = 1;
- rast.point_smooth = 0;
- rast.point_quad_rasterization = 0;
- rast.point_size = 1;
- rast.offset_units = 1;
- rast.offset_scale = 1;
- ctx->rast = ctx->pipe->create_rasterizer_state(ctx->pipe, &rast);
- ctx->pipe->bind_rasterizer_state(ctx->pipe, ctx->rast);
-
- blend.independent_blend_enable = 0;
- blend.rt[0].blend_enable = 0;
- blend.rt[0].rgb_func = PIPE_BLEND_ADD;
- blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE;
- blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ONE;
- blend.rt[0].alpha_func = PIPE_BLEND_ADD;
- blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE;
- blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ONE;
- blend.logicop_enable = 0;
- blend.logicop_func = PIPE_LOGICOP_CLEAR;
- /* Needed to allow color writes to FB, even if blending disabled */
- blend.rt[0].colormask = PIPE_MASK_RGBA;
- blend.dither = 0;
- ctx->blend = ctx->pipe->create_blend_state(ctx->pipe, &blend);
- ctx->pipe->bind_blend_state(ctx->pipe, ctx->blend);
-
- dsa.depth.enabled = 0;
- dsa.depth.writemask = 0;
- dsa.depth.func = PIPE_FUNC_ALWAYS;
- for (i = 0; i < 2; ++i) {
- dsa.stencil[i].enabled = 0;
- dsa.stencil[i].func = PIPE_FUNC_ALWAYS;
- dsa.stencil[i].fail_op = PIPE_STENCIL_OP_KEEP;
- dsa.stencil[i].zpass_op = PIPE_STENCIL_OP_KEEP;
- dsa.stencil[i].zfail_op = PIPE_STENCIL_OP_KEEP;
- dsa.stencil[i].valuemask = 0;
- dsa.stencil[i].writemask = 0;
- }
- dsa.alpha.enabled = 0;
- dsa.alpha.func = PIPE_FUNC_ALWAYS;
- dsa.alpha.ref_value = 0;
- ctx->dsa = ctx->pipe->create_depth_stencil_alpha_state(ctx->pipe, &dsa);
- ctx->pipe->bind_depth_stencil_alpha_state(ctx->pipe, ctx->dsa);
-
- return true;
-}
-
-static struct pipe_video_context *
-sp_mpeg12_create(struct pipe_screen *screen, enum pipe_video_profile profile,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
-{
- struct sp_mpeg12_context *ctx;
-
- assert(u_reduce_video_profile(profile) == PIPE_VIDEO_CODEC_MPEG12);
-
- ctx = CALLOC_STRUCT(sp_mpeg12_context);
-
- if (!ctx)
- return NULL;
-
- ctx->base.profile = profile;
- ctx->base.chroma_format = chroma_format;
- ctx->base.width = width;
- ctx->base.height = height;
-
- ctx->base.screen = screen;
- ctx->base.destroy = sp_mpeg12_destroy;
- ctx->base.decode_macroblocks = sp_mpeg12_decode_macroblocks;
- ctx->base.clear_surface = sp_mpeg12_clear_surface;
- ctx->base.render_picture = sp_mpeg12_render_picture;
- ctx->base.set_decode_target = sp_mpeg12_set_decode_target;
- ctx->base.set_csc_matrix = sp_mpeg12_set_csc_matrix;
-
- ctx->pipe = screen->context_create(screen, NULL);
- if (!ctx->pipe) {
- FREE(ctx);
- return NULL;
- }
-
- /* TODO: Use slice buffering for softpipe when implemented, no advantage to buffering an entire picture */
- if (!vl_mpeg12_mc_renderer_init(&ctx->mc_renderer, ctx->pipe,
- width, height, chroma_format,
- VL_MPEG12_MC_RENDERER_BUFFER_PICTURE,
- /* TODO: Use XFER_NONE when implemented */
- VL_MPEG12_MC_RENDERER_EMPTY_BLOCK_XFER_ONE,
- true)) {
- ctx->pipe->destroy(ctx->pipe);
- FREE(ctx);
- return NULL;
- }
-
- if (!vl_compositor_init(&ctx->compositor, ctx->pipe)) {
- vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
- ctx->pipe->destroy(ctx->pipe);
- FREE(ctx);
- return NULL;
- }
-
- if (!init_pipe_state(ctx)) {
- vl_compositor_cleanup(&ctx->compositor);
- vl_mpeg12_mc_renderer_cleanup(&ctx->mc_renderer);
- ctx->pipe->destroy(ctx->pipe);
- FREE(ctx);
- return NULL;
- }
-
- return &ctx->base;
-}
-
-struct pipe_video_context *
-sp_video_create(struct pipe_screen *screen, enum pipe_video_profile profile,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
-{
- assert(screen);
- assert(width && height);
-
- switch (u_reduce_video_profile(profile)) {
- case PIPE_VIDEO_CODEC_MPEG12:
- return sp_mpeg12_create(screen, profile,
- chroma_format,
- width, height);
- default:
- return NULL;
- }
-}
diff --git a/src/gallium/drivers/softpipe/sp_video_context.h b/src/gallium/drivers/softpipe/sp_video_context.h
deleted file mode 100644
index ccbd1ffe4c..0000000000
--- a/src/gallium/drivers/softpipe/sp_video_context.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef SP_VIDEO_CONTEXT_H
-#define SP_VIDEO_CONTEXT_H
-
-#include <pipe/p_video_context.h>
-#include <vl/vl_mpeg12_mc_renderer.h>
-#include <vl/vl_compositor.h>
-
-struct pipe_screen;
-struct pipe_context;
-struct pipe_video_surface;
-
-struct sp_mpeg12_context
-{
- struct pipe_video_context base;
- struct pipe_context *pipe;
- struct pipe_video_surface *decode_target;
- struct vl_mpeg12_mc_renderer mc_renderer;
- struct vl_compositor compositor;
-
- void *rast;
- void *dsa;
- void *blend;
-};
-
-struct pipe_video_context *
-sp_video_create(struct pipe_screen *screen, enum pipe_video_profile profile,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height);
-
-#endif /* SP_VIDEO_CONTEXT_H */
diff --git a/src/gallium/drivers/svga/Makefile b/src/gallium/drivers/svga/Makefile
index f361908187..27287793bd 100644
--- a/src/gallium/drivers/svga/Makefile
+++ b/src/gallium/drivers/svga/Makefile
@@ -27,8 +27,6 @@ C_SOURCES = \
svga_pipe_vertex.c \
svga_pipe_vs.c \
svga_screen.c \
- svga_screen_buffer.c \
- svga_screen_texture.c \
svga_screen_cache.c \
svga_state.c \
svga_state_need_swtnl.c \
@@ -45,7 +43,14 @@ C_SOURCES = \
svga_tgsi.c \
svga_tgsi_decl_sm20.c \
svga_tgsi_decl_sm30.c \
- svga_tgsi_insn.c
+ svga_tgsi_insn.c \
+ svga_sampler_view.c \
+ svga_surface.c \
+ svga_resource.c \
+ svga_resource_texture.c \
+ svga_resource_buffer.c \
+ svga_resource_buffer_upload.c
+
LIBRARY_INCLUDES = \
-I$(TOP)/src/gallium/drivers/svga/include
diff --git a/src/gallium/drivers/svga/SConscript b/src/gallium/drivers/svga/SConscript
index 737b791ceb..12ce4732d1 100644
--- a/src/gallium/drivers/svga/SConscript
+++ b/src/gallium/drivers/svga/SConscript
@@ -38,10 +38,13 @@ sources = [
'svga_pipe_sampler.c',
'svga_pipe_vertex.c',
'svga_pipe_vs.c',
+ 'svga_resource.c',
+ 'svga_resource_buffer.c',
+ 'svga_resource_buffer_upload.c',
+ 'svga_resource_texture.c',
+ 'svga_sampler_view.c',
'svga_screen.c',
- 'svga_screen_buffer.c',
'svga_screen_cache.c',
- 'svga_screen_texture.c',
'svga_state.c',
'svga_state_constants.c',
'svga_state_framebuffer.c',
@@ -51,6 +54,7 @@ sources = [
'svga_state_vdecl.c',
'svga_state_fs.c',
'svga_state_vs.c',
+ 'svga_surface.c',
'svga_swtnl_backend.c',
'svga_swtnl_draw.c',
'svga_swtnl_state.c',
diff --git a/src/gallium/drivers/svga/svga_cmd.c b/src/gallium/drivers/svga/svga_cmd.c
index 04307d17fe..7b2dfe2549 100644
--- a/src/gallium/drivers/svga/svga_cmd.c
+++ b/src/gallium/drivers/svga/svga_cmd.c
@@ -31,8 +31,9 @@
*/
#include "svga_winsys.h"
-#include "svga_screen_buffer.h"
-#include "svga_screen_texture.h"
+#include "svga_resource_buffer.h"
+#include "svga_resource_texture.h"
+#include "svga_surface.h"
#include "svga_cmd.h"
/*
@@ -279,7 +280,7 @@ SVGA3D_BeginDefineSurface(struct svga_winsys_context *swc,
if(!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
- swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_WRITE);
+ swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_WRITE);
cmd->surfaceFlags = flags;
cmd->format = format;
@@ -365,7 +366,7 @@ SVGA3D_DestroySurface(struct svga_winsys_context *swc,
if(!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
- swc->surface_relocation(swc, &cmd->sid, sid, PIPE_BUFFER_USAGE_GPU_READ);
+ swc->surface_relocation(swc, &cmd->sid, sid, SVGA_RELOC_READ);
swc->commit(swc);;
return PIPE_OK;
@@ -423,7 +424,7 @@ SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
const SVGA3dCopyBox *boxes, // IN
uint32 numBoxes) // IN
{
- struct svga_texture *texture = svga_texture(st->base.texture);
+ struct svga_texture *texture = svga_texture(st->base.resource);
SVGA3dCmdSurfaceDMA *cmd;
SVGA3dCmdSurfaceDMASuffix *pSuffix;
uint32 boxesSize = sizeof *boxes * numBoxes;
@@ -431,12 +432,12 @@ SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
unsigned surface_flags;
if(transfer == SVGA3D_WRITE_HOST_VRAM) {
- region_flags = PIPE_BUFFER_USAGE_GPU_READ;
- surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+ region_flags = SVGA_RELOC_READ;
+ surface_flags = SVGA_RELOC_WRITE;
}
else if(transfer == SVGA3D_READ_HOST_VRAM) {
- region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
- surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+ region_flags = SVGA_RELOC_WRITE;
+ surface_flags = SVGA_RELOC_READ;
}
else {
assert(0);
@@ -454,8 +455,8 @@ SVGA3D_SurfaceDMA(struct svga_winsys_context *swc,
cmd->guest.pitch = st->base.stride;
swc->surface_relocation(swc, &cmd->host.sid, texture->handle, surface_flags);
- cmd->host.face = st->base.face; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
- cmd->host.mipmap = st->base.level;
+ cmd->host.face = st->base.sr.face; /* PIPE_TEX_FACE_* and SVGA3D_CUBEFACE_* match */
+ cmd->host.mipmap = st->base.sr.level;
cmd->transfer = transfer;
@@ -489,12 +490,12 @@ SVGA3D_BufferDMA(struct svga_winsys_context *swc,
unsigned surface_flags;
if(transfer == SVGA3D_WRITE_HOST_VRAM) {
- region_flags = PIPE_BUFFER_USAGE_GPU_READ;
- surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+ region_flags = SVGA_RELOC_READ;
+ surface_flags = SVGA_RELOC_WRITE;
}
else if(transfer == SVGA3D_READ_HOST_VRAM) {
- region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
- surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+ region_flags = SVGA_RELOC_WRITE;
+ surface_flags = SVGA_RELOC_READ;
}
else {
assert(0);
@@ -584,7 +585,7 @@ SVGA3D_SetRenderTarget(struct svga_winsys_context *swc,
cmd->type = type;
- surface_to_surfaceid(swc, surface, &cmd->target, PIPE_BUFFER_USAGE_GPU_WRITE);
+ surface_to_surfaceid(swc, surface, &cmd->target, SVGA_RELOC_WRITE);
swc->commit(swc);
@@ -1000,8 +1001,8 @@ SVGA3D_BeginSurfaceCopy(struct svga_winsys_context *swc,
if(!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
- surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ);
- surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE);
+ surface_to_surfaceid(swc, src, &cmd->src, SVGA_RELOC_READ);
+ surface_to_surfaceid(swc, dest, &cmd->dest, SVGA_RELOC_WRITE);
*boxes = (SVGA3dCopyBox*) &cmd[1];
memset(*boxes, 0, boxesSize);
@@ -1043,8 +1044,8 @@ SVGA3D_SurfaceStretchBlt(struct svga_winsys_context *swc,
if(!cmd)
return PIPE_ERROR_OUT_OF_MEMORY;
- surface_to_surfaceid(swc, src, &cmd->src, PIPE_BUFFER_USAGE_GPU_READ);
- surface_to_surfaceid(swc, dest, &cmd->dest, PIPE_BUFFER_USAGE_GPU_WRITE);
+ surface_to_surfaceid(swc, src, &cmd->src, SVGA_RELOC_READ);
+ surface_to_surfaceid(swc, dest, &cmd->dest, SVGA_RELOC_WRITE);
cmd->boxSrc = *boxSrc;
cmd->boxDest = *boxDest;
cmd->mode = mode;
@@ -1373,7 +1374,7 @@ SVGA3D_EndQuery(struct svga_winsys_context *swc,
cmd->type = type;
swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ SVGA_RELOC_WRITE);
swc->commit(swc);
@@ -1420,7 +1421,7 @@ SVGA3D_WaitForQuery(struct svga_winsys_context *swc,
cmd->type = type;
swc->region_relocation(swc, &cmd->guestResult, buffer, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ SVGA_RELOC_WRITE);
swc->commit(swc);
diff --git a/src/gallium/drivers/svga/svga_cmd.h b/src/gallium/drivers/svga/svga_cmd.h
index da9fc4355f..0e568d78e6 100644
--- a/src/gallium/drivers/svga/svga_cmd.h
+++ b/src/gallium/drivers/svga/svga_cmd.h
@@ -41,7 +41,6 @@
#include "pipe/p_defines.h"
-struct pipe_buffer;
struct pipe_surface;
struct svga_transfer;
struct svga_winsys_context;
diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c
index adb7840182..3228a6d3d7 100644
--- a/src/gallium/drivers/svga/svga_context.c
+++ b/src/gallium/drivers/svga/svga_context.c
@@ -34,8 +34,9 @@
#include "svga_context.h"
#include "svga_screen.h"
-#include "svga_screen_texture.h"
-#include "svga_screen_buffer.h"
+#include "svga_resource_texture.h"
+#include "svga_resource_buffer.h"
+#include "svga_resource.h"
#include "svga_winsys.h"
#include "svga_swtnl.h"
#include "svga_draw.h"
@@ -66,64 +67,11 @@ static void svga_destroy( struct pipe_context *pipe )
util_bitmask_destroy( svga->fs_bm );
for(shader = 0; shader < PIPE_SHADER_TYPES; ++shader)
- pipe_buffer_reference( &svga->curr.cb[shader], NULL );
+ pipe_resource_reference( &svga->curr.cb[shader], NULL );
FREE( svga );
}
-static unsigned int
-svga_is_texture_referenced( struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level)
-{
- struct svga_texture *tex = svga_texture(texture);
- struct svga_screen *ss = svga_screen(pipe->screen);
-
- /**
- * The screen does not cache texture writes.
- */
-
- if (!tex->handle || ss->sws->surface_is_flushed(ss->sws, tex->handle))
- return PIPE_UNREFERENCED;
-
- /**
- * sws->surface_is_flushed() does not distinguish between read references
- * and write references. So assume a reference is both.
- */
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
-
-static unsigned int
-svga_is_buffer_referenced( struct pipe_context *pipe,
- struct pipe_buffer *buf)
-
-{
- struct svga_screen *ss = svga_screen(pipe->screen);
- struct svga_buffer *sbuf = svga_buffer(buf);
-
- /**
- * XXX: Check this.
- * The screen may cache buffer writes, but when we map, we map out
- * of those cached writes, so we don't need to set a
- * PIPE_REFERENCED_FOR_WRITE flag for cached buffers.
- */
-
- if (!sbuf->handle || ss->sws->surface_is_flushed(ss->sws, sbuf->handle))
- return PIPE_UNREFERENCED;
-
- /**
- * sws->surface_is_flushed() does not distinguish between read references
- * and write references. So assume a reference is both,
- * however, we make an exception for index- and vertex buffers, to avoid
- * a flush in st_bufferobj_get_subdata, during display list replay.
- */
-
- if (sbuf->base.usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_INDEX))
- return PIPE_REFERENCED_FOR_READ;
-
- return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
-}
struct pipe_context *svga_context_create( struct pipe_screen *screen,
@@ -143,13 +91,11 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen,
svga->pipe.destroy = svga_destroy;
svga->pipe.clear = svga_clear;
- svga->pipe.is_texture_referenced = svga_is_texture_referenced;
- svga->pipe.is_buffer_referenced = svga_is_buffer_referenced;
-
svga->swc = svgascreen->sws->context_create(svgascreen->sws);
if(!svga->swc)
goto no_swc;
+ svga_init_resource_functions(svga);
svga_init_blend_functions(svga);
svga_init_blit_functions(svga);
svga_init_depth_stencil_functions(svga);
@@ -164,7 +110,6 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen,
svga_init_constbuffer_functions(svga);
svga_init_query_functions(svga);
- svga_init_texture_functions(&svga->pipe);
/* debug */
svga->debug.no_swtnl = debug_get_bool_option("SVGA_NO_SWTNL", FALSE);
@@ -183,17 +128,17 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen,
if (svga->vs_bm == NULL)
goto no_vs_bm;
- svga->upload_ib = u_upload_create( svga->pipe.screen,
+ svga->upload_ib = u_upload_create( &svga->pipe,
32 * 1024,
16,
- PIPE_BUFFER_USAGE_INDEX );
+ PIPE_BIND_INDEX_BUFFER );
if (svga->upload_ib == NULL)
goto no_upload_ib;
- svga->upload_vb = u_upload_create( svga->pipe.screen,
+ svga->upload_vb = u_upload_create( &svga->pipe,
128 * 1024,
16,
- PIPE_BUFFER_USAGE_VERTEX );
+ PIPE_BIND_VERTEX_BUFFER );
if (svga->upload_vb == NULL)
goto no_upload_vb;
diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h
index 1f66437dfe..9a46de643f 100644
--- a/src/gallium/drivers/svga/svga_context.h
+++ b/src/gallium/drivers/svga/svga_context.h
@@ -190,7 +190,7 @@ struct svga_state
struct svga_vertex_shader *vs;
struct pipe_vertex_buffer vb[PIPE_MAX_ATTRIBS];
- struct pipe_buffer *cb[PIPE_SHADER_TYPES];
+ struct pipe_resource *cb[PIPE_SHADER_TYPES];
struct pipe_framebuffer_state framebuffer;
float depthscale;
@@ -254,7 +254,7 @@ struct svga_hw_clear_state
struct svga_hw_view_state
{
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct svga_sampler_view *v;
unsigned min_lod;
unsigned max_lod;
diff --git a/src/gallium/drivers/svga/svga_draw.c b/src/gallium/drivers/svga/svga_draw.c
index 8b7ca2e112..81dd4778d0 100644
--- a/src/gallium/drivers/svga/svga_draw.c
+++ b/src/gallium/drivers/svga/svga_draw.c
@@ -34,8 +34,9 @@
#include "svga_draw_private.h"
#include "svga_debug.h"
#include "svga_screen.h"
-#include "svga_screen_buffer.h"
-#include "svga_screen_texture.h"
+#include "svga_resource_buffer.h"
+#include "svga_resource_texture.h"
+#include "svga_surface.h"
#include "svga_winsys.h"
#include "svga_cmd.h"
@@ -65,16 +66,16 @@ void svga_hwtnl_destroy( struct svga_hwtnl *hwtnl )
for (i = 0; i < PIPE_PRIM_MAX; i++) {
for (j = 0; j < IDX_CACHE_MAX; j++) {
- pipe_buffer_reference( &hwtnl->index_cache[i][j].buffer,
+ pipe_resource_reference( &hwtnl->index_cache[i][j].buffer,
NULL );
}
}
for (i = 0; i < hwtnl->cmd.vdecl_count; i++)
- pipe_buffer_reference(&hwtnl->cmd.vdecl_vb[i], NULL);
+ pipe_resource_reference(&hwtnl->cmd.vdecl_vb[i], NULL);
for (i = 0; i < hwtnl->cmd.prim_count; i++)
- pipe_buffer_reference(&hwtnl->cmd.prim_ib[i], NULL);
+ pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL);
FREE(hwtnl);
@@ -103,7 +104,7 @@ void svga_hwtnl_reset_vdecl( struct svga_hwtnl *hwtnl,
assert(hwtnl->cmd.prim_count == 0);
for (i = count; i < hwtnl->cmd.vdecl_count; i++) {
- pipe_buffer_reference(&hwtnl->cmd.vdecl_vb[i],
+ pipe_resource_reference(&hwtnl->cmd.vdecl_vb[i],
NULL);
}
@@ -112,9 +113,9 @@ void svga_hwtnl_reset_vdecl( struct svga_hwtnl *hwtnl,
void svga_hwtnl_vdecl( struct svga_hwtnl *hwtnl,
- unsigned i,
- const SVGA3dVertexDecl *decl,
- struct pipe_buffer *vb)
+ unsigned i,
+ const SVGA3dVertexDecl *decl,
+ struct pipe_resource *vb)
{
assert(hwtnl->cmd.prim_count == 0);
@@ -122,8 +123,7 @@ void svga_hwtnl_vdecl( struct svga_hwtnl *hwtnl,
hwtnl->cmd.vdecl[i] = *decl;
- pipe_buffer_reference(&hwtnl->cmd.vdecl_vb[i],
- vb);
+ pipe_resource_reference(&hwtnl->cmd.vdecl_vb[i], vb);
}
@@ -198,7 +198,7 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
swc->surface_relocation(swc,
&vdecl[i].array.surfaceId,
vb_handle[i],
- PIPE_BUFFER_USAGE_GPU_READ);
+ SVGA_RELOC_READ);
}
memcpy( prim,
@@ -209,8 +209,8 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
swc->surface_relocation(swc,
&prim[i].indexArray.surfaceId,
ib_handle[i],
- PIPE_BUFFER_USAGE_GPU_READ);
- pipe_buffer_reference(&hwtnl->cmd.prim_ib[i], NULL);
+ SVGA_RELOC_READ);
+ pipe_resource_reference(&hwtnl->cmd.prim_ib[i], NULL);
}
SVGA_FIFOCommitAll( swc );
@@ -232,7 +232,7 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
const SVGA3dPrimitiveRange *range,
unsigned min_index,
unsigned max_index,
- struct pipe_buffer *ib )
+ struct pipe_resource *ib )
{
int ret = PIPE_OK;
@@ -240,8 +240,8 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
{
unsigned i;
for (i = 0; i < hwtnl->cmd.vdecl_count; i++) {
- struct pipe_buffer *vb = hwtnl->cmd.vdecl_vb[i];
- unsigned size = vb ? vb->size : 0;
+ struct pipe_resource *vb = hwtnl->cmd.vdecl_vb[i];
+ unsigned size = vb ? vb->width0 : 0;
unsigned offset = hwtnl->cmd.vdecl[i].array.offset;
unsigned stride = hwtnl->cmd.vdecl[i].array.stride;
unsigned index_bias = range->indexBias;
@@ -324,7 +324,7 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
assert(range->indexWidth == range->indexArray.stride);
if(ib) {
- unsigned size = ib->size;
+ unsigned size = ib->width0;
unsigned offset = range->indexArray.offset;
unsigned stride = range->indexArray.stride;
unsigned count;
@@ -375,7 +375,7 @@ enum pipe_error svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
hwtnl->cmd.prim[hwtnl->cmd.prim_count] = *range;
- pipe_buffer_reference(&hwtnl->cmd.prim_ib[hwtnl->cmd.prim_count], ib);
+ pipe_resource_reference(&hwtnl->cmd.prim_ib[hwtnl->cmd.prim_count], ib);
hwtnl->cmd.prim_count++;
return ret;
diff --git a/src/gallium/drivers/svga/svga_draw.h b/src/gallium/drivers/svga/svga_draw.h
index 14553b17b5..81c7f8377d 100644
--- a/src/gallium/drivers/svga/svga_draw.h
+++ b/src/gallium/drivers/svga/svga_draw.h
@@ -34,7 +34,7 @@ struct svga_hwtnl;
struct svga_winsys_context;
struct svga_screen;
struct svga_context;
-struct pipe_buffer;
+struct pipe_resource;
struct u_upload_mgr;
struct svga_hwtnl *svga_hwtnl_create( struct svga_context *svga,
@@ -53,7 +53,7 @@ void svga_hwtnl_set_unfilled( struct svga_hwtnl *hwtnl,
void svga_hwtnl_vdecl( struct svga_hwtnl *hwtnl,
unsigned i,
const SVGA3dVertexDecl *decl,
- struct pipe_buffer *vb);
+ struct pipe_resource *vb);
void svga_hwtnl_reset_vdecl( struct svga_hwtnl *hwtnl,
unsigned count );
@@ -67,7 +67,7 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl,
enum pipe_error
svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
diff --git a/src/gallium/drivers/svga/svga_draw_arrays.c b/src/gallium/drivers/svga/svga_draw_arrays.c
index 6192aa96b1..005996d05d 100644
--- a/src/gallium/drivers/svga/svga_draw_arrays.c
+++ b/src/gallium/drivers/svga/svga_draw_arrays.c
@@ -43,40 +43,40 @@ static enum pipe_error generate_indices( struct svga_hwtnl *hwtnl,
unsigned nr,
unsigned index_size,
u_generate_func generate,
- struct pipe_buffer **out_buf )
+ struct pipe_resource **out_buf )
{
- struct pipe_screen *screen = hwtnl->svga->pipe.screen;
+ struct pipe_context *pipe = &hwtnl->svga->pipe;
+ struct pipe_transfer *transfer;
unsigned size = index_size * nr;
- struct pipe_buffer *dst = NULL;
+ struct pipe_resource *dst = NULL;
void *dst_map = NULL;
- dst = screen->buffer_create( screen, 32,
- PIPE_BUFFER_USAGE_INDEX |
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ,
- size );
+ dst = pipe_buffer_create( pipe->screen,
+ PIPE_BIND_INDEX_BUFFER,
+ size );
if (dst == NULL)
goto fail;
- dst_map = pipe_buffer_map( screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE );
+ dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE,
+ &transfer);
if (dst_map == NULL)
goto fail;
generate( nr,
dst_map );
- pipe_buffer_unmap( screen, dst );
+ pipe_buffer_unmap( pipe, dst, transfer );
*out_buf = dst;
return PIPE_OK;
fail:
if (dst_map)
- screen->buffer_unmap( screen, dst );
+ pipe_buffer_unmap( pipe, dst, transfer );
if (dst)
- screen->buffer_destroy( dst );
-
+ pipe->screen->resource_destroy( pipe->screen, dst );
+
return PIPE_ERROR_OUT_OF_MEMORY;
}
@@ -96,7 +96,7 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl,
unsigned gen_nr,
unsigned gen_size,
u_generate_func generate,
- struct pipe_buffer **out_buf )
+ struct pipe_resource **out_buf )
{
enum pipe_error ret = PIPE_OK;
int i;
@@ -107,7 +107,7 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl,
{
if (compare(hwtnl->index_cache[prim][i].gen_nr, gen_nr, gen_type))
{
- pipe_buffer_reference( out_buf,
+ pipe_resource_reference( out_buf,
hwtnl->index_cache[prim][i].buffer );
if (DBG)
@@ -117,7 +117,7 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl,
}
else if (gen_type == U_GENERATE_REUSABLE)
{
- pipe_buffer_reference( &hwtnl->index_cache[prim][i].buffer,
+ pipe_resource_reference( &hwtnl->index_cache[prim][i].buffer,
NULL );
if (DBG)
@@ -149,7 +149,7 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl,
assert (smallest != IDX_CACHE_MAX);
- pipe_buffer_reference( &hwtnl->index_cache[prim][smallest].buffer,
+ pipe_resource_reference( &hwtnl->index_cache[prim][smallest].buffer,
NULL );
if (DBG)
@@ -171,7 +171,7 @@ static enum pipe_error retrieve_or_generate_indices( struct svga_hwtnl *hwtnl,
hwtnl->index_cache[prim][i].generate = generate;
hwtnl->index_cache[prim][i].gen_nr = gen_nr;
- pipe_buffer_reference( &hwtnl->index_cache[prim][i].buffer,
+ pipe_resource_reference( &hwtnl->index_cache[prim][i].buffer,
*out_buf );
if (DBG)
@@ -259,7 +259,7 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl,
return simple_draw_arrays( hwtnl, gen_prim, start, count );
}
else {
- struct pipe_buffer *gen_buf = NULL;
+ struct pipe_resource *gen_buf = NULL;
/* Need to draw as indexed primitive.
* Potentially need to run the gen func to build an index buffer.
@@ -288,7 +288,7 @@ svga_hwtnl_draw_arrays( struct svga_hwtnl *hwtnl,
done:
if (gen_buf)
- pipe_buffer_reference( &gen_buf, NULL );
+ pipe_resource_reference( &gen_buf, NULL );
return ret;
}
diff --git a/src/gallium/drivers/svga/svga_draw_elements.c b/src/gallium/drivers/svga/svga_draw_elements.c
index e8097d82f1..7ec4a058fc 100644
--- a/src/gallium/drivers/svga/svga_draw_elements.c
+++ b/src/gallium/drivers/svga/svga_draw_elements.c
@@ -30,7 +30,7 @@
#include "svga_cmd.h"
#include "svga_draw.h"
#include "svga_draw_private.h"
-#include "svga_screen_buffer.h"
+#include "svga_resource_buffer.h"
#include "svga_winsys.h"
#include "svga_context.h"
@@ -39,32 +39,32 @@
static enum pipe_error
translate_indices( struct svga_hwtnl *hwtnl,
- struct pipe_buffer *src,
+ struct pipe_resource *src,
unsigned offset,
unsigned nr,
unsigned index_size,
u_translate_func translate,
- struct pipe_buffer **out_buf )
+ struct pipe_resource **out_buf )
{
- struct pipe_screen *screen = hwtnl->svga->pipe.screen;
+ struct pipe_context *pipe = &hwtnl->svga->pipe;
+ struct pipe_transfer *src_transfer = NULL;
+ struct pipe_transfer *dst_transfer = NULL;
unsigned size = index_size * nr;
const void *src_map = NULL;
- struct pipe_buffer *dst = NULL;
+ struct pipe_resource *dst = NULL;
void *dst_map = NULL;
- dst = screen->buffer_create( screen, 32,
- PIPE_BUFFER_USAGE_INDEX |
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ,
- size );
+ dst = pipe_buffer_create( pipe->screen,
+ PIPE_BIND_INDEX_BUFFER,
+ size );
if (dst == NULL)
goto fail;
- src_map = pipe_buffer_map( screen, src, PIPE_BUFFER_USAGE_CPU_READ );
+ src_map = pipe_buffer_map( pipe, src, PIPE_TRANSFER_READ, &src_transfer );
if (src_map == NULL)
goto fail;
- dst_map = pipe_buffer_map( screen, dst, PIPE_BUFFER_USAGE_CPU_WRITE );
+ dst_map = pipe_buffer_map( pipe, dst, PIPE_TRANSFER_WRITE, &dst_transfer );
if (dst_map == NULL)
goto fail;
@@ -72,21 +72,21 @@ translate_indices( struct svga_hwtnl *hwtnl,
nr,
dst_map );
- pipe_buffer_unmap( screen, src );
- pipe_buffer_unmap( screen, dst );
+ pipe_buffer_unmap( pipe, src, src_transfer );
+ pipe_buffer_unmap( pipe, dst, dst_transfer );
*out_buf = dst;
return PIPE_OK;
fail:
if (src_map)
- screen->buffer_unmap( screen, src );
+ pipe_buffer_unmap( pipe, src, src_transfer );
if (dst_map)
- screen->buffer_unmap( screen, dst );
+ pipe_buffer_unmap( pipe, dst, dst_transfer );
if (dst)
- screen->buffer_destroy( dst );
+ pipe->screen->resource_destroy( pipe->screen, dst );
return PIPE_ERROR_OUT_OF_MEMORY;
}
@@ -97,7 +97,7 @@ fail:
enum pipe_error
svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
@@ -106,7 +106,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
unsigned count,
unsigned bias )
{
- struct pipe_buffer *upload_buffer = NULL;
+ struct pipe_resource *upload_buffer = NULL;
SVGA3dPrimitiveRange range;
unsigned hw_prim;
unsigned hw_count;
@@ -120,7 +120,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
if (index_buffer &&
svga_buffer_is_user_buffer(index_buffer))
{
- assert( index_buffer->size >= index_offset + count * index_size );
+ assert( index_buffer->width0 >= index_offset + count * index_size );
ret = u_upload_buffer( hwtnl->upload_ib,
index_offset,
@@ -151,7 +151,7 @@ svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
done:
if (upload_buffer)
- pipe_buffer_reference( &upload_buffer, NULL );
+ pipe_resource_reference( &upload_buffer, NULL );
return ret;
}
@@ -161,7 +161,7 @@ done:
enum pipe_error
svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
@@ -209,7 +209,7 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
gen_prim, start, count, bias );
}
else {
- struct pipe_buffer *gen_buf = NULL;
+ struct pipe_resource *gen_buf = NULL;
/* Need to allocate a new index buffer and run the translate
* func to populate it. Could potentially cache this translated
@@ -242,7 +242,7 @@ svga_hwtnl_draw_range_elements( struct svga_hwtnl *hwtnl,
done:
if (gen_buf)
- pipe_buffer_reference( &gen_buf, NULL );
+ pipe_resource_reference( &gen_buf, NULL );
return ret;
}
diff --git a/src/gallium/drivers/svga/svga_draw_private.h b/src/gallium/drivers/svga/svga_draw_private.h
index 9aa40e1664..b6fcd6854c 100644
--- a/src/gallium/drivers/svga/svga_draw_private.h
+++ b/src/gallium/drivers/svga/svga_draw_private.h
@@ -90,7 +90,7 @@ struct index_cache {
/* If non-null, this buffer is filled by calling
* generate(nr, map(buffer))
*/
- struct pipe_buffer *buffer;
+ struct pipe_resource *buffer;
};
#define QSZ 32
@@ -99,11 +99,11 @@ struct draw_cmd {
struct svga_winsys_context *swc;
SVGA3dVertexDecl vdecl[SVGA3D_INPUTREG_MAX];
- struct pipe_buffer *vdecl_vb[SVGA3D_INPUTREG_MAX];
+ struct pipe_resource *vdecl_vb[SVGA3D_INPUTREG_MAX];
unsigned vdecl_count;
SVGA3dPrimitiveRange prim[QSZ];
- struct pipe_buffer *prim_ib[QSZ];
+ struct pipe_resource *prim_ib[QSZ];
unsigned prim_count;
unsigned min_index[QSZ];
unsigned max_index[QSZ];
@@ -141,11 +141,11 @@ svga_hwtnl_prim( struct svga_hwtnl *hwtnl,
const SVGA3dPrimitiveRange *range,
unsigned min_index,
unsigned max_index,
- struct pipe_buffer *ib );
+ struct pipe_resource *ib );
enum pipe_error
svga_hwtnl_simple_draw_range_elements( struct svga_hwtnl *hwtnl,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
diff --git a/src/gallium/drivers/svga/svga_pipe_blit.c b/src/gallium/drivers/svga/svga_pipe_blit.c
index 4f575b06e6..889da29e28 100644
--- a/src/gallium/drivers/svga/svga_pipe_blit.c
+++ b/src/gallium/drivers/svga/svga_pipe_blit.c
@@ -23,10 +23,11 @@
*
**********************************************************/
-#include "svga_screen_texture.h"
+#include "svga_resource_texture.h"
#include "svga_context.h"
#include "svga_debug.h"
#include "svga_cmd.h"
+#include "svga_surface.h"
#define FILE_DEBUG_FLAG DEBUG_BLIT
diff --git a/src/gallium/drivers/svga/svga_pipe_clear.c b/src/gallium/drivers/svga/svga_pipe_clear.c
index bb1664fbed..cbff95c917 100644
--- a/src/gallium/drivers/svga/svga_pipe_clear.c
+++ b/src/gallium/drivers/svga/svga_pipe_clear.c
@@ -31,7 +31,7 @@
#include "svga_context.h"
#include "svga_state.h"
-#include "svga_screen_texture.h"
+#include "svga_surface.h"
static enum pipe_error
diff --git a/src/gallium/drivers/svga/svga_pipe_constants.c b/src/gallium/drivers/svga/svga_pipe_constants.c
index 73a0cd6b3a..2fa2142d07 100644
--- a/src/gallium/drivers/svga/svga_pipe_constants.c
+++ b/src/gallium/drivers/svga/svga_pipe_constants.c
@@ -45,14 +45,14 @@ struct svga_constbuf
static void svga_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
- struct pipe_buffer *buf)
+ struct pipe_resource *buf)
{
struct svga_context *svga = svga_context(pipe);
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
- pipe_buffer_reference( &svga->curr.cb[shader],
+ pipe_resource_reference( &svga->curr.cb[shader],
buf );
if (shader == PIPE_SHADER_FRAGMENT)
diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c
index f00cf23935..a05272b2e4 100644
--- a/src/gallium/drivers/svga/svga_pipe_draw.c
+++ b/src/gallium/drivers/svga/svga_pipe_draw.c
@@ -42,7 +42,7 @@
static enum pipe_error
retry_draw_range_elements( struct svga_context *svga,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
@@ -150,7 +150,7 @@ retry:
static void
svga_draw_range_elements( struct pipe_context *pipe,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned min_index,
unsigned max_index,
@@ -224,7 +224,7 @@ svga_draw_range_elements( struct pipe_context *pipe,
static void
svga_draw_elements( struct pipe_context *pipe,
- struct pipe_buffer *index_buffer,
+ struct pipe_resource *index_buffer,
unsigned index_size,
unsigned prim, unsigned start, unsigned count)
{
diff --git a/src/gallium/drivers/svga/svga_pipe_flush.c b/src/gallium/drivers/svga/svga_pipe_flush.c
index 7fa2205ae5..ab243aa6ec 100644
--- a/src/gallium/drivers/svga/svga_pipe_flush.c
+++ b/src/gallium/drivers/svga/svga_pipe_flush.c
@@ -25,7 +25,7 @@
#include "pipe/p_defines.h"
#include "svga_screen.h"
-#include "svga_screen_texture.h"
+#include "svga_surface.h"
#include "svga_context.h"
#include "svga_debug.h"
diff --git a/src/gallium/drivers/svga/svga_pipe_misc.c b/src/gallium/drivers/svga/svga_pipe_misc.c
index 2c43f9a24f..8c24fb302f 100644
--- a/src/gallium/drivers/svga/svga_pipe_misc.c
+++ b/src/gallium/drivers/svga/svga_pipe_misc.c
@@ -28,7 +28,7 @@
#include "util/u_inlines.h"
#include "svga_context.h"
-#include "svga_screen_texture.h"
+#include "svga_surface.h"
static void svga_set_scissor_state( struct pipe_context *pipe,
diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c
index 08283e3731..9c6f5858ba 100644
--- a/src/gallium/drivers/svga/svga_pipe_query.c
+++ b/src/gallium/drivers/svga/svga_pipe_query.c
@@ -30,7 +30,7 @@
#include "svga_cmd.h"
#include "svga_context.h"
#include "svga_screen.h"
-#include "svga_screen_buffer.h"
+#include "svga_resource_buffer.h"
#include "svga_winsys.h"
#include "svga_debug.h"
@@ -89,7 +89,7 @@ static struct pipe_query *svga_create_query( struct pipe_context *pipe,
sq->queryResult = (SVGA3dQueryResult *)sws->buffer_map(sws,
sq->hwbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PIPE_TRANSFER_WRITE);
if(!sq->queryResult)
goto no_query_result;
diff --git a/src/gallium/drivers/svga/svga_pipe_sampler.c b/src/gallium/drivers/svga/svga_pipe_sampler.c
index 82d525ca33..f44a0e1325 100644
--- a/src/gallium/drivers/svga/svga_pipe_sampler.c
+++ b/src/gallium/drivers/svga/svga_pipe_sampler.c
@@ -30,7 +30,7 @@
#include "tgsi/tgsi_parse.h"
#include "svga_context.h"
-#include "svga_screen_texture.h"
+#include "svga_resource_texture.h"
#include "svga_debug.h"
@@ -178,7 +178,7 @@ static void svga_delete_sampler_state(struct pipe_context *pipe,
static struct pipe_sampler_view *
svga_create_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templ)
{
struct pipe_sampler_view *view = CALLOC_STRUCT(pipe_sampler_view);
@@ -187,7 +187,7 @@ svga_create_sampler_view(struct pipe_context *pipe,
*view = *templ;
view->reference.count = 1;
view->texture = NULL;
- pipe_texture_reference(&view->texture, texture);
+ pipe_resource_reference(&view->texture, texture);
view->context = pipe;
}
@@ -199,7 +199,7 @@ static void
svga_sampler_view_destroy(struct pipe_context *pipe,
struct pipe_sampler_view *view)
{
- pipe_texture_reference(&view->texture, NULL);
+ pipe_resource_reference(&view->texture, NULL);
FREE(view);
}
diff --git a/src/gallium/drivers/svga/svga_pipe_vertex.c b/src/gallium/drivers/svga/svga_pipe_vertex.c
index 1715a47fc6..23808ad08e 100644
--- a/src/gallium/drivers/svga/svga_pipe_vertex.c
+++ b/src/gallium/drivers/svga/svga_pipe_vertex.c
@@ -30,7 +30,7 @@
#include "tgsi/tgsi_parse.h"
#include "svga_screen.h"
-#include "svga_screen_buffer.h"
+#include "svga_resource_buffer.h"
#include "svga_context.h"
@@ -49,13 +49,13 @@ static void svga_set_vertex_buffers(struct pipe_context *pipe,
/* Adjust refcounts */
for (i = 0; i < count; i++) {
- pipe_buffer_reference(&svga->curr.vb[i].buffer, buffers[i].buffer);
+ pipe_resource_reference(&svga->curr.vb[i].buffer, buffers[i].buffer);
if (svga_buffer_is_user_buffer(buffers[i].buffer))
any_user_buffer = TRUE;
}
for ( ; i < svga->curr.num_vertex_buffers; i++)
- pipe_buffer_reference(&svga->curr.vb[i].buffer, NULL);
+ pipe_resource_reference(&svga->curr.vb[i].buffer, NULL);
/* Copy remaining data */
memcpy(svga->curr.vb, buffers, count * sizeof buffers[0]);
@@ -102,7 +102,7 @@ void svga_cleanup_vertex_state( struct svga_context *svga )
unsigned i;
for (i = 0 ; i < svga->curr.num_vertex_buffers; i++)
- pipe_buffer_reference(&svga->curr.vb[i].buffer, NULL);
+ pipe_resource_reference(&svga->curr.vb[i].buffer, NULL);
}
diff --git a/src/gallium/drivers/svga/svga_resource.c b/src/gallium/drivers/svga/svga_resource.c
new file mode 100644
index 0000000000..15258c1966
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_resource.c
@@ -0,0 +1,55 @@
+#include "util/u_debug.h"
+
+#include "svga_resource.h"
+#include "svga_resource_buffer.h"
+#include "svga_resource_texture.h"
+#include "svga_context.h"
+#include "svga_screen.h"
+
+
+static struct pipe_resource *
+svga_resource_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ if (template->target == PIPE_BUFFER)
+ return svga_buffer_create(screen, template);
+ else
+ return svga_resource_create(screen, template);
+
+}
+
+static struct pipe_resource *
+svga_resource_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
+{
+ if (template->target == PIPE_BUFFER)
+ return NULL;
+ else
+ return svga_resource_from_handle(screen, template, whandle);
+}
+
+
+void
+svga_init_resource_functions(struct svga_context *svga)
+{
+ svga->pipe.get_transfer = u_get_transfer_vtbl;
+ svga->pipe.transfer_map = u_transfer_map_vtbl;
+ svga->pipe.transfer_flush_region = u_transfer_flush_region_vtbl;
+ svga->pipe.transfer_unmap = u_transfer_unmap_vtbl;
+ svga->pipe.transfer_destroy = u_transfer_destroy_vtbl;
+ svga->pipe.transfer_inline_write = u_transfer_inline_write_vtbl;
+}
+
+void
+svga_init_screen_resource_functions(struct svga_screen *is)
+{
+ is->screen.resource_create = svga_resource_create;
+ is->screen.resource_from_handle = svga_resource_from_handle;
+ is->screen.resource_get_handle = u_resource_get_handle_vtbl;
+ is->screen.resource_destroy = u_resource_destroy_vtbl;
+ is->screen.user_buffer_create = svga_user_buffer_create;
+}
+
+
+
diff --git a/src/gallium/state_trackers/xorg/xvmc/attributes.c b/src/gallium/drivers/svga/svga_resource.h
index 79a67838e6..851e3b50ce 100644
--- a/src/gallium/state_trackers/xorg/xvmc/attributes.c
+++ b/src/gallium/drivers/svga/svga_resource.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2009 Younes Manton.
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,22 +25,19 @@
*
**************************************************************************/
-#include <assert.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/Xvlib.h>
-#include <X11/extensions/XvMClib.h>
-
-XvAttribute* XvMCQueryAttributes(Display *dpy, XvMCContext *context, int *number)
-{
- return NULL;
-}
-
-Status XvMCSetAttribute(Display *dpy, XvMCContext *context, Atom attribute, int value)
-{
- return BadImplementation;
-}
-
-Status XvMCGetAttribute(Display *dpy, XvMCContext *context, Atom attribute, int *value)
-{
- return BadImplementation;
-}
+#ifndef SVGA_RESOURCE_H
+#define SVGA_RESOURCE_H
+
+struct svga_screen;
+
+#include "util/u_debug.h"
+
+struct svga_context;
+struct svga_screen;
+
+
+void svga_init_screen_resource_functions(struct svga_screen *is);
+void svga_init_resource_functions(struct svga_context *svga );
+
+
+#endif /* SVGA_RESOURCE_H */
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer.c
new file mode 100644
index 0000000000..cfa7d1015e
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_resource_buffer.c
@@ -0,0 +1,355 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_context.h"
+#include "svga_screen.h"
+#include "svga_resource_buffer.h"
+#include "svga_resource_buffer_upload.h"
+#include "svga_winsys.h"
+#include "svga_debug.h"
+
+
+/**
+ * Vertex and index buffers need hardware backing. Constant buffers
+ * do not. No other types of buffers currently supported.
+ */
+static INLINE boolean
+svga_buffer_needs_hw_storage(unsigned usage)
+{
+ return usage & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER);
+}
+
+
+static unsigned int
+svga_buffer_is_referenced( struct pipe_context *pipe,
+ struct pipe_resource *buf,
+ unsigned face, unsigned level)
+{
+ struct svga_screen *ss = svga_screen(pipe->screen);
+ struct svga_buffer *sbuf = svga_buffer(buf);
+
+ /**
+ * XXX: Check this.
+ * The screen may cache buffer writes, but when we map, we map out
+ * of those cached writes, so we don't need to set a
+ * PIPE_REFERENCED_FOR_WRITE flag for cached buffers.
+ */
+
+ if (!sbuf->handle || ss->sws->surface_is_flushed(ss->sws, sbuf->handle))
+ return PIPE_UNREFERENCED;
+
+ /**
+ * sws->surface_is_flushed() does not distinguish between read references
+ * and write references. So assume a reference is both,
+ * however, we make an exception for index- and vertex buffers, to avoid
+ * a flush in st_bufferobj_get_subdata, during display list replay.
+ */
+
+ if (sbuf->b.b.bind & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER))
+ return PIPE_REFERENCED_FOR_READ;
+
+ return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+}
+
+
+
+
+
+
+static void *
+svga_buffer_map_range( struct pipe_screen *screen,
+ struct pipe_resource *buf,
+ unsigned offset,
+ unsigned length,
+ unsigned usage )
+{
+ struct svga_screen *ss = svga_screen(screen);
+ struct svga_winsys_screen *sws = ss->sws;
+ struct svga_buffer *sbuf = svga_buffer( buf );
+ void *map;
+
+ if (!sbuf->swbuf && !sbuf->hwbuf) {
+ if (svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK) {
+ /*
+ * We can't create a hardware buffer big enough, so create a malloc
+ * buffer instead.
+ */
+ debug_printf("%s: failed to allocate %u KB of DMA, splitting DMA transfers\n",
+ __FUNCTION__,
+ (sbuf->b.b.width0 + 1023)/1024);
+
+ sbuf->swbuf = align_malloc(sbuf->b.b.width0, 16);
+ }
+ }
+
+ if (sbuf->swbuf) {
+ /* User/malloc buffer */
+ map = sbuf->swbuf;
+ }
+ else if (sbuf->hwbuf) {
+ map = sws->buffer_map(sws, sbuf->hwbuf, usage);
+ }
+ else {
+ map = NULL;
+ }
+
+ if(map) {
+ pipe_mutex_lock(ss->swc_mutex);
+
+ ++sbuf->map.count;
+
+ if (usage & PIPE_TRANSFER_WRITE) {
+ assert(sbuf->map.count <= 1);
+ sbuf->map.writing = TRUE;
+ if (usage & PIPE_TRANSFER_FLUSH_EXPLICIT)
+ sbuf->map.flush_explicit = TRUE;
+ }
+
+ pipe_mutex_unlock(ss->swc_mutex);
+ }
+
+ return map;
+}
+
+
+
+static void
+svga_buffer_flush_mapped_range( struct pipe_screen *screen,
+ struct pipe_resource *buf,
+ unsigned offset, unsigned length)
+{
+ struct svga_buffer *sbuf = svga_buffer( buf );
+ struct svga_screen *ss = svga_screen(screen);
+
+ pipe_mutex_lock(ss->swc_mutex);
+ assert(sbuf->map.writing);
+ if(sbuf->map.writing) {
+ assert(sbuf->map.flush_explicit);
+ svga_buffer_add_range(sbuf, offset, offset + length);
+ }
+ pipe_mutex_unlock(ss->swc_mutex);
+}
+
+static void
+svga_buffer_unmap( struct pipe_screen *screen,
+ struct pipe_resource *buf)
+{
+ struct svga_screen *ss = svga_screen(screen);
+ struct svga_winsys_screen *sws = ss->sws;
+ struct svga_buffer *sbuf = svga_buffer( buf );
+
+ pipe_mutex_lock(ss->swc_mutex);
+
+ assert(sbuf->map.count);
+ if(sbuf->map.count)
+ --sbuf->map.count;
+
+ if(sbuf->hwbuf)
+ sws->buffer_unmap(sws, sbuf->hwbuf);
+
+ if(sbuf->map.writing) {
+ if(!sbuf->map.flush_explicit) {
+ /* No mapped range was flushed -- flush the whole buffer */
+ SVGA_DBG(DEBUG_DMA, "flushing the whole buffer\n");
+
+ svga_buffer_add_range(sbuf, 0, sbuf->b.b.width0);
+ }
+
+ sbuf->map.writing = FALSE;
+ sbuf->map.flush_explicit = FALSE;
+ }
+
+ pipe_mutex_unlock(ss->swc_mutex);
+}
+
+
+
+static void
+svga_buffer_destroy( struct pipe_screen *screen,
+ struct pipe_resource *buf )
+{
+ struct svga_screen *ss = svga_screen(screen);
+ struct svga_buffer *sbuf = svga_buffer( buf );
+
+ assert(!p_atomic_read(&buf->reference.count));
+
+ assert(!sbuf->dma.pending);
+
+ if(sbuf->handle)
+ svga_buffer_destroy_host_surface(ss, sbuf);
+
+ if(sbuf->uploaded.buffer)
+ pipe_resource_reference(&sbuf->uploaded.buffer, NULL);
+
+ if(sbuf->hwbuf)
+ svga_buffer_destroy_hw_storage(ss, sbuf);
+
+ if(sbuf->swbuf && !sbuf->user)
+ align_free(sbuf->swbuf);
+
+ FREE(sbuf);
+}
+
+
+/* Keep the original code more or less intact, implement transfers in
+ * terms of the old functions.
+ */
+static void *
+svga_buffer_transfer_map( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ uint8_t *map = svga_buffer_map_range( pipe->screen,
+ transfer->resource,
+ transfer->box.x,
+ transfer->box.width,
+ transfer->usage );
+ if (map == NULL)
+ return NULL;
+
+ /* map_buffer() returned a pointer to the beginning of the buffer,
+ * but transfers are expected to return a pointer to just the
+ * region specified in the box.
+ */
+ return map + transfer->box.x;
+}
+
+
+
+static void svga_buffer_transfer_flush_region( struct pipe_context *pipe,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ assert(box->x + box->width <= transfer->box.width);
+
+ svga_buffer_flush_mapped_range(pipe->screen,
+ transfer->resource,
+ transfer->box.x + box->x,
+ box->width);
+}
+
+static void svga_buffer_transfer_unmap( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ svga_buffer_unmap(pipe->screen,
+ transfer->resource);
+}
+
+
+
+
+
+
+
+struct u_resource_vtbl svga_buffer_vtbl =
+{
+ u_default_resource_get_handle, /* get_handle */
+ svga_buffer_destroy, /* resource_destroy */
+ svga_buffer_is_referenced, /* is_resource_referenced */
+ u_default_get_transfer, /* get_transfer */
+ u_default_transfer_destroy, /* transfer_destroy */
+ svga_buffer_transfer_map, /* transfer_map */
+ svga_buffer_transfer_flush_region, /* transfer_flush_region */
+ svga_buffer_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+struct pipe_resource *
+svga_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ struct svga_screen *ss = svga_screen(screen);
+ struct svga_buffer *sbuf;
+
+ sbuf = CALLOC_STRUCT(svga_buffer);
+ if(!sbuf)
+ goto error1;
+
+ sbuf->b.b = *template;
+ sbuf->b.vtbl = &svga_buffer_vtbl;
+ pipe_reference_init(&sbuf->b.b.reference, 1);
+ sbuf->b.b.screen = screen;
+
+ if(svga_buffer_needs_hw_storage(template->bind)) {
+ if(svga_buffer_create_host_surface(ss, sbuf) != PIPE_OK)
+ goto error2;
+ }
+ else {
+ sbuf->swbuf = align_malloc(template->width0, 64);
+ if(!sbuf->swbuf)
+ goto error2;
+ }
+
+ return &sbuf->b.b;
+
+error2:
+ FREE(sbuf);
+error1:
+ return NULL;
+}
+
+struct pipe_resource *
+svga_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind)
+{
+ struct svga_buffer *sbuf;
+
+ sbuf = CALLOC_STRUCT(svga_buffer);
+ if(!sbuf)
+ goto no_sbuf;
+
+ pipe_reference_init(&sbuf->b.b.reference, 1);
+ sbuf->b.vtbl = &svga_buffer_vtbl;
+ sbuf->b.b.screen = screen;
+ sbuf->b.b.format = PIPE_FORMAT_R8_UNORM; /* ?? */
+ sbuf->b.b._usage = PIPE_USAGE_IMMUTABLE;
+ sbuf->b.b.bind = bind;
+ sbuf->b.b.width0 = bytes;
+ sbuf->b.b.height0 = 1;
+ sbuf->b.b.depth0 = 1;
+
+ sbuf->swbuf = ptr;
+ sbuf->user = TRUE;
+
+ return &sbuf->b.b;
+
+no_sbuf:
+ return NULL;
+}
+
+
+
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.h b/src/gallium/drivers/svga/svga_resource_buffer.h
index 8c862fa62d..55e7321184 100644
--- a/src/gallium/drivers/svga/svga_screen_buffer.h
+++ b/src/gallium/drivers/svga/svga_resource_buffer.h
@@ -29,14 +29,13 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
+#include "util/u_transfer.h"
#include "util/u_double_list.h"
#include "svga_screen_cache.h"
-#define SVGA_BUFFER_MAGIC 0x344f9005
-
/**
* Maximum number of discontiguous ranges
*/
@@ -49,6 +48,8 @@ struct svga_winsys_buffer;
struct svga_winsys_surface;
+extern struct u_resource_vtbl svga_buffer_vtbl;
+
struct svga_buffer_range
{
unsigned start;
@@ -61,12 +62,7 @@ struct svga_buffer_range
*/
struct svga_buffer
{
- struct pipe_buffer base;
-
- /**
- * Marker to detect bad casts in runtime.
- */
- uint32_t magic;
+ struct u_resource b;
/**
* Regular (non DMA'able) memory.
@@ -138,7 +134,7 @@ struct svga_buffer
* Information about uploaded version of user buffers.
*/
struct {
- struct pipe_buffer *buffer;
+ struct pipe_resource *buffer;
/**
* We combine multiple user buffers into the same hardware buffer. This
@@ -190,10 +186,10 @@ struct svga_buffer
static INLINE struct svga_buffer *
-svga_buffer(struct pipe_buffer *buffer)
+svga_buffer(struct pipe_resource *buffer)
{
if (buffer) {
- assert(((struct svga_buffer *)buffer)->magic == SVGA_BUFFER_MAGIC);
+ assert(((struct svga_buffer *)buffer)->b.vtbl == &svga_buffer_vtbl);
return (struct svga_buffer *)buffer;
}
return NULL;
@@ -205,14 +201,24 @@ svga_buffer(struct pipe_buffer *buffer)
* decide to use an alternate upload path for these buffers.
*/
static INLINE boolean
-svga_buffer_is_user_buffer( struct pipe_buffer *buffer )
+svga_buffer_is_user_buffer( struct pipe_resource *buffer )
{
return svga_buffer(buffer)->user;
}
-void
-svga_screen_init_buffer_functions(struct pipe_screen *screen);
+
+
+struct pipe_resource *
+svga_user_buffer_create(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned usage);
+
+struct pipe_resource *
+svga_buffer_create(struct pipe_screen *screen,
+ const struct pipe_resource *template);
+
/**
@@ -226,7 +232,7 @@ svga_screen_init_buffer_functions(struct pipe_screen *screen);
*/
struct svga_winsys_surface *
svga_buffer_handle(struct svga_context *svga,
- struct pipe_buffer *buf);
+ struct pipe_resource *buf);
void
svga_context_flush_buffers(struct svga_context *svga);
diff --git a/src/gallium/drivers/svga/svga_resource_buffer_host.c b/src/gallium/drivers/svga/svga_resource_buffer_host.c
new file mode 100644
index 0000000000..139597f9cb
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_resource_buffer_host.c
@@ -0,0 +1,2 @@
+
+
diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c
index 1ff6a3a5b3..acef60f464 100644
--- a/src/gallium/drivers/svga/svga_screen_buffer.c
+++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c
@@ -34,88 +34,14 @@
#include "svga_context.h"
#include "svga_screen.h"
-#include "svga_screen_buffer.h"
+#include "svga_resource_buffer.h"
+#include "svga_resource_buffer_upload.h"
#include "svga_winsys.h"
#include "svga_debug.h"
-/**
- * Vertex and index buffers have to be treated slightly differently from
- * regular guest memory regions because the SVGA device sees them as
- * surfaces, and the state tracker can create/destroy without the pipe
- * driver, therefore we must do the uploads from the vws.
+/* Allocate a winsys_buffer (ie. DMA, aka GMR memory).
*/
-static INLINE boolean
-svga_buffer_needs_hw_storage(unsigned usage)
-{
- return usage & (PIPE_BUFFER_USAGE_VERTEX | PIPE_BUFFER_USAGE_INDEX);
-}
-
-
-static INLINE enum pipe_error
-svga_buffer_create_host_surface(struct svga_screen *ss,
- struct svga_buffer *sbuf)
-{
- if(!sbuf->handle) {
- sbuf->key.flags = 0;
-
- sbuf->key.format = SVGA3D_BUFFER;
- if(sbuf->base.usage & PIPE_BUFFER_USAGE_VERTEX)
- sbuf->key.flags |= SVGA3D_SURFACE_HINT_VERTEXBUFFER;
- if(sbuf->base.usage & PIPE_BUFFER_USAGE_INDEX)
- sbuf->key.flags |= SVGA3D_SURFACE_HINT_INDEXBUFFER;
-
- sbuf->key.size.width = sbuf->base.size;
- sbuf->key.size.height = 1;
- sbuf->key.size.depth = 1;
-
- sbuf->key.numFaces = 1;
- sbuf->key.numMipLevels = 1;
- sbuf->key.cachable = 1;
-
- SVGA_DBG(DEBUG_DMA, "surface_create for buffer sz %d\n", sbuf->base.size);
-
- sbuf->handle = svga_screen_surface_create(ss, &sbuf->key);
- if(!sbuf->handle)
- return PIPE_ERROR_OUT_OF_MEMORY;
-
- /* Always set the discard flag on the first time the buffer is written
- * as svga_screen_surface_create might have passed a recycled host
- * buffer.
- */
- sbuf->dma.flags.discard = TRUE;
-
- SVGA_DBG(DEBUG_DMA, " --> got sid %p sz %d (buffer)\n", sbuf->handle, sbuf->base.size);
- }
-
- return PIPE_OK;
-}
-
-
-static INLINE void
-svga_buffer_destroy_host_surface(struct svga_screen *ss,
- struct svga_buffer *sbuf)
-{
- if(sbuf->handle) {
- SVGA_DBG(DEBUG_DMA, " ungrab sid %p sz %d\n", sbuf->handle, sbuf->base.size);
- svga_screen_surface_destroy(ss, &sbuf->key, &sbuf->handle);
- }
-}
-
-
-static INLINE void
-svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf)
-{
- struct svga_winsys_screen *sws = ss->sws;
-
- assert(!sbuf->map.count);
- assert(sbuf->hwbuf);
- if(sbuf->hwbuf) {
- sws->buffer_destroy(sws, sbuf->hwbuf);
- sbuf->hwbuf = NULL;
- }
-}
-
struct svga_winsys_buffer *
svga_winsys_buffer_create( struct svga_screen *ss,
unsigned alignment,
@@ -142,21 +68,36 @@ svga_winsys_buffer_create( struct svga_screen *ss,
}
+void
+svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf)
+{
+ struct svga_winsys_screen *sws = ss->sws;
+
+ assert(!sbuf->map.count);
+ assert(sbuf->hwbuf);
+ if(sbuf->hwbuf) {
+ sws->buffer_destroy(sws, sbuf->hwbuf);
+ sbuf->hwbuf = NULL;
+ }
+}
+
+
+
/**
* Allocate DMA'ble storage for the buffer.
*
* Called before mapping a buffer.
*/
-static INLINE enum pipe_error
+enum pipe_error
svga_buffer_create_hw_storage(struct svga_screen *ss,
struct svga_buffer *sbuf)
{
assert(!sbuf->user);
if(!sbuf->hwbuf) {
- unsigned alignment = sbuf->base.alignment;
+ unsigned alignment = 16;
unsigned usage = 0;
- unsigned size = sbuf->base.size;
+ unsigned size = sbuf->b.b.width0;
sbuf->hwbuf = svga_winsys_buffer_create(ss, alignment, usage, size);
if(!sbuf->hwbuf)
@@ -169,6 +110,58 @@ svga_buffer_create_hw_storage(struct svga_screen *ss,
}
+
+enum pipe_error
+svga_buffer_create_host_surface(struct svga_screen *ss,
+ struct svga_buffer *sbuf)
+{
+ if(!sbuf->handle) {
+ sbuf->key.flags = 0;
+
+ sbuf->key.format = SVGA3D_BUFFER;
+ if(sbuf->b.b.bind & PIPE_BIND_VERTEX_BUFFER)
+ sbuf->key.flags |= SVGA3D_SURFACE_HINT_VERTEXBUFFER;
+ if(sbuf->b.b.bind & PIPE_BIND_INDEX_BUFFER)
+ sbuf->key.flags |= SVGA3D_SURFACE_HINT_INDEXBUFFER;
+
+ sbuf->key.size.width = sbuf->b.b.width0;
+ sbuf->key.size.height = 1;
+ sbuf->key.size.depth = 1;
+
+ sbuf->key.numFaces = 1;
+ sbuf->key.numMipLevels = 1;
+ sbuf->key.cachable = 1;
+
+ SVGA_DBG(DEBUG_DMA, "surface_create for buffer sz %d\n", sbuf->b.b.width0);
+
+ sbuf->handle = svga_screen_surface_create(ss, &sbuf->key);
+ if(!sbuf->handle)
+ return PIPE_ERROR_OUT_OF_MEMORY;
+
+ /* Always set the discard flag on the first time the buffer is written
+ * as svga_screen_surface_create might have passed a recycled host
+ * buffer.
+ */
+ sbuf->dma.flags.discard = TRUE;
+
+ SVGA_DBG(DEBUG_DMA, " --> got sid %p sz %d (buffer)\n", sbuf->handle, sbuf->b.b.width0);
+ }
+
+ return PIPE_OK;
+}
+
+
+void
+svga_buffer_destroy_host_surface(struct svga_screen *ss,
+ struct svga_buffer *sbuf)
+{
+ if(sbuf->handle) {
+ SVGA_DBG(DEBUG_DMA, " ungrab sid %p sz %d\n", sbuf->handle, sbuf->b.b.width0);
+ svga_screen_surface_destroy(ss, &sbuf->key, &sbuf->handle);
+ }
+}
+
+
/**
* Variant of SVGA3D_BufferDMA which leaves the copy box temporarily in blank.
*/
@@ -186,15 +179,15 @@ svga_buffer_upload_command(struct svga_context *svga,
SVGA3dCmdSurfaceDMASuffix *pSuffix;
unsigned region_flags;
unsigned surface_flags;
- struct pipe_buffer *dummy;
+ struct pipe_resource *dummy;
if(transfer == SVGA3D_WRITE_HOST_VRAM) {
- region_flags = PIPE_BUFFER_USAGE_GPU_READ;
- surface_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
+ region_flags = SVGA_RELOC_READ;
+ surface_flags = SVGA_RELOC_WRITE;
}
else if(transfer == SVGA3D_READ_HOST_VRAM) {
- region_flags = PIPE_BUFFER_USAGE_GPU_WRITE;
- surface_flags = PIPE_BUFFER_USAGE_GPU_READ;
+ region_flags = SVGA_RELOC_WRITE;
+ surface_flags = SVGA_RELOC_READ;
}
else {
assert(0);
@@ -224,11 +217,11 @@ svga_buffer_upload_command(struct svga_context *svga,
/* Increment reference count */
dummy = NULL;
- pipe_buffer_reference(&dummy, &sbuf->base);
+ pipe_resource_reference(&dummy, &sbuf->b.b);
pSuffix = (SVGA3dCmdSurfaceDMASuffix *)((uint8_t*)cmd + sizeof *cmd + numBoxes * sizeof *boxes);
pSuffix->suffixSize = sizeof *pSuffix;
- pSuffix->maximumOffset = sbuf->base.size;
+ pSuffix->maximumOffset = sbuf->b.b.width0;
pSuffix->flags = sbuf->dma.flags;
SVGA_FIFOCommitAll(swc);
@@ -291,11 +284,12 @@ svga_buffer_upload_flush(struct svga_context *svga,
sbuf->dma.boxes = NULL;
/* Decrement reference count */
- pipe_reference(&(sbuf->base.reference), NULL);
+ pipe_reference(&(sbuf->b.b.reference), NULL);
sbuf = NULL;
}
+
/**
* Note a dirty range.
*
@@ -305,7 +299,7 @@ svga_buffer_upload_flush(struct svga_context *svga,
*
* We try to lump as many contiguous DMA transfers together as possible.
*/
-static void
+void
svga_buffer_add_range(struct svga_buffer *sbuf,
unsigned start,
unsigned end)
@@ -330,7 +324,7 @@ svga_buffer_add_range(struct svga_buffer *sbuf,
* Note that it is not this function task to care about overlapping ranges,
* as the GMR was already given so it is too late to do anything. Situations
* where overlapping ranges may pose a problem should be detected via
- * pipe_context::is_buffer_referenced and the context that refers to the
+ * pipe_context::is_resource_referenced and the context that refers to the
* buffer should be flushed.
*/
@@ -400,222 +394,6 @@ svga_buffer_add_range(struct svga_buffer *sbuf,
}
-static void *
-svga_buffer_map_range( struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned length,
- unsigned usage )
-{
- struct svga_screen *ss = svga_screen(screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_buffer *sbuf = svga_buffer( buf );
- void *map;
-
- if (!sbuf->swbuf && !sbuf->hwbuf) {
- if (svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK) {
- /*
- * We can't create a hardware buffer big enough, so create a malloc
- * buffer instead.
- */
-
- debug_printf("%s: failed to allocate %u KB of DMA, splitting DMA transfers\n",
- __FUNCTION__,
- (sbuf->base.size + 1023)/1024);
-
- sbuf->swbuf = align_malloc(sbuf->base.size, sbuf->base.alignment);
- }
- }
-
- if (sbuf->swbuf) {
- /* User/malloc buffer */
- map = sbuf->swbuf;
- }
- else if (sbuf->hwbuf) {
- map = sws->buffer_map(sws, sbuf->hwbuf, usage);
- }
- else {
- map = NULL;
- }
-
- if(map) {
- pipe_mutex_lock(ss->swc_mutex);
-
- ++sbuf->map.count;
-
- if (usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
- assert(sbuf->map.count <= 1);
- sbuf->map.writing = TRUE;
- if (usage & PIPE_BUFFER_USAGE_FLUSH_EXPLICIT)
- sbuf->map.flush_explicit = TRUE;
- }
-
- pipe_mutex_unlock(ss->swc_mutex);
- }
-
- return map;
-}
-
-static void
-svga_buffer_flush_mapped_range( struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset, unsigned length)
-{
- struct svga_buffer *sbuf = svga_buffer( buf );
- struct svga_screen *ss = svga_screen(screen);
-
- pipe_mutex_lock(ss->swc_mutex);
- assert(sbuf->map.writing);
- if(sbuf->map.writing) {
- assert(sbuf->map.flush_explicit);
- svga_buffer_add_range(sbuf, offset, offset + length);
- }
- pipe_mutex_unlock(ss->swc_mutex);
-}
-
-static void
-svga_buffer_unmap( struct pipe_screen *screen,
- struct pipe_buffer *buf)
-{
- struct svga_screen *ss = svga_screen(screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_buffer *sbuf = svga_buffer( buf );
-
- pipe_mutex_lock(ss->swc_mutex);
-
- assert(sbuf->map.count);
- if(sbuf->map.count)
- --sbuf->map.count;
-
- if(sbuf->hwbuf)
- sws->buffer_unmap(sws, sbuf->hwbuf);
-
- if(sbuf->map.writing) {
- if(!sbuf->map.flush_explicit) {
- /* No mapped range was flushed -- flush the whole buffer */
- SVGA_DBG(DEBUG_DMA, "flushing the whole buffer\n");
-
- svga_buffer_add_range(sbuf, 0, sbuf->base.size);
- }
-
- sbuf->map.writing = FALSE;
- sbuf->map.flush_explicit = FALSE;
- }
-
- pipe_mutex_unlock(ss->swc_mutex);
-}
-
-static void
-svga_buffer_destroy( struct pipe_buffer *buf )
-{
- struct svga_screen *ss = svga_screen(buf->screen);
- struct svga_buffer *sbuf = svga_buffer( buf );
-
- assert(!p_atomic_read(&buf->reference.count));
-
- assert(!sbuf->dma.pending);
-
- if(sbuf->handle)
- svga_buffer_destroy_host_surface(ss, sbuf);
-
- if(sbuf->uploaded.buffer)
- pipe_buffer_reference(&sbuf->uploaded.buffer, NULL);
-
- if(sbuf->hwbuf)
- svga_buffer_destroy_hw_storage(ss, sbuf);
-
- if(sbuf->swbuf && !sbuf->user)
- align_free(sbuf->swbuf);
-
- FREE(sbuf);
-}
-
-static struct pipe_buffer *
-svga_buffer_create(struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct svga_screen *ss = svga_screen(screen);
- struct svga_buffer *sbuf;
-
- assert(size);
- assert(alignment);
-
- sbuf = CALLOC_STRUCT(svga_buffer);
- if(!sbuf)
- goto error1;
-
- sbuf->magic = SVGA_BUFFER_MAGIC;
-
- pipe_reference_init(&sbuf->base.reference, 1);
- sbuf->base.screen = screen;
- sbuf->base.alignment = alignment;
- sbuf->base.usage = usage;
- sbuf->base.size = size;
-
- if(svga_buffer_needs_hw_storage(usage)) {
- if(svga_buffer_create_host_surface(ss, sbuf) != PIPE_OK)
- goto error2;
- }
- else {
- if(alignment < sizeof(void*))
- alignment = sizeof(void*);
-
- usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
-
- sbuf->swbuf = align_malloc(size, alignment);
- if(!sbuf->swbuf)
- goto error2;
- }
-
- return &sbuf->base;
-
-error2:
- FREE(sbuf);
-error1:
- return NULL;
-}
-
-static struct pipe_buffer *
-svga_user_buffer_create(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes)
-{
- struct svga_buffer *sbuf;
-
- sbuf = CALLOC_STRUCT(svga_buffer);
- if(!sbuf)
- goto no_sbuf;
-
- sbuf->magic = SVGA_BUFFER_MAGIC;
-
- sbuf->swbuf = ptr;
- sbuf->user = TRUE;
-
- pipe_reference_init(&sbuf->base.reference, 1);
- sbuf->base.screen = screen;
- sbuf->base.alignment = 1;
- sbuf->base.usage = 0;
- sbuf->base.size = bytes;
-
- return &sbuf->base;
-
-no_sbuf:
- return NULL;
-}
-
-
-void
-svga_screen_init_buffer_functions(struct pipe_screen *screen)
-{
- screen->buffer_create = svga_buffer_create;
- screen->user_buffer_create = svga_user_buffer_create;
- screen->buffer_map_range = svga_buffer_map_range;
- screen->buffer_flush_mapped_range = svga_buffer_flush_mapped_range;
- screen->buffer_unmap = svga_buffer_unmap;
- screen->buffer_destroy = svga_buffer_destroy;
-}
-
/**
* Copy the contents of the malloc buffer to a hardware buffer.
@@ -637,7 +415,7 @@ svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf)
return ret;
pipe_mutex_lock(ss->swc_mutex);
- map = ss->sws->buffer_map(ss->sws, sbuf->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+ map = ss->sws->buffer_map(ss->sws, sbuf->hwbuf, PIPE_TRANSFER_WRITE);
assert(map);
if(!map) {
pipe_mutex_unlock(ss->swc_mutex);
@@ -645,7 +423,7 @@ svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf)
return PIPE_ERROR;
}
- memcpy(map, sbuf->swbuf, sbuf->base.size);
+ memcpy(map, sbuf->swbuf, sbuf->b.b.width0);
ss->sws->buffer_unmap(ss->sws, sbuf->hwbuf);
/* This user/malloc buffer is now indistinguishable from a gpu buffer */
@@ -710,8 +488,8 @@ svga_buffer_upload_piecewise(struct svga_screen *ss,
offset, offset + size);
map = sws->buffer_map(sws, hwbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_DISCARD);
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_DISCARD);
assert(map);
if (map) {
memcpy(map, sbuf->swbuf, size);
@@ -745,9 +523,14 @@ svga_buffer_upload_piecewise(struct svga_screen *ss,
}
+
+
+/* Get (or create/upload) the winsys surface handle so that we can
+ * refer to this buffer in fifo commands.
+ */
struct svga_winsys_surface *
svga_buffer_handle(struct svga_context *svga,
- struct pipe_buffer *buf)
+ struct pipe_resource *buf)
{
struct pipe_screen *screen = svga->pipe.screen;
struct svga_screen *ss = svga_screen(screen);
@@ -828,45 +611,6 @@ svga_buffer_handle(struct svga_context *svga,
}
-struct pipe_buffer *
-svga_screen_buffer_wrap_surface(struct pipe_screen *screen,
- enum SVGA3dSurfaceFormat format,
- struct svga_winsys_surface *srf)
-{
- struct pipe_buffer *buf;
- struct svga_buffer *sbuf;
- struct svga_winsys_screen *sws = svga_winsys_screen(screen);
-
- buf = svga_buffer_create(screen, 0, SVGA_BUFFER_USAGE_WRAPPED, 0);
- if (!buf)
- return NULL;
-
- sbuf = svga_buffer(buf);
-
- /*
- * We are not the creator of this surface and therefore we must not
- * cache it for reuse. Set the cacheable flag to zero in the key to
- * prevent this.
- */
- sbuf->key.format = format;
- sbuf->key.cachable = 0;
- sws->surface_reference(sws, &sbuf->handle, srf);
-
- return buf;
-}
-
-
-struct svga_winsys_surface *
-svga_screen_buffer_get_winsys_surface(struct pipe_buffer *buffer)
-{
- struct svga_winsys_screen *sws = svga_winsys_screen(buffer->screen);
- struct svga_winsys_surface *vsurf = NULL;
-
- assert(svga_buffer(buffer)->key.cachable == 0);
- svga_buffer(buffer)->key.cachable = 0;
- sws->surface_reference(sws, &vsurf, svga_buffer(buffer)->handle);
- return vsurf;
-}
void
svga_context_flush_buffers(struct svga_context *svga)
@@ -879,7 +623,7 @@ svga_context_flush_buffers(struct svga_context *svga)
while(curr != &svga->dirty_buffers) {
sbuf = LIST_ENTRY(struct svga_buffer, curr, head);
- assert(p_atomic_read(&sbuf->base.reference.count) != 0);
+ assert(p_atomic_read(&sbuf->b.b.reference.count) != 0);
assert(sbuf->dma.pending);
svga_buffer_upload_flush(svga, sbuf);
diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.h b/src/gallium/drivers/svga/svga_resource_buffer_upload.h
new file mode 100644
index 0000000000..11df306526
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.h
@@ -0,0 +1,54 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#ifndef SVGA_BUFFER_UPLOAD_H
+#define SVGA_BUFFER_UPLOAD_H
+
+
+void
+svga_buffer_add_range(struct svga_buffer *sbuf,
+ unsigned start,
+ unsigned end);
+
+enum pipe_error
+svga_buffer_create_hw_storage(struct svga_screen *ss,
+ struct svga_buffer *sbuf);
+
+void
+svga_buffer_destroy_hw_storage(struct svga_screen *ss,
+ struct svga_buffer *sbuf);
+
+enum pipe_error
+svga_buffer_create_host_surface(struct svga_screen *ss,
+ struct svga_buffer *sbuf);
+
+void
+svga_buffer_destroy_host_surface(struct svga_screen *ss,
+ struct svga_buffer *sbuf);
+
+
+
+
+#endif /* SVGA_BUFFER_H */
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
new file mode 100644
index 0000000000..fd008bda09
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -0,0 +1,635 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_screen.h"
+#include "svga_context.h"
+#include "svga_resource_texture.h"
+#include "svga_resource_buffer.h"
+#include "svga_sampler_view.h"
+#include "svga_winsys.h"
+#include "svga_debug.h"
+
+#include <util/u_string.h>
+
+
+/* XXX: This isn't a real hardware flag, but just a hack for kernel to
+ * know about primary surfaces. Find a better way to accomplish this.
+ */
+#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
+
+
+static unsigned int
+svga_texture_is_referenced( struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ unsigned face, unsigned level)
+{
+ struct svga_texture *tex = svga_texture(texture);
+ struct svga_screen *ss = svga_screen(pipe->screen);
+
+ /**
+ * The screen does not cache texture writes.
+ */
+
+ if (!tex->handle || ss->sws->surface_is_flushed(ss->sws, tex->handle))
+ return PIPE_UNREFERENCED;
+
+ /**
+ * sws->surface_is_flushed() does not distinguish between read references
+ * and write references. So assume a reference is both.
+ */
+
+ return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+}
+
+
+
+/*
+ * Helper function and arrays
+ */
+
+SVGA3dSurfaceFormat
+svga_translate_format(enum pipe_format format)
+{
+ switch(format) {
+
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ return SVGA3D_A8R8G8B8;
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ return SVGA3D_X8R8G8B8;
+
+ /* Required for GL2.1:
+ */
+ case PIPE_FORMAT_B8G8R8A8_SRGB:
+ return SVGA3D_A8R8G8B8;
+
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ return SVGA3D_R5G6B5;
+ case PIPE_FORMAT_B5G5R5A1_UNORM:
+ return SVGA3D_A1R5G5B5;
+ case PIPE_FORMAT_B4G4R4A4_UNORM:
+ return SVGA3D_A4R4G4B4;
+
+
+ /* XXX: Doesn't seem to work properly.
+ case PIPE_FORMAT_Z32_UNORM:
+ return SVGA3D_Z_D32;
+ */
+ case PIPE_FORMAT_Z16_UNORM:
+ return SVGA3D_Z_D16;
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ return SVGA3D_Z_D24S8;
+ case PIPE_FORMAT_X8Z24_UNORM:
+ return SVGA3D_Z_D24X8;
+
+ case PIPE_FORMAT_A8_UNORM:
+ return SVGA3D_ALPHA8;
+ case PIPE_FORMAT_L8_UNORM:
+ return SVGA3D_LUMINANCE8;
+
+ case PIPE_FORMAT_DXT1_RGB:
+ case PIPE_FORMAT_DXT1_RGBA:
+ return SVGA3D_DXT1;
+ case PIPE_FORMAT_DXT3_RGBA:
+ return SVGA3D_DXT3;
+ case PIPE_FORMAT_DXT5_RGBA:
+ return SVGA3D_DXT5;
+
+ default:
+ return SVGA3D_FORMAT_INVALID;
+ }
+}
+
+
+SVGA3dSurfaceFormat
+svga_translate_format_render(enum pipe_format format)
+{
+ switch(format) {
+ case PIPE_FORMAT_B8G8R8A8_UNORM:
+ case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_B5G5R5A1_UNORM:
+ case PIPE_FORMAT_B4G4R4A4_UNORM:
+ case PIPE_FORMAT_B5G6R5_UNORM:
+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
+ case PIPE_FORMAT_X8Z24_UNORM:
+ case PIPE_FORMAT_Z32_UNORM:
+ case PIPE_FORMAT_Z16_UNORM:
+ case PIPE_FORMAT_L8_UNORM:
+ return svga_translate_format(format);
+
+#if 1
+ /* For on host conversion */
+ case PIPE_FORMAT_DXT1_RGB:
+ return SVGA3D_X8R8G8B8;
+ case PIPE_FORMAT_DXT1_RGBA:
+ case PIPE_FORMAT_DXT3_RGBA:
+ case PIPE_FORMAT_DXT5_RGBA:
+ return SVGA3D_A8R8G8B8;
+#endif
+
+ default:
+ return SVGA3D_FORMAT_INVALID;
+ }
+}
+
+
+static INLINE void
+svga_transfer_dma_band(struct svga_transfer *st,
+ SVGA3dTransferType transfer,
+ unsigned y, unsigned h, unsigned srcy)
+{
+ struct svga_texture *texture = svga_texture(st->base.resource);
+ struct svga_screen *screen = svga_screen(texture->b.b.screen);
+ SVGA3dCopyBox box;
+ enum pipe_error ret;
+
+ SVGA_DBG(DEBUG_DMA, "dma %s sid %p, face %u, (%u, %u, %u) - (%u, %u, %u), %ubpp\n",
+ transfer == SVGA3D_WRITE_HOST_VRAM ? "to" : "from",
+ texture->handle,
+ st->base.sr.face,
+ st->base.box.x,
+ y,
+ st->base.box.z,
+ st->base.box.x + st->base.box.width,
+ y + h,
+ st->base.box.z + 1,
+ util_format_get_blocksize(texture->b.b.format) * 8 /
+ (util_format_get_blockwidth(texture->b.b.format)*util_format_get_blockheight(texture->b.b.format)));
+
+ box.x = st->base.box.x;
+ box.y = y;
+ box.z = st->base.box.z;
+ box.w = st->base.box.width;
+ box.h = h;
+ box.d = 1;
+ box.srcx = 0;
+ box.srcy = srcy;
+ box.srcz = 0;
+
+ pipe_mutex_lock(screen->swc_mutex);
+ ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1);
+ if(ret != PIPE_OK) {
+ screen->swc->flush(screen->swc, NULL);
+ ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1);
+ assert(ret == PIPE_OK);
+ }
+ pipe_mutex_unlock(screen->swc_mutex);
+}
+
+
+static INLINE void
+svga_transfer_dma(struct svga_transfer *st,
+ SVGA3dTransferType transfer)
+{
+ struct svga_texture *texture = svga_texture(st->base.resource);
+ struct svga_screen *screen = svga_screen(texture->b.b.screen);
+ struct svga_winsys_screen *sws = screen->sws;
+ struct pipe_fence_handle *fence = NULL;
+
+ if (transfer == SVGA3D_READ_HOST_VRAM) {
+ SVGA_DBG(DEBUG_PERF, "%s: readback transfer\n", __FUNCTION__);
+ }
+
+
+ if(!st->swbuf) {
+ /* Do the DMA transfer in a single go */
+
+ svga_transfer_dma_band(st, transfer, st->base.box.y, st->base.box.height, 0);
+
+ if(transfer == SVGA3D_READ_HOST_VRAM) {
+ svga_screen_flush(screen, &fence);
+ sws->fence_finish(sws, fence, 0);
+ sws->fence_reference(sws, &fence, NULL);
+ }
+ }
+ else {
+ unsigned y, h, srcy;
+ unsigned blockheight = util_format_get_blockheight(st->base.resource->format);
+ h = st->hw_nblocksy * blockheight;
+ srcy = 0;
+ for(y = 0; y < st->base.box.height; y += h) {
+ unsigned offset, length;
+ void *hw, *sw;
+
+ if (y + h > st->base.box.height)
+ h = st->base.box.height - y;
+
+ /* Transfer band must be aligned to pixel block boundaries */
+ assert(y % blockheight == 0);
+ assert(h % blockheight == 0);
+
+ offset = y * st->base.stride / blockheight;
+ length = h * st->base.stride / blockheight;
+
+ sw = (uint8_t *)st->swbuf + offset;
+
+ if(transfer == SVGA3D_WRITE_HOST_VRAM) {
+ /* Wait for the previous DMAs to complete */
+ /* TODO: keep one DMA (at half the size) in the background */
+ if(y) {
+ svga_screen_flush(screen, &fence);
+ sws->fence_finish(sws, fence, 0);
+ sws->fence_reference(sws, &fence, NULL);
+ }
+
+ hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_WRITE);
+ assert(hw);
+ if(hw) {
+ memcpy(hw, sw, length);
+ sws->buffer_unmap(sws, st->hwbuf);
+ }
+ }
+
+ svga_transfer_dma_band(st, transfer, y, h, srcy);
+
+ if(transfer == SVGA3D_READ_HOST_VRAM) {
+ svga_screen_flush(screen, &fence);
+ sws->fence_finish(sws, fence, 0);
+
+ hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_READ);
+ assert(hw);
+ if(hw) {
+ memcpy(sw, hw, length);
+ sws->buffer_unmap(sws, st->hwbuf);
+ }
+ }
+ }
+ }
+}
+
+
+
+
+
+static boolean
+svga_texture_get_handle(struct pipe_screen *screen,
+ struct pipe_resource *texture,
+ struct winsys_handle *whandle)
+{
+ struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen);
+ unsigned stride;
+
+ assert(svga_texture(texture)->key.cachable == 0);
+ svga_texture(texture)->key.cachable = 0;
+ stride = util_format_get_nblocksx(texture->format, texture->width0) *
+ util_format_get_blocksize(texture->format);
+ return sws->surface_get_handle(sws, svga_texture(texture)->handle, stride, whandle);
+}
+
+
+static void
+svga_texture_destroy(struct pipe_screen *screen,
+ struct pipe_resource *pt)
+{
+ struct svga_screen *ss = svga_screen(screen);
+ struct svga_texture *tex = (struct svga_texture *)pt;
+
+ ss->texture_timestamp++;
+
+ svga_sampler_view_reference(&tex->cached_view, NULL);
+
+ /*
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
+ */
+ SVGA_DBG(DEBUG_DMA, "unref sid %p (texture)\n", tex->handle);
+ svga_screen_surface_destroy(ss, &tex->key, &tex->handle);
+
+ FREE(tex);
+}
+
+
+
+
+
+
+
+/* XXX: Still implementing this as if it was a screen function, but
+ * can now modify it to queue transfers on the context.
+ */
+static struct pipe_transfer *
+svga_texture_get_transfer(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
+{
+ struct svga_screen *ss = svga_screen(pipe->screen);
+ struct svga_winsys_screen *sws = ss->sws;
+ struct svga_transfer *st;
+ unsigned nblocksx = util_format_get_nblocksx(texture->format, box->width);
+ unsigned nblocksy = util_format_get_nblocksy(texture->format, box->height);
+
+ /* We can't map texture storage directly */
+ if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
+ return NULL;
+
+ st = CALLOC_STRUCT(svga_transfer);
+ if (!st)
+ return NULL;
+
+ pipe_resource_reference(&st->base.resource, texture);
+ st->base.sr = sr;
+ st->base.usage = usage;
+ st->base.box = *box;
+ st->base.stride = nblocksx*util_format_get_blocksize(texture->format);
+ st->base.slice_stride = 0;
+
+ st->hw_nblocksy = nblocksy;
+
+ st->hwbuf = svga_winsys_buffer_create(ss,
+ 1,
+ 0,
+ st->hw_nblocksy*st->base.stride);
+ while(!st->hwbuf && (st->hw_nblocksy /= 2)) {
+ st->hwbuf = svga_winsys_buffer_create(ss,
+ 1,
+ 0,
+ st->hw_nblocksy*st->base.stride);
+ }
+
+ if(!st->hwbuf)
+ goto no_hwbuf;
+
+ if(st->hw_nblocksy < nblocksy) {
+ /* We couldn't allocate a hardware buffer big enough for the transfer,
+ * so allocate regular malloc memory instead */
+ debug_printf("%s: failed to allocate %u KB of DMA, splitting into %u x %u KB DMA transfers\n",
+ __FUNCTION__,
+ (nblocksy*st->base.stride + 1023)/1024,
+ (nblocksy + st->hw_nblocksy - 1)/st->hw_nblocksy,
+ (st->hw_nblocksy*st->base.stride + 1023)/1024);
+ st->swbuf = MALLOC(nblocksy*st->base.stride);
+ if(!st->swbuf)
+ goto no_swbuf;
+ }
+
+ if (usage & PIPE_TRANSFER_READ)
+ svga_transfer_dma(st, SVGA3D_READ_HOST_VRAM);
+
+ return &st->base;
+
+no_swbuf:
+ sws->buffer_destroy(sws, st->hwbuf);
+no_hwbuf:
+ FREE(st);
+ return NULL;
+}
+
+
+/* XXX: Still implementing this as if it was a screen function, but
+ * can now modify it to queue transfers on the context.
+ */
+static void *
+svga_texture_transfer_map( struct pipe_context *pipe,
+ struct pipe_transfer *transfer )
+{
+ struct svga_screen *ss = svga_screen(pipe->screen);
+ struct svga_winsys_screen *sws = ss->sws;
+ struct svga_transfer *st = svga_transfer(transfer);
+
+ if(st->swbuf)
+ return st->swbuf;
+ else
+ /* The wait for read transfers already happened when svga_transfer_dma
+ * was called. */
+ return sws->buffer_map(sws, st->hwbuf, transfer->usage);
+}
+
+
+/* XXX: Still implementing this as if it was a screen function, but
+ * can now modify it to queue transfers on the context.
+ */
+static void
+svga_texture_transfer_unmap(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct svga_screen *ss = svga_screen(pipe->screen);
+ struct svga_winsys_screen *sws = ss->sws;
+ struct svga_transfer *st = svga_transfer(transfer);
+
+ if(!st->swbuf)
+ sws->buffer_unmap(sws, st->hwbuf);
+}
+
+
+static void
+svga_texture_transfer_destroy(struct pipe_context *pipe,
+ struct pipe_transfer *transfer)
+{
+ struct svga_texture *tex = svga_texture(transfer->resource);
+ struct svga_screen *ss = svga_screen(pipe->screen);
+ struct svga_winsys_screen *sws = ss->sws;
+ struct svga_transfer *st = svga_transfer(transfer);
+
+ if (st->base.usage & PIPE_TRANSFER_WRITE) {
+ svga_transfer_dma(st, SVGA3D_WRITE_HOST_VRAM);
+ ss->texture_timestamp++;
+ tex->view_age[transfer->sr.level] = ++(tex->age);
+ tex->defined[transfer->sr.face][transfer->sr.level] = TRUE;
+ }
+
+ pipe_resource_reference(&st->base.resource, NULL);
+ FREE(st->swbuf);
+ sws->buffer_destroy(sws, st->hwbuf);
+ FREE(st);
+}
+
+
+
+
+
+struct u_resource_vtbl svga_texture_vtbl =
+{
+ svga_texture_get_handle, /* get_handle */
+ svga_texture_destroy, /* resource_destroy */
+ svga_texture_is_referenced, /* is_resource_referenced */
+ svga_texture_get_transfer, /* get_transfer */
+ svga_texture_transfer_destroy, /* transfer_destroy */
+ svga_texture_transfer_map, /* transfer_map */
+ u_default_transfer_flush_region, /* transfer_flush_region */
+ svga_texture_transfer_unmap, /* transfer_unmap */
+ u_default_transfer_inline_write /* transfer_inline_write */
+};
+
+
+
+
+struct pipe_resource *
+svga_texture_create(struct pipe_screen *screen,
+ const struct pipe_resource *template)
+{
+ struct svga_screen *svgascreen = svga_screen(screen);
+ struct svga_texture *tex = CALLOC_STRUCT(svga_texture);
+
+ if (!tex)
+ goto error1;
+
+ tex->b.b = *template;
+ tex->b.vtbl = &svga_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
+
+ assert(template->last_level < SVGA_MAX_TEXTURE_LEVELS);
+ if(template->last_level >= SVGA_MAX_TEXTURE_LEVELS)
+ goto error2;
+
+ tex->key.flags = 0;
+ tex->key.size.width = template->width0;
+ tex->key.size.height = template->height0;
+ tex->key.size.depth = template->depth0;
+
+ if(template->target == PIPE_TEXTURE_CUBE) {
+ tex->key.flags |= SVGA3D_SURFACE_CUBEMAP;
+ tex->key.numFaces = 6;
+ }
+ else {
+ tex->key.numFaces = 1;
+ }
+
+ tex->key.cachable = 1;
+
+ if (template->bind & PIPE_BIND_SAMPLER_VIEW)
+ tex->key.flags |= SVGA3D_SURFACE_HINT_TEXTURE;
+
+ if (template->bind & PIPE_BIND_DISPLAY_TARGET) {
+ tex->key.cachable = 0;
+ }
+
+ if (template->bind & PIPE_BIND_SHARED) {
+ tex->key.cachable = 0;
+ }
+
+ if (template->bind & PIPE_BIND_SCANOUT) {
+ tex->key.flags |= SVGA3D_SURFACE_HINT_SCANOUT;
+ tex->key.cachable = 0;
+ }
+
+ /*
+ * XXX: Never pass the SVGA3D_SURFACE_HINT_RENDERTARGET hint. Mesa cannot
+ * know beforehand whether a texture will be used as a rendertarget or not
+ * and it always requests PIPE_BIND_RENDER_TARGET, therefore
+ * passing the SVGA3D_SURFACE_HINT_RENDERTARGET here defeats its purpose.
+ */
+#if 0
+ if((template->bind & PIPE_BIND_RENDER_TARGET) &&
+ !util_format_is_s3tc(template->format))
+ tex->key.flags |= SVGA3D_SURFACE_HINT_RENDERTARGET;
+#endif
+
+ if(template->bind & PIPE_BIND_DEPTH_STENCIL)
+ tex->key.flags |= SVGA3D_SURFACE_HINT_DEPTHSTENCIL;
+
+ tex->key.numMipLevels = template->last_level + 1;
+
+ tex->key.format = svga_translate_format(template->format);
+ if(tex->key.format == SVGA3D_FORMAT_INVALID)
+ goto error2;
+
+ SVGA_DBG(DEBUG_DMA, "surface_create for texture\n", tex->handle);
+ tex->handle = svga_screen_surface_create(svgascreen, &tex->key);
+ if (tex->handle)
+ SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture)\n", tex->handle);
+
+ return &tex->b.b;
+
+error2:
+ FREE(tex);
+error1:
+ return NULL;
+}
+
+
+
+
+struct pipe_resource *
+svga_texture_from_handle(struct pipe_screen *screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle)
+{
+ struct svga_winsys_screen *sws = svga_winsys_screen(screen);
+ struct svga_winsys_surface *srf;
+ struct svga_texture *tex;
+ enum SVGA3dSurfaceFormat format = 0;
+ assert(screen);
+
+ /* Only supports one type */
+ if (template->target != PIPE_TEXTURE_2D ||
+ template->last_level != 0 ||
+ template->depth0 != 1) {
+ return NULL;
+ }
+
+ srf = sws->surface_from_handle(sws, whandle, &format);
+
+ if (!srf)
+ return NULL;
+
+ if (svga_translate_format(template->format) != format) {
+ unsigned f1 = svga_translate_format(template->format);
+ unsigned f2 = format;
+
+ /* It's okay for XRGB and ARGB or depth with/out stencil to get mixed up */
+ if ( !( (f1 == SVGA3D_X8R8G8B8 && f2 == SVGA3D_A8R8G8B8) ||
+ (f1 == SVGA3D_A8R8G8B8 && f2 == SVGA3D_X8R8G8B8) ||
+ (f1 == SVGA3D_Z_D24X8 && f2 == SVGA3D_Z_D24S8) ) ) {
+ debug_printf("%s wrong format %u != %u\n", __FUNCTION__, f1, f2);
+ return NULL;
+ }
+ }
+
+ tex = CALLOC_STRUCT(svga_texture);
+ if (!tex)
+ return NULL;
+
+ tex->b.b = *template;
+ tex->b.vtbl = &svga_texture_vtbl;
+ pipe_reference_init(&tex->b.b.reference, 1);
+ tex->b.b.screen = screen;
+
+ if (format == SVGA3D_X8R8G8B8)
+ tex->b.b.format = PIPE_FORMAT_B8G8R8X8_UNORM;
+ else if (format == SVGA3D_A8R8G8B8)
+ tex->b.b.format = PIPE_FORMAT_B8G8R8A8_UNORM;
+ else {
+ /* ?? */
+ }
+
+ SVGA_DBG(DEBUG_DMA, "wrap surface sid %p\n", srf);
+
+ tex->key.cachable = 0;
+ tex->handle = srf;
+
+ return &tex->b.b;
+}
+
diff --git a/src/gallium/drivers/svga/svga_screen_texture.h b/src/gallium/drivers/svga/svga_resource_texture.h
index 96d035b12d..631937f2eb 100644
--- a/src/gallium/drivers/svga/svga_screen_texture.h
+++ b/src/gallium/drivers/svga/svga_resource_texture.h
@@ -30,6 +30,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
#include "util/u_inlines.h"
+#include "util/u_transfer.h"
#include "svga_screen_cache.h"
struct pipe_context;
@@ -42,41 +43,12 @@ enum SVGA3dSurfaceFormat;
#define SVGA_MAX_TEXTURE_LEVELS 16
-/**
- * A sampler's view into a texture
- *
- * We currently cache one sampler view on
- * the texture and in there by holding a reference
- * from the texture to the sampler view.
- *
- * Because of this we can not hold a refernce to the
- * texture from the sampler view. So the user
- * of the sampler views must make sure that the
- * texture has a reference take for as long as
- * the sampler view is refrenced.
- *
- * Just unreferencing the sampler_view before the
- * texture is enough.
- */
-struct svga_sampler_view
-{
- struct pipe_reference reference;
-
- struct pipe_texture *texture;
-
- int min_lod;
- int max_lod;
-
- unsigned age;
-
- struct svga_host_surface_cache_key key;
- struct svga_winsys_surface *handle;
-};
+extern struct u_resource_vtbl svga_texture_vtbl;
struct svga_texture
{
- struct pipe_texture base;
+ struct u_resource b;
boolean defined[6][SVGA_MAX_TEXTURE_LEVELS];
@@ -106,21 +78,9 @@ struct svga_texture
};
-struct svga_surface
-{
- struct pipe_surface base;
-
- struct svga_host_surface_cache_key key;
- struct svga_winsys_surface *handle;
-
- unsigned real_face;
- unsigned real_level;
- unsigned real_zslice;
-
- boolean dirty;
-};
-
+/* Note this is only used for texture (not buffer) transfers:
+ */
struct svga_transfer
{
struct pipe_transfer base;
@@ -136,18 +96,13 @@ struct svga_transfer
};
-static INLINE struct svga_texture *
-svga_texture(struct pipe_texture *texture)
+static INLINE struct svga_texture *svga_texture( struct pipe_resource *resource )
{
- return (struct svga_texture *)texture;
+ struct svga_texture *tex = (struct svga_texture *)resource;
+ assert(tex == NULL || tex->b.vtbl == &svga_texture_vtbl);
+ return tex;
}
-static INLINE struct svga_surface *
-svga_surface(struct pipe_surface *surface)
-{
- assert(surface);
- return (struct svga_surface *)surface;
-}
static INLINE struct svga_transfer *
svga_transfer(struct pipe_transfer *transfer)
@@ -156,38 +111,18 @@ svga_transfer(struct pipe_transfer *transfer)
return (struct svga_transfer *)transfer;
}
-extern struct svga_sampler_view *
-svga_get_tex_sampler_view(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned min_lod, unsigned max_lod);
-
-void
-svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v);
-
-void
-svga_destroy_sampler_view_priv(struct svga_sampler_view *v);
-static INLINE void
-svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v)
-{
- struct svga_sampler_view *old = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &v->reference))
- svga_destroy_sampler_view_priv(old);
- *ptr = v;
-}
-extern void
-svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf);
+struct pipe_resource *
+svga_texture_create(struct pipe_screen *screen,
+ const struct pipe_resource *template);
-extern boolean
-svga_surface_needs_propagation(struct pipe_surface *surf);
+struct pipe_resource *
+svga_texture_from_handle(struct pipe_screen * screen,
+ const struct pipe_resource *template,
+ struct winsys_handle *whandle);
-extern void
-svga_screen_init_texture_functions(struct pipe_screen *screen);
-void
-svga_init_texture_functions(struct pipe_context *pipe);
enum SVGA3dSurfaceFormat
svga_translate_format(enum pipe_format format);
diff --git a/src/gallium/drivers/svga/svga_sampler_view.c b/src/gallium/drivers/svga/svga_sampler_view.c
new file mode 100644
index 0000000000..5386db7d1b
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_sampler_view.c
@@ -0,0 +1,199 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_screen.h"
+#include "svga_context.h"
+#include "svga_resource_texture.h"
+#include "svga_sampler_view.h"
+#include "svga_winsys.h"
+#include "svga_debug.h"
+#include "svga_surface.h"
+
+#include <util/u_string.h>
+
+
+struct svga_sampler_view *
+svga_get_tex_sampler_view(struct pipe_context *pipe,
+ struct pipe_resource *pt,
+ unsigned min_lod, unsigned max_lod)
+{
+ struct svga_screen *ss = svga_screen(pt->screen);
+ struct svga_texture *tex = svga_texture(pt);
+ struct svga_sampler_view *sv = NULL;
+ SVGA3dSurfaceFormat format = svga_translate_format(pt->format);
+ boolean view = TRUE;
+
+ assert(pt);
+ assert(min_lod >= 0);
+ assert(min_lod <= max_lod);
+ assert(max_lod <= pt->last_level);
+
+
+ /* Is a view needed */
+ {
+ /*
+ * Can't control max lod. For first level views and when we only
+ * look at one level we disable mip filtering to achive the same
+ * results as a view.
+ */
+ if (min_lod == 0 && max_lod >= pt->last_level)
+ view = FALSE;
+
+ if (util_format_is_s3tc(pt->format) && view) {
+ format = svga_translate_format_render(pt->format);
+ }
+
+ if (ss->debug.no_sampler_view)
+ view = FALSE;
+
+ if (ss->debug.force_sampler_view)
+ view = TRUE;
+ }
+
+ /* First try the cache */
+ if (view) {
+ pipe_mutex_lock(ss->tex_mutex);
+ if (tex->cached_view &&
+ tex->cached_view->min_lod == min_lod &&
+ tex->cached_view->max_lod == max_lod) {
+ svga_sampler_view_reference(&sv, tex->cached_view);
+ pipe_mutex_unlock(ss->tex_mutex);
+ SVGA_DBG(DEBUG_VIEWS, "svga: Sampler view: reuse %p, %u %u, last %u\n",
+ pt, min_lod, max_lod, pt->last_level);
+ svga_validate_sampler_view(svga_context(pipe), sv);
+ return sv;
+ }
+ pipe_mutex_unlock(ss->tex_mutex);
+ }
+
+ sv = CALLOC_STRUCT(svga_sampler_view);
+ pipe_reference_init(&sv->reference, 1);
+ pipe_resource_reference(&sv->texture, pt);
+ sv->min_lod = min_lod;
+ sv->max_lod = max_lod;
+
+ /* No view needed just use the whole texture */
+ if (!view) {
+ SVGA_DBG(DEBUG_VIEWS,
+ "svga: Sampler view: no %p, mips %u..%u, nr %u, size (%ux%ux%u), last %u\n",
+ pt, min_lod, max_lod,
+ max_lod - min_lod + 1,
+ pt->width0,
+ pt->height0,
+ pt->depth0,
+ pt->last_level);
+ sv->key.cachable = 0;
+ sv->handle = tex->handle;
+ return sv;
+ }
+
+ SVGA_DBG(DEBUG_VIEWS,
+ "svga: Sampler view: yes %p, mips %u..%u, nr %u, size (%ux%ux%u), last %u\n",
+ pt, min_lod, max_lod,
+ max_lod - min_lod + 1,
+ pt->width0,
+ pt->height0,
+ pt->depth0,
+ pt->last_level);
+
+ sv->age = tex->age;
+ sv->handle = svga_texture_view_surface(pipe, tex, format,
+ min_lod,
+ max_lod - min_lod + 1,
+ -1, -1,
+ &sv->key);
+
+ if (!sv->handle) {
+ assert(0);
+ sv->key.cachable = 0;
+ sv->handle = tex->handle;
+ return sv;
+ }
+
+ pipe_mutex_lock(ss->tex_mutex);
+ svga_sampler_view_reference(&tex->cached_view, sv);
+ pipe_mutex_unlock(ss->tex_mutex);
+
+ return sv;
+}
+
+void
+svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v)
+{
+ struct svga_texture *tex = svga_texture(v->texture);
+ unsigned numFaces;
+ unsigned age = 0;
+ int i, k;
+
+ assert(svga);
+
+ if (v->handle == tex->handle)
+ return;
+
+ age = tex->age;
+
+ if(tex->b.b.target == PIPE_TEXTURE_CUBE)
+ numFaces = 6;
+ else
+ numFaces = 1;
+
+ for (i = v->min_lod; i <= v->max_lod; i++) {
+ for (k = 0; k < numFaces; k++) {
+ if (v->age < tex->view_age[i])
+ svga_texture_copy_handle(svga, NULL,
+ tex->handle, 0, 0, 0, i, k,
+ v->handle, 0, 0, 0, i - v->min_lod, k,
+ u_minify(tex->b.b.width0, i),
+ u_minify(tex->b.b.height0, i),
+ u_minify(tex->b.b.depth0, i));
+ }
+ }
+
+ v->age = age;
+}
+
+void
+svga_destroy_sampler_view_priv(struct svga_sampler_view *v)
+{
+ struct svga_texture *tex = svga_texture(v->texture);
+
+ if(v->handle != tex->handle) {
+ struct svga_screen *ss = svga_screen(v->texture->screen);
+ SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
+ svga_screen_surface_destroy(ss, &v->key, &v->handle);
+ }
+ pipe_resource_reference(&v->texture, NULL);
+ FREE(v);
+}
diff --git a/src/gallium/drivers/svga/svga_sampler_view.h b/src/gallium/drivers/svga/svga_sampler_view.h
new file mode 100644
index 0000000000..e64665f2e5
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_sampler_view.h
@@ -0,0 +1,97 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#ifndef SVGA_SAMPLER_VIEW_H
+#define SVGA_SAMPLER_VIEW_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+#include "util/u_inlines.h"
+#include "svga_screen_cache.h"
+
+struct pipe_context;
+struct pipe_screen;
+struct svga_context;
+struct svga_winsys_surface;
+enum SVGA3dSurfaceFormat;
+
+
+/**
+ * A sampler's view into a texture
+ *
+ * We currently cache one sampler view on
+ * the texture and in there by holding a reference
+ * from the texture to the sampler view.
+ *
+ * Because of this we can not hold a refernce to the
+ * texture from the sampler view. So the user
+ * of the sampler views must make sure that the
+ * texture has a reference take for as long as
+ * the sampler view is refrenced.
+ *
+ * Just unreferencing the sampler_view before the
+ * texture is enough.
+ */
+struct svga_sampler_view
+{
+ struct pipe_reference reference;
+
+ struct pipe_resource *texture;
+
+ int min_lod;
+ int max_lod;
+
+ unsigned age;
+
+ struct svga_host_surface_cache_key key;
+ struct svga_winsys_surface *handle;
+};
+
+
+
+extern struct svga_sampler_view *
+svga_get_tex_sampler_view(struct pipe_context *pipe,
+ struct pipe_resource *pt,
+ unsigned min_lod, unsigned max_lod);
+
+void
+svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v);
+
+void
+svga_destroy_sampler_view_priv(struct svga_sampler_view *v);
+
+static INLINE void
+svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v)
+{
+ struct svga_sampler_view *old = *ptr;
+
+ if (pipe_reference(&(*ptr)->reference, &v->reference))
+ svga_destroy_sampler_view_priv(old);
+ *ptr = v;
+}
+
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index 9a2e7c6f5b..9a75e456cf 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -31,8 +31,9 @@
#include "svga_winsys.h"
#include "svga_context.h"
#include "svga_screen.h"
-#include "svga_screen_texture.h"
-#include "svga_screen_buffer.h"
+#include "svga_resource_texture.h"
+#include "svga_resource_buffer.h"
+#include "svga_resource.h"
#include "svga_debug.h"
#include "svga3d_shaderdefs.h"
@@ -248,7 +249,7 @@ svga_is_format_supported( struct pipe_screen *screen,
assert(tex_usage);
/* Override host capabilities */
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) {
+ if (tex_usage & PIPE_BIND_RENDER_TARGET) {
switch(format) {
/* Often unsupported/problematic. This means we end up with the same
@@ -278,11 +279,11 @@ svga_is_format_supported( struct pipe_screen *screen,
SVGA3dSurfaceFormatCaps mask;
mask.value = 0;
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ if (tex_usage & PIPE_BIND_RENDER_TARGET)
mask.offscreenRenderTarget = 1;
- if (tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
+ if (tex_usage & PIPE_BIND_DEPTH_STENCIL)
mask.zStencil = 1;
- if (tex_usage & PIPE_TEXTURE_USAGE_SAMPLER)
+ if (tex_usage & PIPE_BIND_SAMPLER_VIEW)
mask.texture = 1;
if ((result.u & mask.value) == mask.value)
@@ -295,7 +296,7 @@ svga_is_format_supported( struct pipe_screen *screen,
* duplicated list of supported formats which is prone to getting
* out of sync:
*/
- if(tex_usage & (PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
+ if(tex_usage & (PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL))
return svga_translate_format_render(format) != SVGA3D_FORMAT_INVALID;
else
return svga_translate_format(format) != SVGA3D_FORMAT_INVALID;
@@ -397,8 +398,7 @@ svga_screen_create(struct svga_winsys_screen *sws)
screen->fence_finish = svga_fence_finish;
svgascreen->sws = sws;
- svga_screen_init_texture_functions(screen);
- svga_screen_init_buffer_functions(screen);
+ svga_init_screen_resource_functions(svgascreen);
svgascreen->use_ps30 =
sws->get_cap(sws, SVGA3D_DEVCAP_FRAGMENT_SHADER_VERSION, &result) &&
diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c
deleted file mode 100644
index 811c746695..0000000000
--- a/src/gallium/drivers/svga/svga_screen_texture.c
+++ /dev/null
@@ -1,1097 +0,0 @@
-/**********************************************************
- * Copyright 2008-2009 VMware, Inc. All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
-
-#include "svga_cmd.h"
-
-#include "pipe/p_state.h"
-#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
-#include "os/os_thread.h"
-#include "util/u_format.h"
-#include "util/u_math.h"
-#include "util/u_memory.h"
-
-#include "svga_screen.h"
-#include "svga_context.h"
-#include "svga_screen_texture.h"
-#include "svga_screen_buffer.h"
-#include "svga_winsys.h"
-#include "svga_debug.h"
-#include "svga_screen_buffer.h"
-
-
-/* XXX: This isn't a real hardware flag, but just a hack for kernel to
- * know about primary surfaces. Find a better way to accomplish this.
- */
-#define SVGA3D_SURFACE_HINT_SCANOUT (1 << 9)
-
-
-/*
- * Helper function and arrays
- */
-
-SVGA3dSurfaceFormat
-svga_translate_format(enum pipe_format format)
-{
- switch(format) {
-
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- return SVGA3D_A8R8G8B8;
- case PIPE_FORMAT_B8G8R8X8_UNORM:
- return SVGA3D_X8R8G8B8;
-
- /* Required for GL2.1:
- */
- case PIPE_FORMAT_B8G8R8A8_SRGB:
- return SVGA3D_A8R8G8B8;
-
- case PIPE_FORMAT_B5G6R5_UNORM:
- return SVGA3D_R5G6B5;
- case PIPE_FORMAT_B5G5R5A1_UNORM:
- return SVGA3D_A1R5G5B5;
- case PIPE_FORMAT_B4G4R4A4_UNORM:
- return SVGA3D_A4R4G4B4;
-
-
- /* XXX: Doesn't seem to work properly.
- case PIPE_FORMAT_Z32_UNORM:
- return SVGA3D_Z_D32;
- */
- case PIPE_FORMAT_Z16_UNORM:
- return SVGA3D_Z_D16;
- case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
- return SVGA3D_Z_D24S8;
- case PIPE_FORMAT_X8Z24_UNORM:
- return SVGA3D_Z_D24X8;
-
- case PIPE_FORMAT_A8_UNORM:
- return SVGA3D_ALPHA8;
- case PIPE_FORMAT_L8_UNORM:
- return SVGA3D_LUMINANCE8;
-
- case PIPE_FORMAT_DXT1_RGB:
- case PIPE_FORMAT_DXT1_RGBA:
- return SVGA3D_DXT1;
- case PIPE_FORMAT_DXT3_RGBA:
- return SVGA3D_DXT3;
- case PIPE_FORMAT_DXT5_RGBA:
- return SVGA3D_DXT5;
-
- default:
- return SVGA3D_FORMAT_INVALID;
- }
-}
-
-
-SVGA3dSurfaceFormat
-svga_translate_format_render(enum pipe_format format)
-{
- switch(format) {
- case PIPE_FORMAT_B8G8R8A8_UNORM:
- case PIPE_FORMAT_B8G8R8X8_UNORM:
- case PIPE_FORMAT_B5G5R5A1_UNORM:
- case PIPE_FORMAT_B4G4R4A4_UNORM:
- case PIPE_FORMAT_B5G6R5_UNORM:
- case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
- case PIPE_FORMAT_X8Z24_UNORM:
- case PIPE_FORMAT_Z32_UNORM:
- case PIPE_FORMAT_Z16_UNORM:
- case PIPE_FORMAT_L8_UNORM:
- return svga_translate_format(format);
-
-#if 1
- /* For on host conversion */
- case PIPE_FORMAT_DXT1_RGB:
- return SVGA3D_X8R8G8B8;
- case PIPE_FORMAT_DXT1_RGBA:
- case PIPE_FORMAT_DXT3_RGBA:
- case PIPE_FORMAT_DXT5_RGBA:
- return SVGA3D_A8R8G8B8;
-#endif
-
- default:
- return SVGA3D_FORMAT_INVALID;
- }
-}
-
-
-static INLINE void
-svga_transfer_dma_band(struct svga_transfer *st,
- SVGA3dTransferType transfer,
- unsigned y, unsigned h, unsigned srcy)
-{
- struct svga_texture *texture = svga_texture(st->base.texture);
- struct svga_screen *screen = svga_screen(texture->base.screen);
- SVGA3dCopyBox box;
- enum pipe_error ret;
-
- SVGA_DBG(DEBUG_DMA, "dma %s sid %p, face %u, (%u, %u, %u) - (%u, %u, %u), %ubpp\n",
- transfer == SVGA3D_WRITE_HOST_VRAM ? "to" : "from",
- texture->handle,
- st->base.face,
- st->base.x,
- y,
- st->base.zslice,
- st->base.x + st->base.width,
- y + h,
- st->base.zslice + 1,
- util_format_get_blocksize(texture->base.format)*8/
- (util_format_get_blockwidth(texture->base.format)*util_format_get_blockheight(texture->base.format)));
-
- box.x = st->base.x;
- box.y = y;
- box.z = st->base.zslice;
- box.w = st->base.width;
- box.h = h;
- box.d = 1;
- box.srcx = 0;
- box.srcy = srcy;
- box.srcz = 0;
-
- pipe_mutex_lock(screen->swc_mutex);
- ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1);
- if(ret != PIPE_OK) {
- screen->swc->flush(screen->swc, NULL);
- ret = SVGA3D_SurfaceDMA(screen->swc, st, transfer, &box, 1);
- assert(ret == PIPE_OK);
- }
- pipe_mutex_unlock(screen->swc_mutex);
-}
-
-
-static INLINE void
-svga_transfer_dma(struct svga_transfer *st,
- SVGA3dTransferType transfer)
-{
- struct svga_texture *texture = svga_texture(st->base.texture);
- struct svga_screen *screen = svga_screen(texture->base.screen);
- struct svga_winsys_screen *sws = screen->sws;
- struct pipe_fence_handle *fence = NULL;
-
- if (transfer == SVGA3D_READ_HOST_VRAM) {
- SVGA_DBG(DEBUG_PERF, "%s: readback transfer\n", __FUNCTION__);
- }
-
-
- if(!st->swbuf) {
- /* Do the DMA transfer in a single go */
-
- svga_transfer_dma_band(st, transfer, st->base.y, st->base.height, 0);
-
- if(transfer == SVGA3D_READ_HOST_VRAM) {
- svga_screen_flush(screen, &fence);
- sws->fence_finish(sws, fence, 0);
- sws->fence_reference(sws, &fence, NULL);
- }
- }
- else {
- unsigned y, h, srcy;
- unsigned blockheight = util_format_get_blockheight(st->base.texture->format);
- h = st->hw_nblocksy * blockheight;
- srcy = 0;
- for(y = 0; y < st->base.height; y += h) {
- unsigned offset, length;
- void *hw, *sw;
-
- if (y + h > st->base.height)
- h = st->base.height - y;
-
- /* Transfer band must be aligned to pixel block boundaries */
- assert(y % blockheight == 0);
- assert(h % blockheight == 0);
-
- offset = y * st->base.stride / blockheight;
- length = h * st->base.stride / blockheight;
-
- sw = (uint8_t *)st->swbuf + offset;
-
- if(transfer == SVGA3D_WRITE_HOST_VRAM) {
- /* Wait for the previous DMAs to complete */
- /* TODO: keep one DMA (at half the size) in the background */
- if(y) {
- svga_screen_flush(screen, &fence);
- sws->fence_finish(sws, fence, 0);
- sws->fence_reference(sws, &fence, NULL);
- }
-
- hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
- assert(hw);
- if(hw) {
- memcpy(hw, sw, length);
- sws->buffer_unmap(sws, st->hwbuf);
- }
- }
-
- svga_transfer_dma_band(st, transfer, y, h, srcy);
-
- if(transfer == SVGA3D_READ_HOST_VRAM) {
- svga_screen_flush(screen, &fence);
- sws->fence_finish(sws, fence, 0);
-
- hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_READ);
- assert(hw);
- if(hw) {
- memcpy(sw, hw, length);
- sws->buffer_unmap(sws, st->hwbuf);
- }
- }
- }
- }
-}
-
-
-static struct pipe_texture *
-svga_texture_create(struct pipe_screen *screen,
- const struct pipe_texture *templat)
-{
- struct svga_screen *svgascreen = svga_screen(screen);
- struct svga_texture *tex = CALLOC_STRUCT(svga_texture);
- unsigned width, height, depth;
- unsigned level;
-
- if (!tex)
- goto error1;
-
- tex->base = *templat;
- pipe_reference_init(&tex->base.reference, 1);
- tex->base.screen = screen;
-
- assert(templat->last_level < SVGA_MAX_TEXTURE_LEVELS);
- if(templat->last_level >= SVGA_MAX_TEXTURE_LEVELS)
- goto error2;
-
- width = templat->width0;
- height = templat->height0;
- depth = templat->depth0;
- for(level = 0; level <= templat->last_level; ++level) {
- width = u_minify(width, 1);
- height = u_minify(height, 1);
- depth = u_minify(depth, 1);
- }
-
- tex->key.flags = 0;
- tex->key.size.width = templat->width0;
- tex->key.size.height = templat->height0;
- tex->key.size.depth = templat->depth0;
-
- if(templat->target == PIPE_TEXTURE_CUBE) {
- tex->key.flags |= SVGA3D_SURFACE_CUBEMAP;
- tex->key.numFaces = 6;
- }
- else {
- tex->key.numFaces = 1;
- }
-
- tex->key.cachable = 1;
-
- if(templat->tex_usage & PIPE_TEXTURE_USAGE_SAMPLER)
- tex->key.flags |= SVGA3D_SURFACE_HINT_TEXTURE;
-
- if(templat->tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
- tex->key.cachable = 0;
- }
-
- if(templat->tex_usage & PIPE_TEXTURE_USAGE_SHARED) {
- tex->key.cachable = 0;
- }
-
- if(templat->tex_usage & PIPE_TEXTURE_USAGE_SCANOUT) {
- tex->key.flags |= SVGA3D_SURFACE_HINT_SCANOUT;
- tex->key.cachable = 0;
- }
-
- /*
- * XXX: Never pass the SVGA3D_SURFACE_HINT_RENDERTARGET hint. Mesa cannot
- * know beforehand whether a texture will be used as a rendertarget or not
- * and it always requests PIPE_TEXTURE_USAGE_RENDER_TARGET, therefore
- * passing the SVGA3D_SURFACE_HINT_RENDERTARGET here defeats its purpose.
- */
-#if 0
- if((templat->tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) &&
- !util_format_is_s3tc(templat->format))
- tex->key.flags |= SVGA3D_SURFACE_HINT_RENDERTARGET;
-#endif
-
- if(templat->tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL)
- tex->key.flags |= SVGA3D_SURFACE_HINT_DEPTHSTENCIL;
-
- tex->key.numMipLevels = templat->last_level + 1;
-
- tex->key.format = svga_translate_format(templat->format);
- if(tex->key.format == SVGA3D_FORMAT_INVALID)
- goto error2;
-
- SVGA_DBG(DEBUG_DMA, "surface_create for texture\n", tex->handle);
- tex->handle = svga_screen_surface_create(svgascreen, &tex->key);
- if (tex->handle)
- SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture)\n", tex->handle);
-
- return &tex->base;
-
-error2:
- FREE(tex);
-error1:
- return NULL;
-}
-
-
-
-
-
-static struct pipe_texture *
-svga_screen_texture_from_handle(struct pipe_screen *screen,
- const struct pipe_texture *base,
- struct winsys_handle *whandle)
-{
- struct svga_winsys_screen *sws = svga_winsys_screen(screen);
- struct svga_winsys_surface *srf;
- struct svga_texture *tex;
- enum SVGA3dSurfaceFormat format = 0;
- assert(screen);
-
- /* Only supports one type */
- if (base->target != PIPE_TEXTURE_2D ||
- base->last_level != 0 ||
- base->depth0 != 1) {
- return NULL;
- }
-
- srf = sws->surface_from_handle(sws, whandle, &format);
-
- if (!srf)
- return NULL;
-
- if (svga_translate_format(base->format) != format) {
- unsigned f1 = svga_translate_format(base->format);
- unsigned f2 = format;
-
- /* It's okay for XRGB and ARGB or depth with/out stencil to get mixed up */
- if ( !( (f1 == SVGA3D_X8R8G8B8 && f2 == SVGA3D_A8R8G8B8) ||
- (f1 == SVGA3D_A8R8G8B8 && f2 == SVGA3D_X8R8G8B8) ||
- (f1 == SVGA3D_Z_D24X8 && f2 == SVGA3D_Z_D24S8) ) ) {
- debug_printf("%s wrong format %u != %u\n", __FUNCTION__, f1, f2);
- return NULL;
- }
- }
-
- tex = CALLOC_STRUCT(svga_texture);
- if (!tex)
- return NULL;
-
- tex->base = *base;
-
-
- if (format == 1)
- tex->base.format = PIPE_FORMAT_B8G8R8X8_UNORM;
- else if (format == 2)
- tex->base.format = PIPE_FORMAT_B8G8R8A8_UNORM;
-
- pipe_reference_init(&tex->base.reference, 1);
- tex->base.screen = screen;
-
- SVGA_DBG(DEBUG_DMA, "wrap surface sid %p\n", srf);
-
- tex->key.cachable = 0;
- tex->handle = srf;
-
- return &tex->base;
-}
-
-
-static boolean
-svga_screen_texture_get_handle(struct pipe_screen *screen,
- struct pipe_texture *texture,
- struct winsys_handle *whandle)
-{
- struct svga_winsys_screen *sws = svga_winsys_screen(texture->screen);
- unsigned stride;
-
- assert(svga_texture(texture)->key.cachable == 0);
- svga_texture(texture)->key.cachable = 0;
- stride = util_format_get_nblocksx(texture->format, texture->width0) *
- util_format_get_blocksize(texture->format);
- return sws->surface_get_handle(sws, svga_texture(texture)->handle, stride, whandle);
-}
-
-
-static void
-svga_texture_destroy(struct pipe_texture *pt)
-{
- struct svga_screen *ss = svga_screen(pt->screen);
- struct svga_texture *tex = (struct svga_texture *)pt;
-
- ss->texture_timestamp++;
-
- svga_sampler_view_reference(&tex->cached_view, NULL);
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
- SVGA_DBG(DEBUG_DMA, "unref sid %p (texture)\n", tex->handle);
- svga_screen_surface_destroy(ss, &tex->key, &tex->handle);
-
- FREE(tex);
-}
-
-
-static void
-svga_texture_copy_handle(struct svga_context *svga,
- struct svga_screen *ss,
- struct svga_winsys_surface *src_handle,
- unsigned src_x, unsigned src_y, unsigned src_z,
- unsigned src_level, unsigned src_face,
- struct svga_winsys_surface *dst_handle,
- unsigned dst_x, unsigned dst_y, unsigned dst_z,
- unsigned dst_level, unsigned dst_face,
- unsigned width, unsigned height, unsigned depth)
-{
- struct svga_surface dst, src;
- enum pipe_error ret;
- SVGA3dCopyBox box, *boxes;
-
- assert(svga || ss);
-
- src.handle = src_handle;
- src.real_level = src_level;
- src.real_face = src_face;
- src.real_zslice = 0;
-
- dst.handle = dst_handle;
- dst.real_level = dst_level;
- dst.real_face = dst_face;
- dst.real_zslice = 0;
-
- box.x = dst_x;
- box.y = dst_y;
- box.z = dst_z;
- box.w = width;
- box.h = height;
- box.d = depth;
- box.srcx = src_x;
- box.srcy = src_y;
- box.srcz = src_z;
-
-/*
- SVGA_DBG(DEBUG_VIEWS, "mipcopy src: %p %u (%ux%ux%u), dst: %p %u (%ux%ux%u)\n",
- src_handle, src_level, src_x, src_y, src_z,
- dst_handle, dst_level, dst_x, dst_y, dst_z);
-*/
-
- if (svga) {
- ret = SVGA3D_BeginSurfaceCopy(svga->swc,
- &src.base,
- &dst.base,
- &boxes, 1);
- if(ret != PIPE_OK) {
- svga_context_flush(svga, NULL);
- ret = SVGA3D_BeginSurfaceCopy(svga->swc,
- &src.base,
- &dst.base,
- &boxes, 1);
- assert(ret == PIPE_OK);
- }
- *boxes = box;
- SVGA_FIFOCommitAll(svga->swc);
- } else {
- pipe_mutex_lock(ss->swc_mutex);
- ret = SVGA3D_BeginSurfaceCopy(ss->swc,
- &src.base,
- &dst.base,
- &boxes, 1);
- if(ret != PIPE_OK) {
- ss->swc->flush(ss->swc, NULL);
- ret = SVGA3D_BeginSurfaceCopy(ss->swc,
- &src.base,
- &dst.base,
- &boxes, 1);
- assert(ret == PIPE_OK);
- }
- *boxes = box;
- SVGA_FIFOCommitAll(ss->swc);
- pipe_mutex_unlock(ss->swc_mutex);
- }
-}
-
-static struct svga_winsys_surface *
-svga_texture_view_surface(struct pipe_context *pipe,
- struct svga_texture *tex,
- SVGA3dSurfaceFormat format,
- unsigned start_mip,
- unsigned num_mip,
- int face_pick,
- int zslice_pick,
- struct svga_host_surface_cache_key *key) /* OUT */
-{
- struct svga_screen *ss = svga_screen(tex->base.screen);
- struct svga_winsys_surface *handle;
- uint32_t i, j;
- unsigned z_offset = 0;
-
- SVGA_DBG(DEBUG_PERF,
- "svga: Create surface view: face %d zslice %d mips %d..%d\n",
- face_pick, zslice_pick, start_mip, start_mip+num_mip-1);
-
- key->flags = 0;
- key->format = format;
- key->numMipLevels = num_mip;
- key->size.width = u_minify(tex->base.width0, start_mip);
- key->size.height = u_minify(tex->base.height0, start_mip);
- key->size.depth = zslice_pick < 0 ? u_minify(tex->base.depth0, start_mip) : 1;
- key->cachable = 1;
- assert(key->size.depth == 1);
-
- if(tex->base.target == PIPE_TEXTURE_CUBE && face_pick < 0) {
- key->flags |= SVGA3D_SURFACE_CUBEMAP;
- key->numFaces = 6;
- } else {
- key->numFaces = 1;
- }
-
- if(key->format == SVGA3D_FORMAT_INVALID) {
- key->cachable = 0;
- return NULL;
- }
-
- SVGA_DBG(DEBUG_DMA, "surface_create for texture view\n");
- handle = svga_screen_surface_create(ss, key);
- if (!handle) {
- key->cachable = 0;
- return NULL;
- }
-
- SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture view)\n", handle);
-
- if (face_pick < 0)
- face_pick = 0;
-
- if (zslice_pick >= 0)
- z_offset = zslice_pick;
-
- for (i = 0; i < key->numMipLevels; i++) {
- for (j = 0; j < key->numFaces; j++) {
- if(tex->defined[j + face_pick][i + start_mip]) {
- unsigned depth = (zslice_pick < 0 ?
- u_minify(tex->base.depth0, i + start_mip) :
- 1);
-
- svga_texture_copy_handle(svga_context(pipe),
- ss,
- tex->handle,
- 0, 0, z_offset,
- i + start_mip,
- j + face_pick,
- handle, 0, 0, 0, i, j,
- u_minify(tex->base.width0, i + start_mip),
- u_minify(tex->base.height0, i + start_mip),
- depth);
- }
- }
- }
-
- return handle;
-}
-
-
-static struct pipe_surface *
-svga_get_tex_surface(struct pipe_screen *screen,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice,
- unsigned flags)
-{
- struct svga_texture *tex = svga_texture(pt);
- struct svga_surface *s;
- boolean render = flags & PIPE_BUFFER_USAGE_GPU_WRITE ? TRUE : FALSE;
- boolean view = FALSE;
- SVGA3dSurfaceFormat format;
-
- s = CALLOC_STRUCT(svga_surface);
- if (!s)
- return NULL;
-
- pipe_reference_init(&s->base.reference, 1);
- pipe_texture_reference(&s->base.texture, pt);
- s->base.format = pt->format;
- s->base.width = u_minify(pt->width0, level);
- s->base.height = u_minify(pt->height0, level);
- s->base.usage = flags;
- s->base.level = level;
- s->base.face = face;
- s->base.zslice = zslice;
-
- if (!render)
- format = svga_translate_format(pt->format);
- else
- format = svga_translate_format_render(pt->format);
-
- assert(format != SVGA3D_FORMAT_INVALID);
- assert(!(flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
-
-
- if (svga_screen(screen)->debug.force_surface_view)
- view = TRUE;
-
- /* Currently only used for compressed textures */
- if (render &&
- format != svga_translate_format(pt->format)) {
- view = TRUE;
- }
-
- if (level != 0 &&
- svga_screen(screen)->debug.force_level_surface_view)
- view = TRUE;
-
- if (pt->target == PIPE_TEXTURE_3D)
- view = TRUE;
-
- if (svga_screen(screen)->debug.no_surface_view)
- view = FALSE;
-
- if (view) {
- SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: yes %p, level %u face %u z %u, %p\n",
- pt, level, face, zslice, s);
-
- s->handle = svga_texture_view_surface(NULL, tex, format, level, 1, face, zslice,
- &s->key);
- s->real_face = 0;
- s->real_level = 0;
- s->real_zslice = 0;
- } else {
- SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: no %p, level %u, face %u, z %u, %p\n",
- pt, level, face, zslice, s);
-
- memset(&s->key, 0, sizeof s->key);
- s->handle = tex->handle;
- s->real_face = face;
- s->real_level = level;
- s->real_zslice = zslice;
- }
-
- return &s->base;
-}
-
-
-static void
-svga_tex_surface_destroy(struct pipe_surface *surf)
-{
- struct svga_surface *s = svga_surface(surf);
- struct svga_texture *t = svga_texture(surf->texture);
- struct svga_screen *ss = svga_screen(surf->texture->screen);
-
- if(s->handle != t->handle) {
- SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
- svga_screen_surface_destroy(ss, &s->key, &s->handle);
- }
-
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
-}
-
-
-static INLINE void
-svga_mark_surface_dirty(struct pipe_surface *surf)
-{
- struct svga_surface *s = svga_surface(surf);
-
- if(!s->dirty) {
- struct svga_texture *tex = svga_texture(surf->texture);
-
- s->dirty = TRUE;
-
- if (s->handle == tex->handle)
- tex->defined[surf->face][surf->level] = TRUE;
- else {
- /* this will happen later in svga_propagate_surface */
- }
- }
-}
-
-
-void svga_mark_surfaces_dirty(struct svga_context *svga)
-{
- unsigned i;
-
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
- if (svga->curr.framebuffer.cbufs[i])
- svga_mark_surface_dirty(svga->curr.framebuffer.cbufs[i]);
- }
- if (svga->curr.framebuffer.zsbuf)
- svga_mark_surface_dirty(svga->curr.framebuffer.zsbuf);
-}
-
-/**
- * Progagate any changes from surfaces to texture.
- * pipe is optional context to inline the blit command in.
- */
-void
-svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf)
-{
- struct svga_surface *s = svga_surface(surf);
- struct svga_texture *tex = svga_texture(surf->texture);
- struct svga_screen *ss = svga_screen(surf->texture->screen);
-
- if (!s->dirty)
- return;
-
- s->dirty = FALSE;
- ss->texture_timestamp++;
- tex->view_age[surf->level] = ++(tex->age);
-
- if (s->handle != tex->handle) {
- SVGA_DBG(DEBUG_VIEWS, "svga: Surface propagate: tex %p, level %u, from %p\n", tex, surf->level, surf);
- svga_texture_copy_handle(svga_context(pipe), ss,
- s->handle, 0, 0, 0, s->real_level, s->real_face,
- tex->handle, 0, 0, surf->zslice, surf->level, surf->face,
- u_minify(tex->base.width0, surf->level),
- u_minify(tex->base.height0, surf->level), 1);
- tex->defined[surf->face][surf->level] = TRUE;
- }
-}
-
-/**
- * Check if we should call svga_propagate_surface on the surface.
- */
-extern boolean
-svga_surface_needs_propagation(struct pipe_surface *surf)
-{
- struct svga_surface *s = svga_surface(surf);
- struct svga_texture *tex = svga_texture(surf->texture);
-
- return s->dirty && s->handle != tex->handle;
-}
-
-/* XXX: Still implementing this as if it was a screen function, but
- * can now modify it to queue transfers on the context.
- */
-static struct pipe_transfer *
-svga_get_tex_transfer(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level, unsigned zslice,
- enum pipe_transfer_usage usage, unsigned x, unsigned y,
- unsigned w, unsigned h)
-{
- struct svga_screen *ss = svga_screen(pipe->screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_transfer *st;
- unsigned nblocksx = util_format_get_nblocksx(texture->format, w);
- unsigned nblocksy = util_format_get_nblocksy(texture->format, h);
-
- /* We can't map texture storage directly */
- if (usage & PIPE_TRANSFER_MAP_DIRECTLY)
- return NULL;
-
- st = CALLOC_STRUCT(svga_transfer);
- if (!st)
- return NULL;
-
- st->base.x = x;
- st->base.y = y;
- st->base.width = w;
- st->base.height = h;
- st->base.stride = nblocksx*util_format_get_blocksize(texture->format);
- st->base.usage = usage;
- st->base.face = face;
- st->base.level = level;
- st->base.zslice = zslice;
-
- st->hw_nblocksy = nblocksy;
-
- st->hwbuf = svga_winsys_buffer_create(ss,
- 1,
- 0,
- st->hw_nblocksy*st->base.stride);
- while(!st->hwbuf && (st->hw_nblocksy /= 2)) {
- st->hwbuf = svga_winsys_buffer_create(ss,
- 1,
- 0,
- st->hw_nblocksy*st->base.stride);
- }
-
- if(!st->hwbuf)
- goto no_hwbuf;
-
- if(st->hw_nblocksy < nblocksy) {
- /* We couldn't allocate a hardware buffer big enough for the transfer,
- * so allocate regular malloc memory instead */
- debug_printf("%s: failed to allocate %u KB of DMA, splitting into %u x %u KB DMA transfers\n",
- __FUNCTION__,
- (nblocksy*st->base.stride + 1023)/1024,
- (nblocksy + st->hw_nblocksy - 1)/st->hw_nblocksy,
- (st->hw_nblocksy*st->base.stride + 1023)/1024);
- st->swbuf = MALLOC(nblocksy*st->base.stride);
- if(!st->swbuf)
- goto no_swbuf;
- }
-
- pipe_texture_reference(&st->base.texture, texture);
-
- if (usage & PIPE_TRANSFER_READ)
- svga_transfer_dma(st, SVGA3D_READ_HOST_VRAM);
-
- return &st->base;
-
-no_swbuf:
- sws->buffer_destroy(sws, st->hwbuf);
-no_hwbuf:
- FREE(st);
- return NULL;
-}
-
-
-/* XXX: Still implementing this as if it was a screen function, but
- * can now modify it to queue transfers on the context.
- */
-static void *
-svga_transfer_map( struct pipe_context *pipe,
- struct pipe_transfer *transfer )
-{
- struct svga_screen *ss = svga_screen(pipe->screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_transfer *st = svga_transfer(transfer);
-
- if(st->swbuf)
- return st->swbuf;
- else
- /* The wait for read transfers already happened when svga_transfer_dma
- * was called. */
- return sws->buffer_map(sws, st->hwbuf,
- pipe_transfer_buffer_flags(transfer));
-}
-
-
-/* XXX: Still implementing this as if it was a screen function, but
- * can now modify it to queue transfers on the context.
- */
-static void
-svga_transfer_unmap(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct svga_screen *ss = svga_screen(pipe->screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_transfer *st = svga_transfer(transfer);
-
- if(!st->swbuf)
- sws->buffer_unmap(sws, st->hwbuf);
-}
-
-
-static void
-svga_tex_transfer_destroy(struct pipe_context *pipe,
- struct pipe_transfer *transfer)
-{
- struct svga_texture *tex = svga_texture(transfer->texture);
- struct svga_screen *ss = svga_screen(pipe->screen);
- struct svga_winsys_screen *sws = ss->sws;
- struct svga_transfer *st = svga_transfer(transfer);
-
- if (st->base.usage & PIPE_TRANSFER_WRITE) {
- svga_transfer_dma(st, SVGA3D_WRITE_HOST_VRAM);
- ss->texture_timestamp++;
- tex->view_age[transfer->level] = ++(tex->age);
- tex->defined[transfer->face][transfer->level] = TRUE;
- }
-
- pipe_texture_reference(&st->base.texture, NULL);
- FREE(st->swbuf);
- sws->buffer_destroy(sws, st->hwbuf);
- FREE(st);
-}
-
-
-void
-svga_init_texture_functions(struct pipe_context *pipe)
-{
- pipe->get_tex_transfer = svga_get_tex_transfer;
- pipe->transfer_map = svga_transfer_map;
- pipe->transfer_unmap = svga_transfer_unmap;
- pipe->tex_transfer_destroy = svga_tex_transfer_destroy;
-}
-
-
-void
-svga_screen_init_texture_functions(struct pipe_screen *screen)
-{
- screen->texture_create = svga_texture_create;
- screen->texture_from_handle = svga_screen_texture_from_handle;
- screen->texture_get_handle = svga_screen_texture_get_handle;
- screen->texture_destroy = svga_texture_destroy;
- screen->get_tex_surface = svga_get_tex_surface;
- screen->tex_surface_destroy = svga_tex_surface_destroy;
-}
-
-/***********************************************************************
- */
-
-struct svga_sampler_view *
-svga_get_tex_sampler_view(struct pipe_context *pipe, struct pipe_texture *pt,
- unsigned min_lod, unsigned max_lod)
-{
- struct svga_screen *ss = svga_screen(pt->screen);
- struct svga_texture *tex = svga_texture(pt);
- struct svga_sampler_view *sv = NULL;
- SVGA3dSurfaceFormat format = svga_translate_format(pt->format);
- boolean view = TRUE;
-
- assert(pt);
- assert(min_lod >= 0);
- assert(min_lod <= max_lod);
- assert(max_lod <= pt->last_level);
-
-
- /* Is a view needed */
- {
- /*
- * Can't control max lod. For first level views and when we only
- * look at one level we disable mip filtering to achive the same
- * results as a view.
- */
- if (min_lod == 0 && max_lod >= pt->last_level)
- view = FALSE;
-
- if (util_format_is_s3tc(pt->format) && view) {
- format = svga_translate_format_render(pt->format);
- }
-
- if (ss->debug.no_sampler_view)
- view = FALSE;
-
- if (ss->debug.force_sampler_view)
- view = TRUE;
- }
-
- /* First try the cache */
- if (view) {
- pipe_mutex_lock(ss->tex_mutex);
- if (tex->cached_view &&
- tex->cached_view->min_lod == min_lod &&
- tex->cached_view->max_lod == max_lod) {
- svga_sampler_view_reference(&sv, tex->cached_view);
- pipe_mutex_unlock(ss->tex_mutex);
- SVGA_DBG(DEBUG_VIEWS, "svga: Sampler view: reuse %p, %u %u, last %u\n",
- pt, min_lod, max_lod, pt->last_level);
- svga_validate_sampler_view(svga_context(pipe), sv);
- return sv;
- }
- pipe_mutex_unlock(ss->tex_mutex);
- }
-
- sv = CALLOC_STRUCT(svga_sampler_view);
- pipe_reference_init(&sv->reference, 1);
- pipe_texture_reference(&sv->texture, pt);
- sv->min_lod = min_lod;
- sv->max_lod = max_lod;
-
- /* No view needed just use the whole texture */
- if (!view) {
- SVGA_DBG(DEBUG_VIEWS,
- "svga: Sampler view: no %p, mips %u..%u, nr %u, size (%ux%ux%u), last %u\n",
- pt, min_lod, max_lod,
- max_lod - min_lod + 1,
- pt->width0,
- pt->height0,
- pt->depth0,
- pt->last_level);
- sv->key.cachable = 0;
- sv->handle = tex->handle;
- return sv;
- }
-
- SVGA_DBG(DEBUG_VIEWS,
- "svga: Sampler view: yes %p, mips %u..%u, nr %u, size (%ux%ux%u), last %u\n",
- pt, min_lod, max_lod,
- max_lod - min_lod + 1,
- pt->width0,
- pt->height0,
- pt->depth0,
- pt->last_level);
-
- sv->age = tex->age;
- sv->handle = svga_texture_view_surface(pipe, tex, format,
- min_lod,
- max_lod - min_lod + 1,
- -1, -1,
- &sv->key);
-
- if (!sv->handle) {
- assert(0);
- sv->key.cachable = 0;
- sv->handle = tex->handle;
- return sv;
- }
-
- pipe_mutex_lock(ss->tex_mutex);
- svga_sampler_view_reference(&tex->cached_view, sv);
- pipe_mutex_unlock(ss->tex_mutex);
-
- return sv;
-}
-
-void
-svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *v)
-{
- struct svga_texture *tex = svga_texture(v->texture);
- unsigned numFaces;
- unsigned age = 0;
- int i, k;
-
- assert(svga);
-
- if (v->handle == tex->handle)
- return;
-
- age = tex->age;
-
- if(tex->base.target == PIPE_TEXTURE_CUBE)
- numFaces = 6;
- else
- numFaces = 1;
-
- for (i = v->min_lod; i <= v->max_lod; i++) {
- for (k = 0; k < numFaces; k++) {
- if (v->age < tex->view_age[i])
- svga_texture_copy_handle(svga, NULL,
- tex->handle, 0, 0, 0, i, k,
- v->handle, 0, 0, 0, i - v->min_lod, k,
- u_minify(tex->base.width0, i),
- u_minify(tex->base.height0, i),
- u_minify(tex->base.depth0, i));
- }
- }
-
- v->age = age;
-}
-
-void
-svga_destroy_sampler_view_priv(struct svga_sampler_view *v)
-{
- struct svga_texture *tex = svga_texture(v->texture);
-
- if(v->handle != tex->handle) {
- struct svga_screen *ss = svga_screen(v->texture->screen);
- SVGA_DBG(DEBUG_DMA, "unref sid %p (sampler view)\n", v->handle);
- svga_screen_surface_destroy(ss, &v->key, &v->handle);
- }
- pipe_texture_reference(&v->texture, NULL);
- FREE(v);
-}
diff --git a/src/gallium/drivers/svga/svga_state_constants.c b/src/gallium/drivers/svga/svga_state_constants.c
index 493f78a990..97c818cd37 100644
--- a/src/gallium/drivers/svga/svga_state_constants.c
+++ b/src/gallium/drivers/svga/svga_state_constants.c
@@ -82,7 +82,7 @@ static int emit_consts( struct svga_context *svga,
int offset,
int unit )
{
- struct pipe_screen *screen = svga->pipe.screen;
+ struct pipe_transfer *transfer = NULL;
unsigned count;
const float (*data)[4] = NULL;
unsigned i;
@@ -91,11 +91,12 @@ static int emit_consts( struct svga_context *svga,
if (svga->curr.cb[unit] == NULL)
goto done;
- count = svga->curr.cb[unit]->size / (4 * sizeof(float));
+ count = svga->curr.cb[unit]->width0 / (4 * sizeof(float));
- data = (const float (*)[4])pipe_buffer_map(screen,
+ data = (const float (*)[4])pipe_buffer_map(&svga->pipe,
svga->curr.cb[unit],
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &transfer);
if (data == NULL) {
ret = PIPE_ERROR_OUT_OF_MEMORY;
goto done;
@@ -109,7 +110,7 @@ static int emit_consts( struct svga_context *svga,
done:
if (data)
- pipe_buffer_unmap(screen, svga->curr.cb[unit]);
+ pipe_buffer_unmap(&svga->pipe, svga->curr.cb[unit], transfer);
return ret;
}
@@ -137,7 +138,7 @@ static int emit_fs_consts( struct svga_context *svga,
for (i = 0; i < key->num_textures; i++) {
if (key->tex[i].unnormalized) {
- struct pipe_texture *tex = svga->curr.sampler_views[i]->texture;
+ struct pipe_resource *tex = svga->curr.sampler_views[i]->texture;
float data[4];
data[0] = 1.0 / (float)tex->width0;
diff --git a/src/gallium/drivers/svga/svga_state_tss.c b/src/gallium/drivers/svga/svga_state_tss.c
index c08ec7c2e8..76a2dae143 100644
--- a/src/gallium/drivers/svga/svga_state_tss.c
+++ b/src/gallium/drivers/svga/svga_state_tss.c
@@ -27,7 +27,7 @@
#include "pipe/p_defines.h"
#include "util/u_math.h"
-#include "svga_screen_texture.h"
+#include "svga_sampler_view.h"
#include "svga_winsys.h"
#include "svga_context.h"
#include "svga_state.h"
@@ -45,7 +45,7 @@ void svga_cleanup_tss_binding(struct svga_context *svga)
svga_sampler_view_reference(&view->v, NULL);
pipe_sampler_view_reference( &svga->curr.sampler_views[i], NULL );
- pipe_texture_reference( &view->texture, NULL );
+ pipe_resource_reference( &view->texture, NULL );
view->dirty = 1;
}
@@ -77,7 +77,7 @@ update_tss_binding(struct svga_context *svga,
for (i = 0; i < count; i++) {
const struct svga_sampler_state *s = svga->curr.sampler[i];
struct svga_hw_view_state *view = &svga->state.hw_draw.views[i];
- struct pipe_texture *texture = NULL;
+ struct pipe_resource *texture = NULL;
/* get min max lod */
if (svga->curr.sampler_views[i]) {
@@ -94,7 +94,7 @@ update_tss_binding(struct svga_context *svga,
view->max_lod != max_lod) {
svga_sampler_view_reference(&view->v, NULL);
- pipe_texture_reference( &view->texture, texture );
+ pipe_resource_reference( &view->texture, texture );
view->dirty = TRUE;
view->min_lod = min_lod;
@@ -135,7 +135,7 @@ update_tss_binding(struct svga_context *svga,
svga->swc->surface_relocation(svga->swc,
&ts[i].value,
queue.bind[i].view->v->handle,
- PIPE_BUFFER_USAGE_GPU_READ);
+ SVGA_RELOC_READ);
}
else {
ts[i].value = SVGA3D_INVALID_ID;
diff --git a/src/gallium/drivers/svga/svga_state_vdecl.c b/src/gallium/drivers/svga/svga_state_vdecl.c
index f531e22304..3af7bf2b35 100644
--- a/src/gallium/drivers/svga/svga_state_vdecl.c
+++ b/src/gallium/drivers/svga/svga_state_vdecl.c
@@ -33,7 +33,7 @@
#include "svga_draw.h"
#include "svga_tgsi.h"
#include "svga_screen.h"
-#include "svga_screen_buffer.h"
+#include "svga_resource_buffer.h"
#include "svga_hw_reg.h"
@@ -59,8 +59,8 @@ upload_user_buffers( struct svga_context *svga )
if (!buffer->uploaded.buffer) {
ret = u_upload_buffer( svga->upload_vb,
0,
- buffer->base.size,
- &buffer->base,
+ buffer->b.b.width0,
+ &buffer->b.b,
&buffer->uploaded.offset,
&buffer->uploaded.buffer );
if (ret)
@@ -73,10 +73,10 @@ upload_user_buffers( struct svga_context *svga )
buffer,
buffer->uploaded.buffer,
buffer->uploaded.offset,
- buffer->base.size);
+ buffer->b.b.width0);
}
- pipe_buffer_reference( &svga->curr.vb[i].buffer, buffer->uploaded.buffer );
+ pipe_resource_reference( &svga->curr.vb[i].buffer, buffer->uploaded.buffer );
svga->curr.vb[i].buffer_offset = buffer->uploaded.offset;
}
}
diff --git a/src/gallium/drivers/svga/svga_state_vs.c b/src/gallium/drivers/svga/svga_state_vs.c
index 781f7bf533..a6215c68cb 100644
--- a/src/gallium/drivers/svga/svga_state_vs.c
+++ b/src/gallium/drivers/svga/svga_state_vs.c
@@ -190,9 +190,11 @@ static int update_zero_stride( struct svga_context *svga,
const struct pipe_vertex_element *vel = &svga->curr.velems->velem[i];
const struct pipe_vertex_buffer *vbuffer = &svga->curr.vb[
vel->vertex_buffer_index];
+
if (vbuffer->stride == 0) {
unsigned const_idx =
svga->curr.num_zero_stride_vertex_elements;
+ struct pipe_transfer *transfer;
struct translate *translate;
struct translate_key key;
void *mapped_buffer;
@@ -218,19 +220,23 @@ static int update_zero_stride( struct svga_context *svga,
assert(vel->src_offset == 0);
- mapped_buffer = pipe_buffer_map_range(svga->pipe.screen,
+ mapped_buffer = pipe_buffer_map_range(&svga->pipe,
vbuffer->buffer,
vel->src_offset,
util_format_get_blocksize(vel->src_format),
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &transfer);
+
translate->set_buffer(translate, vel->vertex_buffer_index,
mapped_buffer,
vbuffer->stride);
translate->run(translate, 0, 1, 0,
svga->curr.zero_stride_constants);
- pipe_buffer_unmap(svga->pipe.screen,
- vbuffer->buffer);
+ pipe_buffer_unmap(&svga->pipe,
+ vbuffer->buffer,
+ transfer);
+
translate->release(translate);
}
}
diff --git a/src/gallium/drivers/svga/svga_surface.c b/src/gallium/drivers/svga/svga_surface.c
new file mode 100644
index 0000000000..126b078751
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_surface.c
@@ -0,0 +1,383 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#include "svga_cmd.h"
+
+#include "pipe/p_state.h"
+#include "pipe/p_defines.h"
+#include "util/u_inlines.h"
+#include "os/os_thread.h"
+#include "util/u_format.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
+#include "svga_screen.h"
+#include "svga_context.h"
+#include "svga_resource_texture.h"
+#include "svga_surface.h"
+#include "svga_winsys.h"
+#include "svga_debug.h"
+
+#include <util/u_string.h>
+
+
+void
+svga_texture_copy_handle(struct svga_context *svga,
+ struct svga_screen *ss,
+ struct svga_winsys_surface *src_handle,
+ unsigned src_x, unsigned src_y, unsigned src_z,
+ unsigned src_level, unsigned src_face,
+ struct svga_winsys_surface *dst_handle,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ unsigned dst_level, unsigned dst_face,
+ unsigned width, unsigned height, unsigned depth)
+{
+ struct svga_surface dst, src;
+ enum pipe_error ret;
+ SVGA3dCopyBox box, *boxes;
+
+ assert(svga || ss);
+
+ src.handle = src_handle;
+ src.real_level = src_level;
+ src.real_face = src_face;
+ src.real_zslice = 0;
+
+ dst.handle = dst_handle;
+ dst.real_level = dst_level;
+ dst.real_face = dst_face;
+ dst.real_zslice = 0;
+
+ box.x = dst_x;
+ box.y = dst_y;
+ box.z = dst_z;
+ box.w = width;
+ box.h = height;
+ box.d = depth;
+ box.srcx = src_x;
+ box.srcy = src_y;
+ box.srcz = src_z;
+
+/*
+ SVGA_DBG(DEBUG_VIEWS, "mipcopy src: %p %u (%ux%ux%u), dst: %p %u (%ux%ux%u)\n",
+ src_handle, src_level, src_x, src_y, src_z,
+ dst_handle, dst_level, dst_x, dst_y, dst_z);
+*/
+
+ if (svga) {
+ ret = SVGA3D_BeginSurfaceCopy(svga->swc,
+ &src.base,
+ &dst.base,
+ &boxes, 1);
+ if(ret != PIPE_OK) {
+ svga_context_flush(svga, NULL);
+ ret = SVGA3D_BeginSurfaceCopy(svga->swc,
+ &src.base,
+ &dst.base,
+ &boxes, 1);
+ assert(ret == PIPE_OK);
+ }
+ *boxes = box;
+ SVGA_FIFOCommitAll(svga->swc);
+ } else {
+ pipe_mutex_lock(ss->swc_mutex);
+ ret = SVGA3D_BeginSurfaceCopy(ss->swc,
+ &src.base,
+ &dst.base,
+ &boxes, 1);
+ if(ret != PIPE_OK) {
+ ss->swc->flush(ss->swc, NULL);
+ ret = SVGA3D_BeginSurfaceCopy(ss->swc,
+ &src.base,
+ &dst.base,
+ &boxes, 1);
+ assert(ret == PIPE_OK);
+ }
+ *boxes = box;
+ SVGA_FIFOCommitAll(ss->swc);
+ pipe_mutex_unlock(ss->swc_mutex);
+ }
+}
+
+
+struct svga_winsys_surface *
+svga_texture_view_surface(struct pipe_context *pipe,
+ struct svga_texture *tex,
+ SVGA3dSurfaceFormat format,
+ unsigned start_mip,
+ unsigned num_mip,
+ int face_pick,
+ int zslice_pick,
+ struct svga_host_surface_cache_key *key) /* OUT */
+{
+ struct svga_screen *ss = svga_screen(pipe->screen);
+ struct svga_winsys_surface *handle;
+ uint32_t i, j;
+ unsigned z_offset = 0;
+
+ SVGA_DBG(DEBUG_PERF,
+ "svga: Create surface view: face %d zslice %d mips %d..%d\n",
+ face_pick, zslice_pick, start_mip, start_mip+num_mip-1);
+
+ key->flags = 0;
+ key->format = format;
+ key->numMipLevels = num_mip;
+ key->size.width = u_minify(tex->b.b.width0, start_mip);
+ key->size.height = u_minify(tex->b.b.height0, start_mip);
+ key->size.depth = zslice_pick < 0 ? u_minify(tex->b.b.depth0, start_mip) : 1;
+ key->cachable = 1;
+ assert(key->size.depth == 1);
+
+ if(tex->b.b.target == PIPE_TEXTURE_CUBE && face_pick < 0) {
+ key->flags |= SVGA3D_SURFACE_CUBEMAP;
+ key->numFaces = 6;
+ } else {
+ key->numFaces = 1;
+ }
+
+ if(key->format == SVGA3D_FORMAT_INVALID) {
+ key->cachable = 0;
+ return NULL;
+ }
+
+ SVGA_DBG(DEBUG_DMA, "surface_create for texture view\n");
+ handle = svga_screen_surface_create(ss, key);
+ if (!handle) {
+ key->cachable = 0;
+ return NULL;
+ }
+
+ SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture view)\n", handle);
+
+ if (face_pick < 0)
+ face_pick = 0;
+
+ if (zslice_pick >= 0)
+ z_offset = zslice_pick;
+
+ for (i = 0; i < key->numMipLevels; i++) {
+ for (j = 0; j < key->numFaces; j++) {
+ if(tex->defined[j + face_pick][i + start_mip]) {
+ unsigned depth = (zslice_pick < 0 ?
+ u_minify(tex->b.b.depth0, i + start_mip) :
+ 1);
+
+ svga_texture_copy_handle(svga_context(pipe),
+ ss,
+ tex->handle,
+ 0, 0, z_offset,
+ i + start_mip,
+ j + face_pick,
+ handle, 0, 0, 0, i, j,
+ u_minify(tex->b.b.width0, i + start_mip),
+ u_minify(tex->b.b.height0, i + start_mip),
+ depth);
+ }
+ }
+ }
+
+ return handle;
+}
+
+
+static struct pipe_surface *
+svga_get_tex_surface(struct pipe_screen *screen,
+ struct pipe_resource *pt,
+ unsigned face, unsigned level, unsigned zslice,
+ unsigned flags)
+{
+ struct svga_texture *tex = svga_texture(pt);
+ struct svga_surface *s;
+ boolean render = (flags & (PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_DEPTH_STENCIL)) ? TRUE : FALSE;
+ boolean view = FALSE;
+ SVGA3dSurfaceFormat format;
+
+ s = CALLOC_STRUCT(svga_surface);
+ if (!s)
+ return NULL;
+
+ pipe_reference_init(&s->base.reference, 1);
+ pipe_resource_reference(&s->base.texture, pt);
+ s->base.format = pt->format;
+ s->base.width = u_minify(pt->width0, level);
+ s->base.height = u_minify(pt->height0, level);
+ s->base.usage = flags;
+ s->base.level = level;
+ s->base.face = face;
+ s->base.zslice = zslice;
+
+ if (!render)
+ format = svga_translate_format(pt->format);
+ else
+ format = svga_translate_format_render(pt->format);
+
+ assert(format != SVGA3D_FORMAT_INVALID);
+
+ if (svga_screen(screen)->debug.force_surface_view)
+ view = TRUE;
+
+ /* Currently only used for compressed textures */
+ if (render &&
+ format != svga_translate_format(pt->format)) {
+ view = TRUE;
+ }
+
+ if (level != 0 &&
+ svga_screen(screen)->debug.force_level_surface_view)
+ view = TRUE;
+
+ if (pt->target == PIPE_TEXTURE_3D)
+ view = TRUE;
+
+ if (svga_screen(screen)->debug.no_surface_view)
+ view = FALSE;
+
+ if (view) {
+ SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: yes %p, level %u face %u z %u, %p\n",
+ pt, level, face, zslice, s);
+
+ s->handle = svga_texture_view_surface(NULL, tex, format, level, 1, face, zslice,
+ &s->key);
+ s->real_face = 0;
+ s->real_level = 0;
+ s->real_zslice = 0;
+ } else {
+ SVGA_DBG(DEBUG_VIEWS, "svga: Surface view: no %p, level %u, face %u, z %u, %p\n",
+ pt, level, face, zslice, s);
+
+ memset(&s->key, 0, sizeof s->key);
+ s->handle = tex->handle;
+ s->real_face = face;
+ s->real_level = level;
+ s->real_zslice = zslice;
+ }
+
+ return &s->base;
+}
+
+
+static void
+svga_tex_surface_destroy(struct pipe_surface *surf)
+{
+ struct svga_surface *s = svga_surface(surf);
+ struct svga_texture *t = svga_texture(surf->texture);
+ struct svga_screen *ss = svga_screen(surf->texture->screen);
+
+ if(s->handle != t->handle) {
+ SVGA_DBG(DEBUG_DMA, "unref sid %p (tex surface)\n", s->handle);
+ svga_screen_surface_destroy(ss, &s->key, &s->handle);
+ }
+
+ pipe_resource_reference(&surf->texture, NULL);
+ FREE(surf);
+}
+
+
+static INLINE void
+svga_mark_surface_dirty(struct pipe_surface *surf)
+{
+ struct svga_surface *s = svga_surface(surf);
+
+ if(!s->dirty) {
+ struct svga_texture *tex = svga_texture(surf->texture);
+
+ s->dirty = TRUE;
+
+ if (s->handle == tex->handle)
+ tex->defined[surf->face][surf->level] = TRUE;
+ else {
+ /* this will happen later in svga_propagate_surface */
+ }
+ }
+}
+
+
+void svga_mark_surfaces_dirty(struct svga_context *svga)
+{
+ unsigned i;
+
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+ if (svga->curr.framebuffer.cbufs[i])
+ svga_mark_surface_dirty(svga->curr.framebuffer.cbufs[i]);
+ }
+ if (svga->curr.framebuffer.zsbuf)
+ svga_mark_surface_dirty(svga->curr.framebuffer.zsbuf);
+}
+
+
+/**
+ * Progagate any changes from surfaces to texture.
+ * pipe is optional context to inline the blit command in.
+ */
+void
+svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf)
+{
+ struct svga_surface *s = svga_surface(surf);
+ struct svga_texture *tex = svga_texture(surf->texture);
+ struct svga_screen *ss = svga_screen(surf->texture->screen);
+
+ if (!s->dirty)
+ return;
+
+ s->dirty = FALSE;
+ ss->texture_timestamp++;
+ tex->view_age[surf->level] = ++(tex->age);
+
+ if (s->handle != tex->handle) {
+ SVGA_DBG(DEBUG_VIEWS, "svga: Surface propagate: tex %p, level %u, from %p\n", tex, surf->level, surf);
+ svga_texture_copy_handle(svga_context(pipe), ss,
+ s->handle, 0, 0, 0, s->real_level, s->real_face,
+ tex->handle, 0, 0, surf->zslice, surf->level, surf->face,
+ u_minify(tex->b.b.width0, surf->level),
+ u_minify(tex->b.b.height0, surf->level), 1);
+ tex->defined[surf->face][surf->level] = TRUE;
+ }
+}
+
+/**
+ * Check if we should call svga_propagate_surface on the surface.
+ */
+boolean
+svga_surface_needs_propagation(struct pipe_surface *surf)
+{
+ struct svga_surface *s = svga_surface(surf);
+ struct svga_texture *tex = svga_texture(surf->texture);
+
+ return s->dirty && s->handle != tex->handle;
+}
+
+
+
+
+
+
+void
+svga_screen_init_surface_functions(struct pipe_screen *screen)
+{
+ screen->get_tex_surface = svga_get_tex_surface;
+ screen->tex_surface_destroy = svga_tex_surface_destroy;
+}
+
diff --git a/src/gallium/drivers/svga/svga_surface.h b/src/gallium/drivers/svga/svga_surface.h
new file mode 100644
index 0000000000..b50ecdc994
--- /dev/null
+++ b/src/gallium/drivers/svga/svga_surface.h
@@ -0,0 +1,97 @@
+/**********************************************************
+ * Copyright 2008-2009 VMware, Inc. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ **********************************************************/
+
+#ifndef SVGA_SURFACE_H
+#define SVGA_SURFACE_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+#include "util/u_inlines.h"
+#include "svga_screen_cache.h"
+
+struct pipe_context;
+struct pipe_screen;
+struct svga_context;
+struct svga_texture;
+struct svga_winsys_surface;
+enum SVGA3dSurfaceFormat;
+
+
+struct svga_surface
+{
+ struct pipe_surface base;
+
+ struct svga_host_surface_cache_key key;
+ struct svga_winsys_surface *handle;
+
+ unsigned real_face;
+ unsigned real_level;
+ unsigned real_zslice;
+
+ boolean dirty;
+};
+
+
+extern void
+svga_propagate_surface(struct pipe_context *pipe, struct pipe_surface *surf);
+
+extern boolean
+svga_surface_needs_propagation(struct pipe_surface *surf);
+
+struct svga_winsys_surface *
+svga_texture_view_surface(struct pipe_context *pipe,
+ struct svga_texture *tex,
+ SVGA3dSurfaceFormat format,
+ unsigned start_mip,
+ unsigned num_mip,
+ int face_pick,
+ int zslice_pick,
+ struct svga_host_surface_cache_key *key); /* OUT */
+
+
+void
+svga_texture_copy_handle(struct svga_context *svga,
+ struct svga_screen *ss,
+ struct svga_winsys_surface *src_handle,
+ unsigned src_x, unsigned src_y, unsigned src_z,
+ unsigned src_level, unsigned src_face,
+ struct svga_winsys_surface *dst_handle,
+ unsigned dst_x, unsigned dst_y, unsigned dst_z,
+ unsigned dst_level, unsigned dst_face,
+ unsigned width, unsigned height, unsigned depth);
+
+
+static INLINE struct svga_surface *
+svga_surface(struct pipe_surface *surface)
+{
+ assert(surface);
+ return (struct svga_surface *)surface;
+}
+
+void
+svga_screen_init_surface_functions(struct pipe_screen *screen);
+
+#endif
diff --git a/src/gallium/drivers/svga/svga_swtnl.h b/src/gallium/drivers/svga/svga_swtnl.h
index 4882f26b17..096ed410b5 100644
--- a/src/gallium/drivers/svga/svga_swtnl.h
+++ b/src/gallium/drivers/svga/svga_swtnl.h
@@ -40,7 +40,7 @@ void svga_destroy_swtnl( struct svga_context *svga );
enum pipe_error
svga_swtnl_draw_range_elements(struct svga_context *svga,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
diff --git a/src/gallium/drivers/svga/svga_swtnl_backend.c b/src/gallium/drivers/svga/svga_swtnl_backend.c
index e9d7942fb5..e649813608 100644
--- a/src/gallium/drivers/svga/svga_swtnl_backend.c
+++ b/src/gallium/drivers/svga/svga_swtnl_backend.c
@@ -79,21 +79,19 @@ svga_vbuf_render_allocate_vertices( struct vbuf_render *render,
new_vbuf = TRUE;
if (new_vbuf)
- pipe_buffer_reference(&svga_render->vbuf, NULL);
+ pipe_resource_reference(&svga_render->vbuf, NULL);
if (new_ibuf)
- pipe_buffer_reference(&svga_render->ibuf, NULL);
+ pipe_resource_reference(&svga_render->ibuf, NULL);
if (!svga_render->vbuf) {
svga_render->vbuf_size = MAX2(size, svga_render->vbuf_alloc_size);
svga_render->vbuf = pipe_buffer_create(screen,
- 16,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
svga_render->vbuf_size);
if(!svga_render->vbuf) {
svga_context_flush(svga, NULL);
svga_render->vbuf = pipe_buffer_create(screen,
- 16,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
svga_render->vbuf_size);
assert(svga_render->vbuf);
}
@@ -117,14 +115,14 @@ svga_vbuf_render_map_vertices( struct vbuf_render *render )
{
struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
struct svga_context *svga = svga_render->svga;
- struct pipe_screen *screen = svga->pipe.screen;
- char *ptr = (char*)pipe_buffer_map(screen,
+ char *ptr = (char*)pipe_buffer_map(&svga->pipe,
svga_render->vbuf,
- PIPE_BUFFER_USAGE_CPU_WRITE |
- PIPE_BUFFER_USAGE_FLUSH_EXPLICIT |
- PIPE_BUFFER_USAGE_DISCARD |
- PIPE_BUFFER_USAGE_UNSYNCHRONIZED);
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_FLUSH_EXPLICIT |
+ PIPE_TRANSFER_DISCARD |
+ PIPE_TRANSFER_UNSYNCHRONIZED,
+ &svga_render->vbuf_transfer);
return ptr + svga_render->vbuf_offset;
}
@@ -135,14 +133,15 @@ svga_vbuf_render_unmap_vertices( struct vbuf_render *render,
{
struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
struct svga_context *svga = svga_render->svga;
- struct pipe_screen *screen = svga->pipe.screen;
unsigned offset, length;
size_t used = svga_render->vertex_size * ((size_t)max_index + 1);
offset = svga_render->vbuf_offset + svga_render->vertex_size * min_index;
length = svga_render->vertex_size * (max_index + 1 - min_index);
- pipe_buffer_flush_mapped_range(screen, svga_render->vbuf, offset, length);
- pipe_buffer_unmap(screen, svga_render->vbuf);
+ pipe_buffer_flush_mapped_range(&svga->pipe,
+ svga_render->vbuf_transfer,
+ offset, length);
+ pipe_buffer_unmap(&svga->pipe, svga_render->vbuf, svga_render->vbuf_transfer);
svga_render->min_index = min_index;
svga_render->max_index = max_index;
svga_render->vbuf_used = MAX2(svga_render->vbuf_used, used);
@@ -255,19 +254,18 @@ svga_vbuf_render_draw( struct vbuf_render *render,
assert(( svga_render->vbuf_offset - svga_render->vdecl_offset) % svga_render->vertex_size == 0);
if (svga_render->ibuf_size < svga_render->ibuf_offset + size)
- pipe_buffer_reference(&svga_render->ibuf, NULL);
+ pipe_resource_reference(&svga_render->ibuf, NULL);
if (!svga_render->ibuf) {
svga_render->ibuf_size = MAX2(size, svga_render->ibuf_alloc_size);
svga_render->ibuf = pipe_buffer_create(screen,
- 2,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_INDEX_BUFFER,
svga_render->ibuf_size);
svga_render->ibuf_offset = 0;
}
- pipe_buffer_write_nooverlap(screen, svga_render->ibuf,
- svga_render->ibuf_offset, 2 * nr_indices, indices);
+ pipe_buffer_write_nooverlap(&svga->pipe, svga_render->ibuf,
+ svga_render->ibuf_offset, 2 * nr_indices, indices);
/* off to hardware */
@@ -315,8 +313,8 @@ svga_vbuf_render_destroy( struct vbuf_render *render )
{
struct svga_vbuf_render *svga_render = svga_vbuf_render(render);
- pipe_buffer_reference(&svga_render->vbuf, NULL);
- pipe_buffer_reference(&svga_render->ibuf, NULL);
+ pipe_resource_reference(&svga_render->vbuf, NULL);
+ pipe_resource_reference(&svga_render->ibuf, NULL);
FREE(svga_render);
}
diff --git a/src/gallium/drivers/svga/svga_swtnl_draw.c b/src/gallium/drivers/svga/svga_swtnl_draw.c
index da15be155c..0037bbd5fe 100644
--- a/src/gallium/drivers/svga/svga_swtnl_draw.c
+++ b/src/gallium/drivers/svga/svga_swtnl_draw.c
@@ -37,12 +37,15 @@
enum pipe_error
svga_swtnl_draw_range_elements(struct svga_context *svga,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned min_index,
unsigned max_index,
unsigned prim, unsigned start, unsigned count)
{
+ struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
+ struct pipe_transfer *ib_transfer;
+ struct pipe_transfer *cb_transfer;
struct draw_context *draw = svga->swtnl.draw;
unsigned i;
const void *map;
@@ -64,17 +67,19 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
* Map vertex buffers
*/
for (i = 0; i < svga->curr.num_vertex_buffers; i++) {
- map = pipe_buffer_map(svga->pipe.screen,
+ map = pipe_buffer_map(&svga->pipe,
svga->curr.vb[i].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &vb_transfer[i]);
draw_set_mapped_vertex_buffer(draw, i, map);
}
/* Map index buffer, if present */
if (indexBuffer) {
- map = pipe_buffer_map(svga->pipe.screen, indexBuffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(&svga->pipe, indexBuffer,
+ PIPE_TRANSFER_READ,
+ &ib_transfer);
draw_set_mapped_element_buffer_range(draw,
indexSize,
@@ -84,14 +89,15 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
}
if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
- map = pipe_buffer_map(svga->pipe.screen,
+ map = pipe_buffer_map(&svga->pipe,
svga->curr.cb[PIPE_SHADER_VERTEX],
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &cb_transfer);
assert(map);
draw_set_mapped_constant_buffer(
draw, PIPE_SHADER_VERTEX, 0,
map,
- svga->curr.cb[PIPE_SHADER_VERTEX]->size);
+ svga->curr.cb[PIPE_SHADER_VERTEX]->width0);
}
draw_arrays(svga->swtnl.draw, prim, start, count);
@@ -105,18 +111,20 @@ svga_swtnl_draw_range_elements(struct svga_context *svga,
* unmap vertex/index buffers
*/
for (i = 0; i < svga->curr.num_vertex_buffers; i++) {
- pipe_buffer_unmap(svga->pipe.screen, svga->curr.vb[i].buffer);
+ pipe_buffer_unmap(&svga->pipe, svga->curr.vb[i].buffer,
+ vb_transfer[i]);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (indexBuffer) {
- pipe_buffer_unmap(svga->pipe.screen, indexBuffer);
+ pipe_buffer_unmap(&svga->pipe, indexBuffer, ib_transfer);
draw_set_mapped_element_buffer(draw, 0, NULL);
}
if (svga->curr.cb[PIPE_SHADER_VERTEX]) {
- pipe_buffer_unmap(svga->pipe.screen,
- svga->curr.cb[PIPE_SHADER_VERTEX]);
+ pipe_buffer_unmap(&svga->pipe,
+ svga->curr.cb[PIPE_SHADER_VERTEX],
+ cb_transfer);
}
return ret;
diff --git a/src/gallium/drivers/svga/svga_swtnl_private.h b/src/gallium/drivers/svga/svga_swtnl_private.h
index 9bbb42910f..8d08070843 100644
--- a/src/gallium/drivers/svga/svga_swtnl_private.h
+++ b/src/gallium/drivers/svga/svga_swtnl_private.h
@@ -45,8 +45,10 @@ struct svga_vbuf_render {
unsigned prim;
- struct pipe_buffer *vbuf;
- struct pipe_buffer *ibuf;
+ struct pipe_resource *vbuf;
+ struct pipe_resource *ibuf;
+ struct pipe_transfer *vbuf_transfer;
+ struct pipe_transfer *ibuf_transfer;
/* current size of buffer */
size_t vbuf_size;
diff --git a/src/gallium/drivers/svga/svga_winsys.h b/src/gallium/drivers/svga/svga_winsys.h
index d4bb176f9a..3892addafd 100644
--- a/src/gallium/drivers/svga/svga_winsys.h
+++ b/src/gallium/drivers/svga/svga_winsys.h
@@ -49,13 +49,18 @@ struct svga_winsys_buffer;
struct pipe_screen;
struct pipe_context;
struct pipe_fence_handle;
-struct pipe_texture;
+struct pipe_resource;
struct svga_region;
struct winsys_handle;
-#define SVGA_BUFFER_USAGE_PINNED (PIPE_BUFFER_USAGE_CUSTOM << 0)
-#define SVGA_BUFFER_USAGE_WRAPPED (PIPE_BUFFER_USAGE_CUSTOM << 1)
+#define SVGA_BUFFER_USAGE_PINNED (1 << 0)
+#define SVGA_BUFFER_USAGE_WRAPPED (1 << 1)
+
+
+#define SVGA_RELOC_WRITE 0x1
+#define SVGA_RELOC_READ 0x2
+
/** Opaque surface handle */
@@ -189,7 +194,7 @@ struct svga_winsys_screen
/**
* Creates a surface from a winsys handle.
- * Used to implement pipe_screen::texture_from_handle.
+ * Used to implement pipe_screen::resource_from_handle.
*/
struct svga_winsys_surface *
(*surface_from_handle)(struct svga_winsys_screen *sws,
@@ -198,7 +203,7 @@ struct svga_winsys_screen
/**
* Get a winsys_handle from a surface.
- * Used to implement pipe_screen::texture_get_handle.
+ * Used to implement pipe_screen::resource_get_handle.
*/
boolean
(*surface_get_handle)(struct svga_winsys_screen *sws,
@@ -225,13 +230,7 @@ struct svga_winsys_screen
/**
* Buffer management. Buffer attributes are mostly fixed over its lifetime.
*
- * Remember that gallium gets to choose the interface it needs, and the
- * window systems must then implement that interface (rather than the
- * other way around...).
- *
- * usage is a bitmask of PIPE_BUFFER_USAGE_PIXEL/VERTEX/INDEX/CONSTANT. This
- * usage argument is only an optimization hint, not a guarantee, therefore
- * proper behavior must be observed in all circumstances.
+ * XXX usage seems to be a bitmask of SVGA_BUFFER_USAGE_* flags.
*
* alignment indicates the client's alignment requirements, eg for
* SSE instructions.
@@ -245,9 +244,9 @@ struct svga_winsys_screen
/**
* Map the entire data store of a buffer object into the client's address.
* flags is a bitmask of:
- * - PIPE_BUFFER_USAGE_CPU_READ/WRITE
- * - PIPE_BUFFER_USAGE_DONTBLOCK
- * - PIPE_BUFFER_USAGE_UNSYNCHRONIZED
+ * - PB_USAGE_CPU_READ/WRITE
+ * - PB_USAGE_DONTBLOCK
+ * - PB_USAGE_UNSYNCHRONIZED
*/
void *
(*buffer_map)( struct svga_winsys_screen *sws,
@@ -298,12 +297,12 @@ svga_screen_create(struct svga_winsys_screen *sws);
struct svga_winsys_screen *
svga_winsys_screen(struct pipe_screen *screen);
-struct pipe_buffer *
+struct pipe_resource *
svga_screen_buffer_wrap_surface(struct pipe_screen *screen,
enum SVGA3dSurfaceFormat format,
struct svga_winsys_surface *srf);
struct svga_winsys_surface *
-svga_screen_buffer_get_winsys_surface(struct pipe_buffer *buffer);
+svga_screen_buffer_get_winsys_surface(struct pipe_resource *buffer);
#endif /* SVGA_WINSYS_H_ */
diff --git a/src/gallium/drivers/trace/Makefile b/src/gallium/drivers/trace/Makefile
index dd6831c70a..78f6347dc7 100644
--- a/src/gallium/drivers/trace/Makefile
+++ b/src/gallium/drivers/trace/Makefile
@@ -4,7 +4,6 @@ include $(TOP)/configs/current
LIBNAME = trace
C_SOURCES = \
- tr_buffer.c \
tr_context.c \
tr_dump.c \
tr_dump_state.c \
diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript
index c1675d1c16..5f1fb17966 100644
--- a/src/gallium/drivers/trace/SConscript
+++ b/src/gallium/drivers/trace/SConscript
@@ -5,7 +5,6 @@ env = env.Clone()
trace = env.ConvenienceLibrary(
target = 'trace',
source = [
- 'tr_buffer.c',
'tr_context.c',
'tr_drm.c',
'tr_dump.c',
diff --git a/src/gallium/drivers/trace/tr_buffer.c b/src/gallium/drivers/trace/tr_buffer.c
deleted file mode 100644
index fa2ac068eb..0000000000
--- a/src/gallium/drivers/trace/tr_buffer.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#include "util/u_inlines.h"
-#include "util/u_memory.h"
-#include "util/u_simple_list.h"
-
-#include "tr_buffer.h"
-
-struct pipe_buffer *
-trace_buffer_create(struct trace_screen *tr_scr,
- struct pipe_buffer *buffer)
-{
- struct trace_buffer *tr_buf;
-
- if(!buffer)
- goto error;
-
- assert(buffer->screen == tr_scr->screen);
-
- tr_buf = CALLOC_STRUCT(trace_buffer);
- if(!tr_buf)
- goto error;
-
- memcpy(&tr_buf->base, buffer, sizeof(struct pipe_buffer));
-
- pipe_reference_init(&tr_buf->base.reference, 1);
- tr_buf->base.screen = &tr_scr->base;
- tr_buf->buffer = buffer;
-
- trace_screen_add_to_list(tr_scr, buffers, tr_buf);
-
- return &tr_buf->base;
-
-error:
- pipe_buffer_reference(&buffer, NULL);
- return NULL;
-}
-
-
-void
-trace_buffer_destroy(struct trace_screen *tr_scr,
- struct pipe_buffer *buffer)
-{
- struct trace_buffer *tr_buf = trace_buffer(buffer);
-
- trace_screen_remove_from_list(tr_scr, buffers, tr_buf);
-
- pipe_buffer_reference(&tr_buf->buffer, NULL);
- FREE(tr_buf);
-}
diff --git a/src/gallium/drivers/trace/tr_buffer.h b/src/gallium/drivers/trace/tr_buffer.h
deleted file mode 100644
index 1a2d0b9aea..0000000000
--- a/src/gallium/drivers/trace/tr_buffer.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 VMware, Inc.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef TR_BUFFER_H_
-#define TR_BUFFER_H_
-
-
-#include "pipe/p_compiler.h"
-#include "pipe/p_state.h"
-
-#include "tr_screen.h"
-
-
-struct trace_buffer
-{
- struct pipe_buffer base;
-
- struct pipe_buffer *buffer;
-
- struct tr_list list;
-
- void *map;
- boolean range_flushed;
-};
-
-
-static INLINE struct trace_buffer *
-trace_buffer(struct pipe_buffer *buffer)
-{
- if(!buffer)
- return NULL;
- (void)trace_screen(buffer->screen);
- return (struct trace_buffer *)buffer;
-}
-
-
-struct pipe_buffer *
-trace_buffer_create(struct trace_screen *tr_scr,
- struct pipe_buffer *buffer);
-
-void
-trace_buffer_destroy(struct trace_screen *tr_scr,
- struct pipe_buffer *buffer);
-
-
-#endif
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index 5c24bd1f7d..dd0fd8ed98 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -36,43 +36,26 @@
#include "tr_dump.h"
#include "tr_dump_state.h"
#include "tr_state.h"
-#include "tr_buffer.h"
#include "tr_screen.h"
#include "tr_texture.h"
-static INLINE struct pipe_buffer *
-trace_buffer_unwrap(struct trace_context *tr_ctx,
- struct pipe_buffer *buffer)
-{
- struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
- struct trace_buffer *tr_buf;
-
- if(!buffer)
- return NULL;
- tr_buf = trace_buffer(buffer);
- assert(tr_buf->buffer);
- assert(tr_buf->buffer->screen == tr_scr->screen);
- (void) tr_scr;
- return tr_buf->buffer;
-}
-
-static INLINE struct pipe_texture *
-trace_texture_unwrap(struct trace_context *tr_ctx,
- struct pipe_texture *texture)
+static INLINE struct pipe_resource *
+trace_resource_unwrap(struct trace_context *tr_ctx,
+ struct pipe_resource *resource)
{
- struct trace_texture *tr_tex;
+ struct trace_resource *tr_tex;
- if(!texture)
+ if(!resource)
return NULL;
- tr_tex = trace_texture(texture);
+ tr_tex = trace_resource(resource);
- assert(tr_tex->texture);
- return tr_tex->texture;
+ assert(tr_tex->resource);
+ return tr_tex->resource;
}
@@ -193,22 +176,20 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
static INLINE void
trace_context_draw_elements(struct pipe_context *_pipe,
- struct pipe_buffer *_indexBuffer,
+ struct pipe_resource *_indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_buffer *tr_buf = trace_buffer(_indexBuffer);
+ struct trace_resource *tr_buf = trace_resource(_indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
- struct pipe_buffer *indexBuffer = tr_buf->buffer;
+ struct pipe_resource *indexBuffer = tr_buf->resource;
if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
return;
trace_context_draw_block(tr_ctx, 1);
- trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
-
trace_dump_call_begin("pipe_context", "draw_elements");
trace_dump_arg(ptr, pipe);
@@ -228,7 +209,7 @@ trace_context_draw_elements(struct pipe_context *_pipe,
static INLINE void
trace_context_draw_range_elements(struct pipe_context *_pipe,
- struct pipe_buffer *_indexBuffer,
+ struct pipe_resource *_indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -237,17 +218,15 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_buffer *tr_buf = trace_buffer(_indexBuffer);
+ struct trace_resource *tr_buf = trace_resource(_indexBuffer);
struct pipe_context *pipe = tr_ctx->pipe;
- struct pipe_buffer *indexBuffer = tr_buf->buffer;
+ struct pipe_resource *indexBuffer = tr_buf->resource;
if (tr_ctx->curr.fs->disabled || tr_ctx->curr.vs->disabled)
return;
trace_context_draw_block(tr_ctx, 1);
- trace_screen_user_buffer_update(_pipe->screen, indexBuffer);
-
trace_dump_call_begin("pipe_context", "draw_range_elements");
trace_dump_arg(ptr, pipe);
@@ -897,14 +876,13 @@ trace_context_set_clip_state(struct pipe_context *_pipe,
static INLINE void
trace_context_set_constant_buffer(struct pipe_context *_pipe,
uint shader, uint index,
- struct pipe_buffer *buffer)
+ struct pipe_resource *buffer)
{
struct trace_context *tr_ctx = trace_context(_pipe);
struct pipe_context *pipe = tr_ctx->pipe;
if (buffer) {
- trace_screen_user_buffer_update(_pipe->screen, buffer);
- buffer = trace_buffer_unwrap(tr_ctx, buffer);
+ buffer = trace_resource_unwrap(tr_ctx, buffer);
}
trace_dump_call_begin("pipe_context", "set_constant_buffer");
@@ -933,11 +911,11 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
tr_ctx->curr.nr_cbufs = state->nr_cbufs;
for (i = 0; i < state->nr_cbufs; i++)
if (state->cbufs[i])
- tr_ctx->curr.cbufs[i] = trace_texture(state->cbufs[i]->texture);
+ tr_ctx->curr.cbufs[i] = trace_resource(state->cbufs[i]->texture);
else
tr_ctx->curr.cbufs[i] = NULL;
if (state->zsbuf)
- tr_ctx->curr.zsbuf = trace_texture(state->zsbuf->texture);
+ tr_ctx->curr.zsbuf = trace_resource(state->zsbuf->texture);
else
tr_ctx->curr.zsbuf = NULL;
}
@@ -1018,13 +996,13 @@ trace_context_set_viewport_state(struct pipe_context *_pipe,
static struct pipe_sampler_view *
trace_create_sampler_view(struct pipe_context *_pipe,
- struct pipe_texture *_texture,
+ struct pipe_resource *_resource,
const struct pipe_sampler_view *templ)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_texture *tr_tex = trace_texture(_texture);
+ struct trace_resource *tr_tex = trace_resource(_resource);
struct pipe_context *pipe = tr_ctx->pipe;
- struct pipe_texture *texture = tr_tex->texture;
+ struct pipe_resource *texture = tr_tex->resource;
struct trace_sampler_view *result = CALLOC_STRUCT(trace_sampler_view);
trace_dump_call_begin("pipe_context", "create_sampler_view");
@@ -1038,7 +1016,7 @@ trace_create_sampler_view(struct pipe_context *_pipe,
result->base = *templ;
result->base.reference.count = 1;
result->base.texture = NULL;
- pipe_texture_reference(&result->base.texture, _texture);
+ pipe_resource_reference(&result->base.texture, _resource);
result->base.context = _pipe;
trace_dump_ret(ptr, result);
@@ -1067,7 +1045,7 @@ trace_sampler_view_destroy(struct pipe_context *_pipe,
trace_dump_call_end();
- pipe_texture_reference(&_view->texture, NULL);
+ pipe_resource_reference(&_view->texture, NULL);
FREE(_view);
}
@@ -1143,9 +1121,6 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe,
struct pipe_context *pipe = tr_ctx->pipe;
unsigned i;
- for(i = 0; i < num_buffers; ++i)
- trace_screen_user_buffer_update(_pipe->screen, buffers[i].buffer);
-
trace_dump_call_begin("pipe_context", "set_vertex_buffers");
trace_dump_arg(ptr, pipe);
@@ -1159,7 +1134,7 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe,
struct pipe_vertex_buffer *_buffers = malloc(num_buffers * sizeof(*_buffers));
memcpy(_buffers, buffers, num_buffers * sizeof(*_buffers));
for (i = 0; i < num_buffers; i++)
- _buffers[i].buffer = trace_buffer_unwrap(tr_ctx, buffers[i].buffer);
+ _buffers[i].buffer = trace_resource_unwrap(tr_ctx, buffers[i].buffer);
pipe->set_vertex_buffers(pipe, num_buffers, _buffers);
free(_buffers);
} else {
@@ -1296,45 +1271,23 @@ trace_context_destroy(struct pipe_context *_pipe)
}
static unsigned int
-trace_is_texture_referenced( struct pipe_context *_pipe,
- struct pipe_texture *_texture,
- unsigned face, unsigned level)
+trace_is_resource_referenced( struct pipe_context *_pipe,
+ struct pipe_resource *_resource,
+ unsigned face, unsigned level)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_texture *tr_tex = trace_texture(_texture);
+ struct trace_resource *tr_tex = trace_resource(_resource);
struct pipe_context *pipe = tr_ctx->pipe;
- struct pipe_texture *texture = tr_tex->texture;
+ struct pipe_resource *texture = tr_tex->resource;
unsigned int referenced;
- trace_dump_call_begin("pipe_context", "is_texture_referenced");
+ trace_dump_call_begin("pipe_context", "is_resource_referenced");
trace_dump_arg(ptr, pipe);
trace_dump_arg(ptr, texture);
trace_dump_arg(uint, face);
trace_dump_arg(uint, level);
- referenced = pipe->is_texture_referenced(pipe, texture, face, level);
-
- trace_dump_ret(uint, referenced);
- trace_dump_call_end();
-
- return referenced;
-}
-
-static unsigned int
-trace_is_buffer_referenced( struct pipe_context *_pipe,
- struct pipe_buffer *_buf)
-{
- struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_buffer *tr_buf = trace_buffer(_buf);
- struct pipe_context *pipe = tr_ctx->pipe;
- struct pipe_buffer *buf = tr_buf->buffer;
- unsigned int referenced;
-
- trace_dump_call_begin("pipe_context", "is_buffer_referenced");
- trace_dump_arg(ptr, pipe);
- trace_dump_arg(ptr, buf);
-
- referenced = pipe->is_buffer_referenced(pipe, buf);
+ referenced = pipe->is_resource_referenced(pipe, texture, face, level);
trace_dump_ret(uint, referenced);
trace_dump_call_end();
@@ -1349,37 +1302,35 @@ trace_is_buffer_referenced( struct pipe_context *_pipe,
static struct pipe_transfer *
-trace_context_get_tex_transfer(struct pipe_context *_context,
- struct pipe_texture *_texture,
- unsigned face, unsigned level,
- unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y, unsigned w, unsigned h)
+trace_context_get_transfer(struct pipe_context *_context,
+ struct pipe_resource *_resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box)
{
struct trace_context *tr_context = trace_context(_context);
- struct trace_texture *tr_tex = trace_texture(_texture);
+ struct trace_resource *tr_tex = trace_resource(_resource);
struct pipe_context *context = tr_context->pipe;
- struct pipe_texture *texture = tr_tex->texture;
+ struct pipe_resource *texture = tr_tex->resource;
struct pipe_transfer *result = NULL;
assert(texture->screen == context->screen);
- trace_dump_call_begin("pipe_context", "get_tex_transfer");
+ trace_dump_call_begin("pipe_context", "get_transfer");
trace_dump_arg(ptr, context);
trace_dump_arg(ptr, texture);
- trace_dump_arg(uint, face);
- trace_dump_arg(uint, level);
- trace_dump_arg(uint, zslice);
+ trace_dump_arg(uint, sr.face);
+ trace_dump_arg(uint, sr.level);
trace_dump_arg(uint, usage);
+ trace_dump_arg(uint, box->x);
+ trace_dump_arg(uint, box->y);
+ trace_dump_arg(uint, box->z);
+ trace_dump_arg(uint, box->width);
+ trace_dump_arg(uint, box->height);
+ trace_dump_arg(uint, box->depth);
- trace_dump_arg(uint, x);
- trace_dump_arg(uint, y);
- trace_dump_arg(uint, w);
- trace_dump_arg(uint, h);
-
- result = context->get_tex_transfer(context, texture, face, level, zslice, usage,
- x, y, w, h);
+ result = context->get_transfer(context, texture, sr, usage, box);
trace_dump_ret(ptr, result);
@@ -1393,7 +1344,7 @@ trace_context_get_tex_transfer(struct pipe_context *_context,
static void
-trace_context_tex_transfer_destroy(struct pipe_context *_context,
+trace_context_transfer_destroy(struct pipe_context *_context,
struct pipe_transfer *_transfer)
{
struct trace_context *tr_context = trace_context(_context);
@@ -1401,7 +1352,7 @@ trace_context_tex_transfer_destroy(struct pipe_context *_context,
struct pipe_context *context = tr_context->pipe;
struct pipe_transfer *transfer = tr_trans->transfer;
- trace_dump_call_begin("pipe_context", "tex_transfer_destroy");
+ trace_dump_call_begin("pipe_context", "transfer_destroy");
trace_dump_arg(ptr, context);
trace_dump_arg(ptr, transfer);
@@ -1435,6 +1386,33 @@ trace_context_transfer_map(struct pipe_context *_context,
static void
+trace_context_transfer_flush_region( struct pipe_context *_context,
+ struct pipe_transfer *_transfer,
+ const struct pipe_box *box)
+{
+ struct trace_context *tr_context = trace_context(_context);
+ struct trace_transfer *tr_transfer = trace_transfer(_transfer);
+ struct pipe_context *context = tr_context->pipe;
+ struct pipe_transfer *transfer = tr_transfer->transfer;
+
+ trace_dump_call_begin("pipe_context", "transfer_flush_region");
+
+ trace_dump_arg(ptr, context);
+ trace_dump_arg(ptr, transfer);
+ trace_dump_arg(uint, box->x);
+ trace_dump_arg(uint, box->y);
+ trace_dump_arg(uint, box->z);
+ trace_dump_arg(uint, box->width);
+ trace_dump_arg(uint, box->height);
+ trace_dump_arg(uint, box->depth);
+ trace_dump_call_end();
+
+ context->transfer_flush_region(context,
+ transfer,
+ box);
+}
+
+static void
trace_context_transfer_unmap(struct pipe_context *_context,
struct pipe_transfer *_transfer)
{
@@ -1444,8 +1422,6 @@ trace_context_transfer_unmap(struct pipe_context *_context,
struct pipe_transfer *transfer = tr_trans->transfer;
if(tr_trans->map) {
- size_t size = util_format_get_nblocksy(transfer->texture->format, transfer->height) * transfer->stride;
-
trace_dump_call_begin("pipe_context", "transfer_write");
trace_dump_arg(ptr, context);
@@ -1457,12 +1433,16 @@ trace_context_transfer_unmap(struct pipe_context *_context,
trace_dump_arg_end();
trace_dump_arg_begin("data");
- trace_dump_bytes(tr_trans->map, size);
+ trace_dump_box_bytes(tr_trans->map,
+ transfer->resource->format,
+ &transfer->box,
+ transfer->stride,
+ transfer->slice_stride);
trace_dump_arg_end();
- trace_dump_arg_begin("size");
- trace_dump_uint(size);
- trace_dump_arg_end();
+// trace_dump_arg_begin("size");
+// trace_dump_uint(size);
+// trace_dump_arg_end();
trace_dump_call_end();
@@ -1472,6 +1452,57 @@ trace_context_transfer_unmap(struct pipe_context *_context,
context->transfer_unmap(context, transfer);
}
+
+static void
+trace_context_transfer_inline_write(struct pipe_context *_context,
+ struct pipe_resource *_resource,
+ struct pipe_subresource sr,
+ unsigned usage,
+ const struct pipe_box *box,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride)
+{
+ struct trace_context *tr_context = trace_context(_context);
+ struct trace_resource *tr_tex = trace_resource(_resource);
+ struct pipe_context *context = tr_context->pipe;
+ struct pipe_resource *resource = tr_tex->resource;
+
+ assert(resource->screen == context->screen);
+
+ trace_dump_call_begin("pipe_context", "transfer_inline_write");
+
+ trace_dump_arg(ptr, context);
+ trace_dump_arg(ptr, resource);
+ trace_dump_arg(uint, sr.face);
+ trace_dump_arg(uint, sr.level);
+ trace_dump_arg(uint, usage);
+ trace_dump_arg(uint, box->x);
+ trace_dump_arg(uint, box->y);
+ trace_dump_arg(uint, box->z);
+ trace_dump_arg(uint, box->width);
+ trace_dump_arg(uint, box->height);
+ trace_dump_arg(uint, box->depth);
+ trace_dump_arg(uint, stride);
+ trace_dump_arg(uint, slice_stride);
+
+ trace_dump_arg_begin("data");
+ trace_dump_box_bytes(data,
+ resource->format,
+ box,
+ stride,
+ slice_stride);
+ trace_dump_arg_end();
+
+ trace_dump_call_end();
+
+ context->transfer_inline_write(context, resource,
+ sr, usage, box, data, stride, slice_stride);
+}
+
+
+
+
static const struct debug_named_value rbug_blocker_flags[] = {
{"before", 1},
{"after", 2},
@@ -1555,13 +1586,14 @@ trace_context_create(struct trace_screen *tr_scr,
tr_ctx->base.surface_fill = trace_context_surface_fill;
tr_ctx->base.clear = trace_context_clear;
tr_ctx->base.flush = trace_context_flush;
- tr_ctx->base.is_texture_referenced = trace_is_texture_referenced;
- tr_ctx->base.is_buffer_referenced = trace_is_buffer_referenced;
+ tr_ctx->base.is_resource_referenced = trace_is_resource_referenced;
- tr_ctx->base.get_tex_transfer = trace_context_get_tex_transfer;
- tr_ctx->base.tex_transfer_destroy = trace_context_tex_transfer_destroy;
+ tr_ctx->base.get_transfer = trace_context_get_transfer;
+ tr_ctx->base.transfer_destroy = trace_context_transfer_destroy;
tr_ctx->base.transfer_map = trace_context_transfer_map;
tr_ctx->base.transfer_unmap = trace_context_transfer_unmap;
+ tr_ctx->base.transfer_flush_region = trace_context_transfer_flush_region;
+ tr_ctx->base.transfer_inline_write = trace_context_transfer_inline_write;
tr_ctx->pipe = pipe;
diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h
index feec9b6bbf..1b4121d80a 100644
--- a/src/gallium/drivers/trace/tr_context.h
+++ b/src/gallium/drivers/trace/tr_context.h
@@ -60,8 +60,8 @@ struct trace_context
unsigned num_vert_sampler_views;
unsigned nr_cbufs;
- struct trace_texture *cbufs[PIPE_MAX_COLOR_BUFS];
- struct trace_texture *zsbuf;
+ struct trace_resource *cbufs[PIPE_MAX_COLOR_BUFS];
+ struct trace_resource *zsbuf;
} curr;
struct {
@@ -69,7 +69,7 @@ struct trace_context
struct trace_shader *vs;
struct trace_sampler_view *sampler_view;
- struct trace_texture *surf;
+ struct trace_resource *surf;
int blocker;
} draw_rule;
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 1affafdddc..19cf0de1d3 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -54,7 +54,6 @@
#include "tr_dump.h"
#include "tr_screen.h"
#include "tr_texture.h"
-#include "tr_buffer.h"
static struct os_stream *stream = NULL;
@@ -471,6 +470,16 @@ void trace_dump_bytes(const void *data,
trace_dump_writes("</bytes>");
}
+void trace_dump_box_bytes(const void *data,
+ unsigned format,
+ const struct pipe_box *box,
+ unsigned stride,
+ unsigned slice_stride)
+{
+ //size_t size = util_format_get_nblocksy(transfer->resource->format, transfer->box.height) * transfer->stride;
+
+}
+
void trace_dump_string(const char *str)
{
if (!dumping)
@@ -574,27 +583,15 @@ void trace_dump_ptr(const void *value)
trace_dump_null();
}
-void trace_dump_buffer_ptr(struct pipe_buffer *_buffer)
-{
- if (!dumping)
- return;
-
- if (_buffer) {
- struct trace_buffer *tr_buf = trace_buffer(_buffer);
- trace_dump_ptr(tr_buf->buffer);
- } else {
- trace_dump_null();
- }
-}
-void trace_dump_texture_ptr(struct pipe_texture *_texture)
+void trace_dump_resource_ptr(struct pipe_resource *_resource)
{
if (!dumping)
return;
- if (_texture) {
- struct trace_texture *tr_tex = trace_texture(_texture);
- trace_dump_ptr(tr_tex->texture);
+ if (_resource) {
+ struct trace_resource *tr_resource = trace_resource(_resource);
+ trace_dump_ptr(tr_resource->resource);
} else {
trace_dump_null();
}
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index 32592bab12..9383ccdecb 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -36,11 +36,11 @@
#include "pipe/p_compiler.h"
-
struct pipe_buffer;
-struct pipe_texture;
+struct pipe_resource;
struct pipe_surface;
struct pipe_transfer;
+struct pipe_box;
/*
* Call before use.
@@ -92,6 +92,11 @@ void trace_dump_int(long long int value);
void trace_dump_uint(long long unsigned value);
void trace_dump_float(double value);
void trace_dump_bytes(const void *data, size_t size);
+void trace_dump_box_bytes(const void *data,
+ unsigned format,
+ const struct pipe_box *box,
+ unsigned stride,
+ unsigned slice_stride);
void trace_dump_string(const char *str);
void trace_dump_enum(const char *value);
void trace_dump_array_begin(void);
@@ -105,8 +110,7 @@ void trace_dump_member_end(void);
void trace_dump_null(void);
void trace_dump_ptr(const void *value);
/* will turn a wrapped object into the real one and dump ptr */
-void trace_dump_buffer_ptr(struct pipe_buffer *_buffer);
-void trace_dump_texture_ptr(struct pipe_texture *_texture);
+void trace_dump_resource_ptr(struct pipe_resource *_texture);
void trace_dump_surface_ptr(struct pipe_surface *_surface);
void trace_dump_transfer_ptr(struct pipe_transfer *_transfer);
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index f82dd01c69..1b917ff3fb 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -44,7 +44,7 @@ void trace_dump_format(enum pipe_format format)
}
-void trace_dump_template(const struct pipe_texture *templat)
+void trace_dump_template(const struct pipe_resource *templat)
{
if (!trace_dumping_enabled_locked())
return;
@@ -54,7 +54,7 @@ void trace_dump_template(const struct pipe_texture *templat)
return;
}
- trace_dump_struct_begin("pipe_texture");
+ trace_dump_struct_begin("pipe_resource");
trace_dump_member(int, templat, target);
trace_dump_member(format, templat, format);
@@ -72,7 +72,9 @@ void trace_dump_template(const struct pipe_texture *templat)
trace_dump_member_end();
trace_dump_member(uint, templat, last_level);
- trace_dump_member(uint, templat, tex_usage);
+ trace_dump_member(uint, templat, _usage);
+ trace_dump_member(uint, templat, bind);
+ trace_dump_member(uint, templat, flags);
trace_dump_struct_end();
}
@@ -428,16 +430,16 @@ void trace_dump_transfer(const struct pipe_transfer *state)
trace_dump_struct_begin("pipe_transfer");
- trace_dump_member(uint, state, width);
- trace_dump_member(uint, state, height);
+ trace_dump_member(uint, state, box.width);
+ trace_dump_member(uint, state, box.height);
trace_dump_member(uint, state, stride);
trace_dump_member(uint, state, usage);
- trace_dump_member(ptr, state, texture);
- trace_dump_member(uint, state, face);
- trace_dump_member(uint, state, level);
- trace_dump_member(uint, state, zslice);
+ trace_dump_member(ptr, state, resource);
+ trace_dump_member(uint, state, sr.face);
+ trace_dump_member(uint, state, sr.level);
+ trace_dump_member(uint, state, box.z);
trace_dump_struct_end();
}
@@ -458,7 +460,7 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
trace_dump_member(uint, state, stride);
trace_dump_member(uint, state, max_index);
trace_dump_member(uint, state, buffer_offset);
- trace_dump_member(buffer_ptr, state, buffer);
+ trace_dump_member(resource_ptr, state, buffer);
trace_dump_struct_end();
}
diff --git a/src/gallium/drivers/trace/tr_dump_state.h b/src/gallium/drivers/trace/tr_dump_state.h
index 3400367d82..41f6263935 100644
--- a/src/gallium/drivers/trace/tr_dump_state.h
+++ b/src/gallium/drivers/trace/tr_dump_state.h
@@ -35,7 +35,7 @@
void trace_dump_format(enum pipe_format format);
-void trace_dump_template(const struct pipe_texture *templat);
+void trace_dump_template(const struct pipe_resource *templat);
void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state);
diff --git a/src/gallium/drivers/trace/tr_rbug.c b/src/gallium/drivers/trace/tr_rbug.c
index 53ab8c686d..3ce1b85854 100644
--- a/src/gallium/drivers/trace/tr_rbug.c
+++ b/src/gallium/drivers/trace/tr_rbug.c
@@ -29,6 +29,7 @@
#include "os/os_thread.h"
#include "util/u_format.h"
#include "util/u_string.h"
+#include "util/u_inlines.h"
#include "util/u_memory.h"
#include "util/u_simple_list.h"
#include "util/u_network.h"
@@ -38,7 +39,6 @@
#include "tr_dump.h"
#include "tr_state.h"
-#include "tr_buffer.h"
#include "tr_texture.h"
#include "rbug/rbug.h"
@@ -150,7 +150,7 @@ static int
trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
{
struct trace_screen *tr_scr = tr_rbug->tr_scr;
- struct trace_texture *tr_tex = NULL;
+ struct trace_resource *tr_tex = NULL;
struct tr_list *ptr;
rbug_texture_t *texs;
int i = 0;
@@ -158,7 +158,7 @@ trace_rbug_texture_list(struct trace_rbug *tr_rbug, struct rbug_header *header,
pipe_mutex_lock(tr_scr->list_mutex);
texs = MALLOC(tr_scr->num_textures * sizeof(rbug_texture_t));
foreach(ptr, &tr_scr->textures) {
- tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+ tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list));
texs[i++] = VOID2U64(tr_tex);
}
pipe_mutex_unlock(tr_scr->list_mutex);
@@ -173,14 +173,14 @@ static int
trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header, uint32_t serial)
{
struct trace_screen *tr_scr = tr_rbug->tr_scr;
- struct trace_texture *tr_tex = NULL;
+ struct trace_resource *tr_tex = NULL;
struct rbug_proto_texture_info *gpti = (struct rbug_proto_texture_info *)header;
struct tr_list *ptr;
- struct pipe_texture *t;
+ struct pipe_resource *t;
pipe_mutex_lock(tr_scr->list_mutex);
foreach(ptr, &tr_scr->textures) {
- tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+ tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list));
if (gpti->texture == VOID2U64(tr_tex))
break;
tr_tex = NULL;
@@ -191,7 +191,7 @@ trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header,
return -ESRCH;
}
- t = tr_tex->texture;
+ t = tr_tex->resource;
rbug_send_texture_info_reply(tr_rbug->con, serial,
t->target, t->format,
&t->width0, 1,
@@ -202,7 +202,7 @@ trace_rbug_texture_info(struct trace_rbug *tr_rbug, struct rbug_header *header,
util_format_get_blocksize(t->format),
t->last_level,
t->nr_samples,
- t->tex_usage,
+ t->bind,
NULL);
pipe_mutex_unlock(tr_scr->list_mutex);
@@ -216,18 +216,18 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
struct rbug_proto_texture_read *gptr = (struct rbug_proto_texture_read *)header;
struct trace_screen *tr_scr = tr_rbug->tr_scr;
- struct trace_texture *tr_tex = NULL;
+ struct trace_resource *tr_tex = NULL;
struct tr_list *ptr;
struct pipe_context *context = tr_scr->private_context;
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
struct pipe_transfer *t;
void *map;
pipe_mutex_lock(tr_scr->list_mutex);
foreach(ptr, &tr_scr->textures) {
- tr_tex = (struct trace_texture *)((char*)ptr - offsetof(struct trace_texture, list));
+ tr_tex = (struct trace_resource *)((char*)ptr - offsetof(struct trace_resource, list));
if (gptr->texture == VOID2U64(tr_tex))
break;
tr_tex = NULL;
@@ -238,8 +238,8 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
return -ESRCH;
}
- tex = tr_tex->texture;
- t = context->get_tex_transfer(context, tex,
+ tex = tr_tex->resource;
+ t = pipe_get_transfer(context, tex,
gptr->face, gptr->level, gptr->zslice,
PIPE_TRANSFER_READ,
gptr->x, gptr->y, gptr->w, gptr->h);
@@ -247,17 +247,18 @@ trace_rbug_texture_read(struct trace_rbug *tr_rbug, struct rbug_header *header,
map = context->transfer_map(context, t);
rbug_send_texture_read_reply(tr_rbug->con, serial,
- t->texture->format,
- util_format_get_blockwidth(t->texture->format),
- util_format_get_blockheight(t->texture->format),
- util_format_get_blocksize(t->texture->format),
+ t->resource->format,
+ util_format_get_blockwidth(t->resource->format),
+ util_format_get_blockheight(t->resource->format),
+ util_format_get_blocksize(t->resource->format),
(uint8_t*)map,
- t->stride * util_format_get_nblocksy(t->texture->format, t->height),
+ t->stride * util_format_get_nblocksy(t->resource->format,
+ t->box.height),
t->stride,
NULL);
context->transfer_unmap(context, t);
- context->tex_transfer_destroy(context, t);
+ context->transfer_destroy(context, t);
pipe_mutex_unlock(tr_scr->list_mutex);
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 25990bdac7..dbd10c6f76 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -29,7 +29,6 @@
#include "util/u_memory.h"
#include "util/u_simple_list.h"
-#include "tr_buffer.h"
#include "tr_dump.h"
#include "tr_dump_state.h"
#include "tr_texture.h"
@@ -213,72 +212,73 @@ trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
*/
-static struct pipe_texture *
-trace_screen_texture_create(struct pipe_screen *_screen,
- const struct pipe_texture *templat)
+static struct pipe_resource *
+trace_screen_resource_create(struct pipe_screen *_screen,
+ const struct pipe_resource *templat)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_texture *result;
+ struct pipe_resource *result;
- trace_dump_call_begin("pipe_screen", "texture_create");
+ trace_dump_call_begin("pipe_screen", "resource_create");
trace_dump_arg(ptr, screen);
trace_dump_arg(template, templat);
- result = screen->texture_create(screen, templat);
+ result = screen->resource_create(screen, templat);
trace_dump_ret(ptr, result);
trace_dump_call_end();
- result = trace_texture_create(tr_scr, result);
+ result = trace_resource_create(tr_scr, result);
return result;
}
-static struct pipe_texture *
-trace_screen_texture_from_handle(struct pipe_screen *_screen,
- const struct pipe_texture *templ,
+static struct pipe_resource *
+trace_screen_resource_from_handle(struct pipe_screen *_screen,
+ const struct pipe_resource *templ,
struct winsys_handle *handle)
{
struct trace_screen *tr_screen = trace_screen(_screen);
struct pipe_screen *screen = tr_screen->screen;
- struct pipe_texture *result;
+ struct pipe_resource *result;
/* TODO trace call */
- result = screen->texture_from_handle(screen, templ, handle);
+ result = screen->resource_from_handle(screen, templ, handle);
- result = trace_texture_create(trace_screen(_screen), result);
+ result = trace_resource_create(trace_screen(_screen), result);
return result;
}
static boolean
-trace_screen_texture_get_handle(struct pipe_screen *_screen,
- struct pipe_texture *_texture,
+trace_screen_resource_get_handle(struct pipe_screen *_screen,
+ struct pipe_resource *_texture,
struct winsys_handle *handle)
{
struct trace_screen *tr_screen = trace_screen(_screen);
- struct trace_texture *tr_texture = trace_texture(_texture);
+ struct trace_resource *tr_texture = trace_resource(_texture);
struct pipe_screen *screen = tr_screen->screen;
- struct pipe_texture *texture = tr_texture->texture;
+ struct pipe_resource *texture = tr_texture->resource;
/* TODO trace call */
- return screen->texture_get_handle(screen, texture, handle);
+ return screen->resource_get_handle(screen, texture, handle);
}
static void
-trace_screen_texture_destroy(struct pipe_texture *_texture)
+trace_screen_resource_destroy(struct pipe_screen *_screen,
+ struct pipe_resource *_texture)
{
- struct trace_screen *tr_scr = trace_screen(_texture->screen);
- struct trace_texture *tr_tex = trace_texture(_texture);
+ struct trace_screen *tr_scr = trace_screen(_screen);
+ struct trace_resource *tr_tex = trace_resource(_texture);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_texture *texture = tr_tex->texture;
+ struct pipe_resource *texture = tr_tex->resource;
assert(texture->screen == screen);
@@ -289,7 +289,7 @@ trace_screen_texture_destroy(struct pipe_texture *_texture)
trace_dump_call_end();
- trace_texture_destroy(tr_tex);
+ trace_resource_destroy(tr_scr, tr_tex);
}
@@ -300,15 +300,15 @@ trace_screen_texture_destroy(struct pipe_texture *_texture)
static struct pipe_surface *
trace_screen_get_tex_surface(struct pipe_screen *_screen,
- struct pipe_texture *_texture,
+ struct pipe_resource *_texture,
unsigned face, unsigned level,
unsigned zslice,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_texture *tr_tex = trace_texture(_texture);
+ struct trace_resource *tr_tex = trace_resource(_texture);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_texture *texture = tr_tex->texture;
+ struct pipe_resource *texture = tr_tex->resource;
struct pipe_surface *result = NULL;
assert(texture->screen == screen);
@@ -362,53 +362,15 @@ trace_screen_tex_surface_destroy(struct pipe_surface *_surface)
-
-
-static struct pipe_buffer *
-trace_screen_buffer_create(struct pipe_screen *_screen,
- unsigned alignment,
- unsigned usage,
- unsigned size)
-{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- struct pipe_buffer *result;
-
- trace_dump_call_begin("pipe_screen", "buffer_create");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(uint, alignment);
- trace_dump_arg(uint, usage);
- trace_dump_arg(uint, size);
-
- result = screen->buffer_create(screen, alignment, usage, size);
-
- trace_dump_ret(ptr, result);
-
- trace_dump_call_end();
-
- /* Zero the buffer to avoid dumping uninitialized memory */
- if(result->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
- void *map;
- map = pipe_buffer_map(screen, result, PIPE_BUFFER_USAGE_CPU_WRITE);
- if(map) {
- memset(map, 0, result->size);
- screen->buffer_unmap(screen, result);
- }
- }
-
- return trace_buffer_create(tr_scr, result);
-}
-
-
-static struct pipe_buffer *
+static struct pipe_resource *
trace_screen_user_buffer_create(struct pipe_screen *_screen,
void *data,
- unsigned size)
+ unsigned size,
+ unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_buffer *result;
+ struct pipe_resource *result;
trace_dump_call_begin("pipe_screen", "user_buffer_create");
@@ -417,189 +379,23 @@ trace_screen_user_buffer_create(struct pipe_screen *_screen,
trace_dump_bytes(data, size);
trace_dump_arg_end();
trace_dump_arg(uint, size);
+ trace_dump_arg(uint, usage);
- result = screen->user_buffer_create(screen, data, size);
+ result = screen->user_buffer_create(screen, data, size, usage);
trace_dump_ret(ptr, result);
trace_dump_call_end();
if(result) {
- assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
- result->usage |= TRACE_BUFFER_USAGE_USER;
- }
-
- return trace_buffer_create(tr_scr, result);
-}
-
-
-/**
- * This function is used to track if data has been changed on a user buffer
- * without map/unmap being called.
- */
-void
-trace_screen_user_buffer_update(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer)
-{
-#if 0
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- const void *map;
-
- if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
- map = screen->buffer_map(screen, buffer, PIPE_BUFFER_USAGE_CPU_READ);
- if(map) {
- trace_dump_call_begin("pipe_winsys", "buffer_write");
-
- trace_dump_arg(ptr, screen);
-
- trace_dump_arg(ptr, buffer);
-
- trace_dump_arg_begin("data");
- trace_dump_bytes(map, buffer->size);
- trace_dump_arg_end();
-
- trace_dump_arg_begin("size");
- trace_dump_uint(buffer->size);
- trace_dump_arg_end();
-
- trace_dump_call_end();
-
- screen->buffer_unmap(screen, buffer);
- }
- }
-#endif
-}
-
-
-static void *
-trace_screen_buffer_map(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer,
- unsigned usage)
-{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_buffer *tr_buf = trace_buffer(_buffer);
- struct pipe_screen *screen = tr_scr->screen;
- struct pipe_buffer *buffer = tr_buf->buffer;
- void *map;
-
- assert(screen->buffer_map);
- map = screen->buffer_map(screen, buffer, usage);
- if(map) {
- if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
- tr_buf->map = map;
- }
- }
-
- return map;
-}
-
-
-static void *
-trace_screen_buffer_map_range(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer,
- unsigned offset,
- unsigned length,
- unsigned usage)
-{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_buffer *tr_buf = trace_buffer(_buffer);
- struct pipe_screen *screen = tr_scr->screen;
- struct pipe_buffer *buffer = tr_buf->buffer;
- void *map;
-
- assert(screen->buffer_map_range);
- map = screen->buffer_map_range(screen, buffer, offset, length, usage);
- if(map) {
- if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
- tr_buf->map = map;
- }
+ assert(!(result->flags & TRACE_FLAG_USER_BUFFER));
+ result->flags |= TRACE_FLAG_USER_BUFFER;
}
- return map;
-}
-
-
-static void
-buffer_write(struct pipe_screen *screen,
- struct pipe_buffer *buffer,
- unsigned offset,
- const char *map,
- unsigned size)
-{
- assert(map);
-
- trace_dump_call_begin("pipe_screen", "buffer_write");
-
- trace_dump_arg(ptr, screen);
-
- trace_dump_arg(ptr, buffer);
-
- trace_dump_arg(uint, offset);
-
- trace_dump_arg_begin("data");
- trace_dump_bytes(map + offset, size);
- trace_dump_arg_end();
-
- trace_dump_arg(uint, size);
-
- trace_dump_call_end();
-
-}
-
-
-static void
-trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer,
- unsigned offset,
- unsigned length)
-{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_buffer *tr_buf = trace_buffer(_buffer);
- struct pipe_screen *screen = tr_scr->screen;
- struct pipe_buffer *buffer = tr_buf->buffer;
-
- assert(tr_buf->map);
- buffer_write(screen, buffer, offset, tr_buf->map, length);
- tr_buf->range_flushed = TRUE;
- screen->buffer_flush_mapped_range(screen, buffer, offset, length);
+ return trace_resource_create(tr_scr, result);
}
-static void
-trace_screen_buffer_unmap(struct pipe_screen *_screen,
- struct pipe_buffer *_buffer)
-{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_buffer *tr_buf = trace_buffer(_buffer);
- struct pipe_screen *screen = tr_scr->screen;
- struct pipe_buffer *buffer = tr_buf->buffer;
-
- if (tr_buf->map && !tr_buf->range_flushed)
- buffer_write(screen, buffer, 0, tr_buf->map, buffer->size);
- tr_buf->map = NULL;
- tr_buf->range_flushed = FALSE;
- screen->buffer_unmap(screen, buffer);
-}
-
-
-static void
-trace_screen_buffer_destroy(struct pipe_buffer *_buffer)
-{
- struct trace_screen *tr_scr = trace_screen(_buffer->screen);
- struct trace_buffer *tr_buf = trace_buffer(_buffer);
- struct pipe_screen *screen = tr_scr->screen;
- struct pipe_buffer *buffer = tr_buf->buffer;
-
- trace_dump_call_begin("pipe_screen", "buffer_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, buffer);
-
- trace_dump_call_end();
-
- trace_buffer_destroy(tr_scr, _buffer);
-}
/********************************************************************
@@ -769,23 +565,13 @@ trace_screen_create(struct pipe_screen *screen)
tr_scr->base.is_format_supported = trace_screen_is_format_supported;
assert(screen->context_create);
tr_scr->base.context_create = trace_screen_context_create;
- tr_scr->base.texture_create = trace_screen_texture_create;
- tr_scr->base.texture_from_handle = trace_screen_texture_from_handle;
- tr_scr->base.texture_get_handle = trace_screen_texture_get_handle;
- tr_scr->base.texture_destroy = trace_screen_texture_destroy;
+ tr_scr->base.resource_create = trace_screen_resource_create;
+ tr_scr->base.resource_from_handle = trace_screen_resource_from_handle;
+ tr_scr->base.resource_get_handle = trace_screen_resource_get_handle;
+ tr_scr->base.resource_destroy = trace_screen_resource_destroy;
tr_scr->base.get_tex_surface = trace_screen_get_tex_surface;
tr_scr->base.tex_surface_destroy = trace_screen_tex_surface_destroy;
- tr_scr->base.buffer_create = trace_screen_buffer_create;
tr_scr->base.user_buffer_create = trace_screen_user_buffer_create;
- if (screen->buffer_map)
- tr_scr->base.buffer_map = trace_screen_buffer_map;
- if (screen->buffer_map_range)
- tr_scr->base.buffer_map_range = trace_screen_buffer_map_range;
- if (screen->buffer_flush_mapped_range)
- tr_scr->base.buffer_flush_mapped_range = trace_screen_buffer_flush_mapped_range;
- if (screen->buffer_unmap)
- tr_scr->base.buffer_unmap = trace_screen_buffer_unmap;
- tr_scr->base.buffer_destroy = trace_screen_buffer_destroy;
tr_scr->base.fence_reference = trace_screen_fence_reference;
tr_scr->base.fence_signalled = trace_screen_fence_signalled;
tr_scr->base.fence_finish = trace_screen_fence_finish;
diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h
index 9bfbe72e2c..05ff9ef61f 100644
--- a/src/gallium/drivers/trace/tr_screen.h
+++ b/src/gallium/drivers/trace/tr_screen.h
@@ -48,7 +48,7 @@ struct tr_list {
* without mapping/unmapping. This flag marks user buffers, so that their
* contents can be dumpped before being used by the pipe context.
*/
-#define TRACE_BUFFER_USAGE_USER (1 << 31)
+#define TRACE_FLAG_USER_BUFFER (1 << 31)
struct trace_screen
@@ -100,10 +100,6 @@ trace_enabled(void);
struct trace_screen *
trace_screen(struct pipe_screen *screen);
-void
-trace_screen_user_buffer_update(struct pipe_screen *screen,
- struct pipe_buffer *buffer);
-
#define trace_screen_add_to_list(tr_scr, name, obj) \
do { \
pipe_mutex_lock(tr_scr->list_mutex); \
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index d818e21bb8..1132dc9272 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -35,51 +35,50 @@
#include "tr_texture.h"
-struct pipe_texture *
-trace_texture_create(struct trace_screen *tr_scr,
- struct pipe_texture *texture)
+struct pipe_resource *
+trace_resource_create(struct trace_screen *tr_scr,
+ struct pipe_resource *texture)
{
- struct trace_texture *tr_tex;
+ struct trace_resource *tr_tex;
if(!texture)
goto error;
assert(texture->screen == tr_scr->screen);
- tr_tex = CALLOC_STRUCT(trace_texture);
+ tr_tex = CALLOC_STRUCT(trace_resource);
if(!tr_tex)
goto error;
- memcpy(&tr_tex->base, texture, sizeof(struct pipe_texture));
+ memcpy(&tr_tex->base, texture, sizeof(struct pipe_resource));
pipe_reference_init(&tr_tex->base.reference, 1);
tr_tex->base.screen = &tr_scr->base;
- tr_tex->texture = texture;
+ tr_tex->resource = texture;
trace_screen_add_to_list(tr_scr, textures, tr_tex);
return &tr_tex->base;
error:
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
return NULL;
}
void
-trace_texture_destroy(struct trace_texture *tr_tex)
+trace_resource_destroy(struct trace_screen *tr_scr,
+ struct trace_resource *tr_tex)
{
- struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
-
trace_screen_remove_from_list(tr_scr, textures, tr_tex);
- pipe_texture_reference(&tr_tex->texture, NULL);
+ pipe_resource_reference(&tr_tex->resource, NULL);
FREE(tr_tex);
}
struct pipe_surface *
-trace_surface_create(struct trace_texture *tr_tex,
+trace_surface_create(struct trace_resource *tr_tex,
struct pipe_surface *surface)
{
struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
@@ -88,7 +87,7 @@ trace_surface_create(struct trace_texture *tr_tex,
if(!surface)
goto error;
- assert(surface->texture == tr_tex->texture);
+ assert(surface->texture == tr_tex->resource);
tr_surf = CALLOC_STRUCT(trace_surface);
if(!tr_surf)
@@ -98,7 +97,7 @@ trace_surface_create(struct trace_texture *tr_tex,
pipe_reference_init(&tr_surf->base.reference, 1);
tr_surf->base.texture = NULL;
- pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
+ pipe_resource_reference(&tr_surf->base.texture, &tr_tex->base);
tr_surf->surface = surface;
trace_screen_add_to_list(tr_scr, surfaces, tr_surf);
@@ -118,7 +117,7 @@ trace_surface_destroy(struct trace_surface *tr_surf)
trace_screen_remove_from_list(tr_scr, surfaces, tr_surf);
- pipe_texture_reference(&tr_surf->base.texture, NULL);
+ pipe_resource_reference(&tr_surf->base.texture, NULL);
pipe_surface_reference(&tr_surf->surface, NULL);
FREE(tr_surf);
}
@@ -126,7 +125,7 @@ trace_surface_destroy(struct trace_surface *tr_surf)
struct pipe_transfer *
trace_transfer_create(struct trace_context *tr_ctx,
- struct trace_texture *tr_tex,
+ struct trace_resource *tr_tex,
struct pipe_transfer *transfer)
{
struct trace_screen *tr_scr = trace_screen(tr_tex->base.screen);
@@ -135,7 +134,7 @@ trace_transfer_create(struct trace_context *tr_ctx,
if(!transfer)
goto error;
- assert(transfer->texture == tr_tex->texture);
+ assert(transfer->resource == tr_tex->resource);
tr_trans = CALLOC_STRUCT(trace_transfer);
if(!tr_trans)
@@ -143,18 +142,18 @@ trace_transfer_create(struct trace_context *tr_ctx,
memcpy(&tr_trans->base, transfer, sizeof(struct pipe_transfer));
- tr_trans->base.texture = NULL;
+ tr_trans->base.resource = NULL;
tr_trans->transfer = transfer;
- pipe_texture_reference(&tr_trans->base.texture, &tr_tex->base);
- assert(tr_trans->base.texture == &tr_tex->base);
+ pipe_resource_reference(&tr_trans->base.resource, &tr_tex->base);
+ assert(tr_trans->base.resource == &tr_tex->base);
trace_screen_add_to_list(tr_scr, transfers, tr_trans);
return &tr_trans->base;
error:
- tr_ctx->pipe->tex_transfer_destroy(tr_ctx->pipe, transfer);
+ tr_ctx->pipe->transfer_destroy(tr_ctx->pipe, transfer);
return NULL;
}
@@ -169,8 +168,8 @@ trace_transfer_destroy(struct trace_context *tr_context,
trace_screen_remove_from_list(tr_scr, transfers, tr_trans);
- pipe_texture_reference(&tr_trans->base.texture, NULL);
- context->tex_transfer_destroy(context, transfer);
+ pipe_resource_reference(&tr_trans->base.resource, NULL);
+ context->transfer_destroy(context, transfer);
FREE(tr_trans);
}
diff --git a/src/gallium/drivers/trace/tr_texture.h b/src/gallium/drivers/trace/tr_texture.h
index 66250465e4..6513995d50 100644
--- a/src/gallium/drivers/trace/tr_texture.h
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -36,11 +36,11 @@
struct trace_context;
-struct trace_texture
+struct trace_resource
{
- struct pipe_texture base;
+ struct pipe_resource base;
- struct pipe_texture *texture;
+ struct pipe_resource *resource;
struct tr_list list;
};
@@ -77,13 +77,13 @@ struct trace_transfer
};
-static INLINE struct trace_texture *
-trace_texture(struct pipe_texture *texture)
+static INLINE struct trace_resource *
+trace_resource(struct pipe_resource *texture)
{
if(!texture)
return NULL;
(void)trace_screen(texture->screen);
- return (struct trace_texture *)texture;
+ return (struct trace_resource *)texture;
}
@@ -92,7 +92,7 @@ trace_surface(struct pipe_surface *surface)
{
if(!surface)
return NULL;
- (void)trace_texture(surface->texture);
+ (void)trace_resource(surface->texture);
return (struct trace_surface *)surface;
}
@@ -111,20 +111,21 @@ trace_transfer(struct pipe_transfer *transfer)
{
if(!transfer)
return NULL;
- (void)trace_texture(transfer->texture);
+ (void)trace_resource(transfer->resource);
return (struct trace_transfer *)transfer;
}
-struct pipe_texture *
-trace_texture_create(struct trace_screen *tr_scr,
- struct pipe_texture *texture);
+struct pipe_resource *
+trace_resource_create(struct trace_screen *tr_scr,
+ struct pipe_resource *texture);
void
-trace_texture_destroy(struct trace_texture *tr_tex);
+trace_resource_destroy(struct trace_screen *tr_scr,
+ struct trace_resource *tr_tex);
struct pipe_surface *
-trace_surface_create(struct trace_texture *tr_tex,
+trace_surface_create(struct trace_resource *tr_tex,
struct pipe_surface *surface);
void
@@ -132,7 +133,7 @@ trace_surface_destroy(struct trace_surface *tr_surf);
struct pipe_transfer *
trace_transfer_create(struct trace_context *tr_ctx,
- struct trace_texture *tr_tex,
+ struct trace_resource *tr_tex,
struct pipe_transfer *transfer);
void
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 6aba6ef1ee..1aa0cbe4dc 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -65,7 +65,7 @@ struct pipe_context {
unsigned mode, unsigned start, unsigned count);
void (*draw_elements)( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count);
@@ -77,7 +77,7 @@ struct pipe_context {
unsigned instanceCount);
void (*draw_elements_instanced)(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode,
unsigned start,
@@ -91,7 +91,7 @@ struct pipe_context {
* module.
*/
void (*draw_range_elements)( struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
+ struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned minIndex,
unsigned maxIndex,
@@ -200,7 +200,7 @@ struct pipe_context {
void (*set_constant_buffer)( struct pipe_context *,
uint shader, uint index,
- struct pipe_buffer *buf );
+ struct pipe_resource *buf );
void (*set_framebuffer_state)( struct pipe_context *,
const struct pipe_framebuffer_state * );
@@ -291,27 +291,15 @@ struct pipe_context {
* \param level mipmap level.
* \return mask of PIPE_REFERENCED_FOR_READ/WRITE or PIPE_UNREFERENCED
*/
- unsigned int (*is_texture_referenced)(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level);
-
- /**
- * Check whether a buffer is referenced by an unflushed hw command.
- * The state-tracker uses this function to avoid unnecessary flushes.
- * It is safe (but wasteful) to always return
- * PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE.
- * \param pipe context whose unflushed hw commands will be checked.
- * \param buf buffer to check.
- * \return mask of PIPE_REFERENCED_FOR_READ/WRITE or PIPE_UNREFERENCED
- */
- unsigned int (*is_buffer_referenced)(struct pipe_context *pipe,
- struct pipe_buffer *buf);
+ unsigned int (*is_resource_referenced)(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ unsigned face, unsigned level);
/**
* Create a view on a texture to be used by a shader stage.
*/
struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
const struct pipe_sampler_view *templat);
void (*sampler_view_destroy)(struct pipe_context *ctx,
@@ -324,24 +312,42 @@ struct pipe_context {
* Transfers are (by default) context-private and allow uploads to be
* interleaved with
*/
- struct pipe_transfer *(*get_tex_transfer)(struct pipe_context *,
- struct pipe_texture *texture,
- unsigned face, unsigned level,
- unsigned zslice,
- enum pipe_transfer_usage usage,
- unsigned x, unsigned y,
- unsigned w, unsigned h);
-
- void (*tex_transfer_destroy)(struct pipe_context *,
+ struct pipe_transfer *(*get_transfer)(struct pipe_context *,
+ struct pipe_resource *resource,
+ struct pipe_subresource,
+ unsigned usage, /* a combination of PIPE_TRANSFER_x */
+ const struct pipe_box *);
+
+ void (*transfer_destroy)(struct pipe_context *,
struct pipe_transfer *);
void *(*transfer_map)( struct pipe_context *,
struct pipe_transfer *transfer );
+ /* If transfer was created with WRITE|FLUSH_EXPLICIT, only the
+ * regions specified with this call are guaranteed to be written to
+ * the resource.
+ */
+ void (*transfer_flush_region)( struct pipe_context *,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *);
+
void (*transfer_unmap)( struct pipe_context *,
struct pipe_transfer *transfer );
+ /* One-shot transfer operation with data supplied in a user
+ * pointer. XXX: strides??
+ */
+ void (*transfer_inline_write)( struct pipe_context *,
+ struct pipe_resource *,
+ struct pipe_subresource,
+ unsigned usage, /* a combination of PIPE_TRANSFER_x */
+ const struct pipe_box *,
+ const void *data,
+ unsigned stride,
+ unsigned slice_stride);
+
};
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index c1e291b9da..0a4bd584ae 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -137,10 +137,11 @@ enum pipe_error {
/** Texture types */
enum pipe_texture_target {
- PIPE_TEXTURE_1D = 0,
- PIPE_TEXTURE_2D = 1,
- PIPE_TEXTURE_3D = 2,
- PIPE_TEXTURE_CUBE = 3,
+ PIPE_BUFFER = 0,
+ PIPE_TEXTURE_1D = 1,
+ PIPE_TEXTURE_2D = 2,
+ PIPE_TEXTURE_3D = 3,
+ PIPE_TEXTURE_CUBE = 4,
PIPE_MAX_TEXTURE_TYPES
};
@@ -175,22 +176,10 @@ enum pipe_texture_target {
#define PIPE_TEX_COMPARE_NONE 0
#define PIPE_TEX_COMPARE_R_TO_TEXTURE 1
-#define PIPE_TEXTURE_USAGE_RENDER_TARGET 0x1
-#define PIPE_TEXTURE_USAGE_DISPLAY_TARGET 0x2 /* windows presentable buffer, ie a backbuffer */
-#define PIPE_TEXTURE_USAGE_SCANOUT 0x4 /* ie a frontbuffer */
-#define PIPE_TEXTURE_USAGE_DEPTH_STENCIL 0x8
-#define PIPE_TEXTURE_USAGE_SAMPLER 0x10
-#define PIPE_TEXTURE_USAGE_DYNAMIC 0x20
-#define PIPE_TEXTURE_USAGE_SHARED 0x40
-/** Pipe driver custom usage flags should be greater or equal to this value */
-#define PIPE_TEXTURE_USAGE_CUSTOM (1 << 16)
-
-#define PIPE_TEXTURE_GEOM_NON_SQUARE 0x1
-#define PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO 0x2
-
/**
- * Surface layout
+ * Surface layout -- a hint? Or some driver-internal poking out into
+ * the interface?
*/
#define PIPE_SURFACE_LAYOUT_LINEAR 0
@@ -208,10 +197,23 @@ enum pipe_texture_target {
* Transfer object usage flags
*/
enum pipe_transfer_usage {
+ /**
+ * Resource contents read back (or accessed directly) at transfer
+ * create time.
+ */
PIPE_TRANSFER_READ = (1 << 0),
+
+ /**
+ * Resource contents will be written back at transfer_destroy
+ * time (or modified as a result of being accessed directly).
+ */
PIPE_TRANSFER_WRITE = (1 << 1),
- /** Read/modify/write */
+
+ /**
+ * Read/modify/write
+ */
PIPE_TRANSFER_READ_WRITE = PIPE_TRANSFER_READ | PIPE_TRANSFER_WRITE,
+
/**
* The transfer should map the texture storage directly. The driver may
* return NULL if that isn't possible, and the state tracker needs to cope
@@ -221,89 +223,116 @@ enum pipe_transfer_usage {
* does read/modify/write cycles on them directly, and a more complicated
* path which uses minimal read and write transfers.
*/
- PIPE_TRANSFER_MAP_DIRECTLY = (1 << 2)
-};
+ PIPE_TRANSFER_MAP_DIRECTLY = (1 << 2),
+
+ /**
+ * Discards the memory within the mapped region.
+ *
+ * It should not be used with PIPE_TRANSFER_CPU_READ.
+ *
+ * See also:
+ * - OpenGL's ARB_map_buffer_range extension, MAP_INVALIDATE_RANGE_BIT flag.
+ * - Direct3D's D3DLOCK_DISCARD flag.
+ */
+ PIPE_TRANSFER_DISCARD = (1 << 8),
+ /**
+ * Fail if the resource cannot be mapped immediately.
+ *
+ * See also:
+ * - Direct3D's D3DLOCK_DONOTWAIT flag.
+ * - Mesa3D's MESA_MAP_NOWAIT_BIT flag.
+ * - WDDM's D3DDDICB_LOCKFLAGS.DonotWait flag.
+ */
+ PIPE_TRANSFER_DONTBLOCK = (1 << 9),
-/*
- * Buffer usage flags
- */
+ /**
+ * Do not attempt to synchronize pending operations on the resource when mapping.
+ *
+ * It should not be used with PIPE_TRANSFER_CPU_READ.
+ *
+ * See also:
+ * - OpenGL's ARB_map_buffer_range extension, MAP_UNSYNCHRONIZED_BIT flag.
+ * - Direct3D's D3DLOCK_NOOVERWRITE flag.
+ * - WDDM's D3DDDICB_LOCKFLAGS.IgnoreSync flag.
+ */
+ PIPE_TRANSFER_UNSYNCHRONIZED = (1 << 10),
+ PIPE_TRANSFER_NOOVERWRITE = (1 << 10), /* are these really the same?? */
+
+ /**
+ * Written ranges will be notified later with
+ * pipe_context::transfer_flush_region.
+ *
+ * It should not be used with PIPE_TRANSFER_CPU_READ.
+ *
+ * See also:
+ * - pipe_context::transfer_flush_region
+ * - OpenGL's ARB_map_buffer_range extension, MAP_FLUSH_EXPLICIT_BIT flag.
+ */
+ PIPE_TRANSFER_FLUSH_EXPLICIT = (1 << 11),
+
+};
-#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0)
-#define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1)
-#define PIPE_BUFFER_USAGE_GPU_READ (1 << 2)
-#define PIPE_BUFFER_USAGE_GPU_WRITE (1 << 3)
-#define PIPE_BUFFER_USAGE_PIXEL (1 << 4)
-#define PIPE_BUFFER_USAGE_VERTEX (1 << 5)
-#define PIPE_BUFFER_USAGE_INDEX (1 << 6)
-#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7)
/*
- * CPU access flags.
- *
- * These flags should only be used for texture transfers or when mapping
- * buffers.
- *
- * Note that the PIPE_BUFFER_USAGE_CPU_xxx flags above are also used for
- * mapping. Either PIPE_BUFFER_USAGE_CPU_READ or PIPE_BUFFER_USAGE_CPU_WRITE
- * must be set.
+ * Resource binding flags -- state tracker must specify in advance all
+ * the ways a resource might be used.
*/
-
-/**
- * Discards the memory within the mapped region.
+#define PIPE_BIND_DEPTH_STENCIL (1 << 0) /* get_tex_surface */
+#define PIPE_BIND_RENDER_TARGET (1 << 1) /* get_tex_surface */
+#define PIPE_BIND_SAMPLER_VIEW (1 << 2) /* get_sampler_view */
+#define PIPE_BIND_VERTEX_BUFFER (1 << 3) /* set_vertex_buffers */
+#define PIPE_BIND_INDEX_BUFFER (1 << 4) /* draw_elements */
+#define PIPE_BIND_CONSTANT_BUFFER (1 << 5) /* set_constant_buffer */
+#define PIPE_BIND_BLIT_SOURCE (1 << 6) /* surface_copy */
+#define PIPE_BIND_BLIT_DESTINATION (1 << 7) /* surface_copy, fill */
+#define PIPE_BIND_DISPLAY_TARGET (1 << 8) /* flush_front_buffer */
+#define PIPE_BIND_TRANSFER_WRITE (1 << 9) /* get_transfer */
+#define PIPE_BIND_TRANSFER_READ (1 << 10) /* get_transfer */
+#define PIPE_BIND_CUSTOM (1 << 16) /* state-tracker/winsys usages */
+
+/* The first two flags were previously part of the amorphous
+ * TEXTURE_USAGE, most of which are now descriptions of the ways a
+ * particular texture can be bound to the gallium pipeline. These two
+ * do not fit within that and probably need to be migrated to some
+ * other place.
*
- * It should not be used with PIPE_BUFFER_USAGE_CPU_READ.
+ * It seems like scanout is used by the Xorg state tracker to ask for
+ * a texture suitable for actual scanout (hence the name), which
+ * implies extra layout constraints on some hardware. It may also
+ * have some special meaning regarding mouse cursor images.
*
- * See also:
- * - OpenGL's ARB_map_buffer_range extension, MAP_INVALIDATE_RANGE_BIT flag.
- * - Direct3D's D3DLOCK_DISCARD flag.
+ * The shared flag is quite underspecified, but certainly isn't a
+ * binding flag - it seems more like a message to the winsys to create
+ * a shareable allocation. Could it mean that this texture is a valid argument for
*/
-#define PIPE_BUFFER_USAGE_DISCARD (1 << 8)
+#define PIPE_BIND_SCANOUT (1 << 14) /* */
+#define PIPE_BIND_SHARED (1 << 15) /* get_texture_handle ??? */
-/**
- * Fail if the resource cannot be mapped immediately.
- *
- * See also:
- * - Direct3D's D3DLOCK_DONOTWAIT flag.
- * - Mesa3D's MESA_MAP_NOWAIT_BIT flag.
- * - WDDM's D3DDDICB_LOCKFLAGS.DonotWait flag.
- */
-#define PIPE_BUFFER_USAGE_DONTBLOCK (1 << 9)
-/**
- * Do not attempt to synchronize pending operations on the resource when mapping.
- *
- * It should not be used with PIPE_BUFFER_USAGE_CPU_READ.
- *
- * See also:
- * - OpenGL's ARB_map_buffer_range extension, MAP_UNSYNCHRONIZED_BIT flag.
- * - Direct3D's D3DLOCK_NOOVERWRITE flag.
- * - WDDM's D3DDDICB_LOCKFLAGS.IgnoreSync flag.
+/* Flags for the driver about resource behaviour:
*/
-#define PIPE_BUFFER_USAGE_UNSYNCHRONIZED (1 << 10)
+#define PIPE_RESOURCE_FLAG_GEN_MIPS (1 << 0) /* Driver performs autogen mips */
+#define PIPE_RESOURCE_FLAG_DRV_PRIV (1 << 16) /* driver/winsys private */
+#define PIPE_RESOURCE_FLAG_ST_PRIV (1 << 24) /* state-tracker/winsys private */
-/**
- * Written ranges will be notified later with
- * pipe_screen::buffer_flush_mapped_range.
- *
- * It should not be used with PIPE_BUFFER_USAGE_CPU_READ.
- *
- * See also:
- * - pipe_screen::buffer_flush_mapped_range
- * - OpenGL's ARB_map_buffer_range extension, MAP_FLUSH_EXPLICIT_BIT flag.
+/* Hint about the expected lifecycle of a resource.
*/
-#define PIPE_BUFFER_USAGE_FLUSH_EXPLICIT (1 << 11)
+#define PIPE_USAGE_DEFAULT 0 /* many uploads, draws intermixed */
+#define PIPE_USAGE_DYNAMIC 1 /* many uploads, draws intermixed */
+#define PIPE_USAGE_STATIC 2 /* same as immutable?? */
+#define PIPE_USAGE_IMMUTABLE 3 /* no change after first upload */
+#define PIPE_USAGE_STREAM 4 /* upload, draw, upload, draw */
-/** Pipe driver custom usage flags should be greater or equal to this value */
-#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
-/* Convenient shortcuts */
-#define PIPE_BUFFER_USAGE_CPU_READ_WRITE \
- ( PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE )
-#define PIPE_BUFFER_USAGE_GPU_READ_WRITE \
- ( PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE )
-#define PIPE_BUFFER_USAGE_WRITE \
- ( PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_GPU_WRITE )
+/* These are intended to be used in calls to is_format_supported, but
+ * no driver actually uses these flags, and only the glx/xlib state
+ * tracker issues them.
+ *
+ * Deprecate?
+ */
+#define PIPE_TEXTURE_GEOM_NON_SQUARE 0x1
+#define PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO 0x2
/**
@@ -435,30 +464,6 @@ enum pipe_transfer_usage {
#define PIPE_REFERENCED_FOR_WRITE (1 << 1)
-enum pipe_video_codec
-{
- PIPE_VIDEO_CODEC_UNKNOWN = 0,
- PIPE_VIDEO_CODEC_MPEG12, /**< MPEG1, MPEG2 */
- PIPE_VIDEO_CODEC_MPEG4, /**< DIVX, XVID */
- PIPE_VIDEO_CODEC_VC1, /**< WMV */
- PIPE_VIDEO_CODEC_MPEG4_AVC /**< H.264 */
-};
-
-enum pipe_video_profile
-{
- PIPE_VIDEO_PROFILE_MPEG1,
- PIPE_VIDEO_PROFILE_MPEG2_SIMPLE,
- PIPE_VIDEO_PROFILE_MPEG2_MAIN,
- PIPE_VIDEO_PROFILE_MPEG4_SIMPLE,
- PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE,
- PIPE_VIDEO_PROFILE_VC1_SIMPLE,
- PIPE_VIDEO_PROFILE_VC1_MAIN,
- PIPE_VIDEO_PROFILE_VC1_ADVANCED,
- PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE,
- PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN,
- PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH
-};
-
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index d588928982..436c3f627a 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -192,24 +192,6 @@ enum pipe_format {
};
-enum pipe_video_chroma_format
-{
- PIPE_VIDEO_CHROMA_FORMAT_420,
- PIPE_VIDEO_CHROMA_FORMAT_422,
- PIPE_VIDEO_CHROMA_FORMAT_444
-};
-
-#if 0
-enum pipe_video_surface_format
-{
- PIPE_VIDEO_SURFACE_FORMAT_NV12, /**< Planar; Y plane, UV plane */
- PIPE_VIDEO_SURFACE_FORMAT_YV12, /**< Planar; Y plane, U plane, V plane */
- PIPE_VIDEO_SURFACE_FORMAT_YUYV, /**< Interleaved; Y,U,Y,V,Y,U,Y,V */
- PIPE_VIDEO_SURFACE_FORMAT_UYVY, /**< Interleaved; U,Y,V,Y,U,Y,V,Y */
- PIPE_VIDEO_SURFACE_FORMAT_VUYA /**< Packed; A31-24|Y23-16|U15-8|V7-0 */
-};
-#endif
-
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index b7cb83abbe..dd7c35e12c 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -54,10 +54,9 @@ struct winsys_handle;
/** Opaque type */
struct pipe_fence_handle;
struct pipe_winsys;
-struct pipe_buffer;
struct pipe_texture;
+struct pipe_resource;
struct pipe_surface;
-struct pipe_video_surface;
struct pipe_transfer;
@@ -94,7 +93,7 @@ struct pipe_screen {
/**
* Check if the given pipe_format is supported as a texture or
* drawing surface.
- * \param tex_usage bitmask of PIPE_TEXTURE_USAGE_*
+ * \param tex_usage bitmask of PIPE_BIND_*
* \param geom_flags bitmask of PIPE_TEXTURE_GEOM_*
*/
boolean (*is_format_supported)( struct pipe_screen *,
@@ -106,35 +105,36 @@ struct pipe_screen {
/**
* Create a new texture object, using the given template info.
*/
- struct pipe_texture * (*texture_create)(struct pipe_screen *,
- const struct pipe_texture *templat);
+ struct pipe_resource * (*resource_create)(struct pipe_screen *,
+ const struct pipe_resource *templat);
/**
* Create a texture from a winsys_handle. The handle is often created in
* another process by first creating a pipe texture and then calling
* texture_get_handle.
*/
- struct pipe_texture * (*texture_from_handle)(struct pipe_screen *,
- const struct pipe_texture *templat,
- struct winsys_handle *handle);
+ struct pipe_resource * (*resource_from_handle)(struct pipe_screen *,
+ const struct pipe_resource *templat,
+ struct winsys_handle *handle);
/**
* Get a winsys_handle from a texture. Some platforms/winsys requires
* that the texture is created with a special usage flag like
* DISPLAYTARGET or PRIMARY.
*/
- boolean (*texture_get_handle)(struct pipe_screen *,
- struct pipe_texture *tex,
- struct winsys_handle *handle);
+ boolean (*resource_get_handle)(struct pipe_screen *,
+ struct pipe_resource *tex,
+ struct winsys_handle *handle);
- void (*texture_destroy)(struct pipe_texture *pt);
+ void (*resource_destroy)(struct pipe_screen *,
+ struct pipe_resource *pt);
/** Get a 2D surface which is a "view" into a texture
- * \param usage bitmaks of PIPE_BUFFER_USAGE_* read/write flags
+ * \param usage bitmaks of PIPE_BIND_* flags
*/
struct pipe_surface *(*get_tex_surface)(struct pipe_screen *,
- struct pipe_texture *texture,
+ struct pipe_resource *resource,
unsigned face, unsigned level,
unsigned zslice,
unsigned usage );
@@ -144,17 +144,6 @@ struct pipe_screen {
/**
- * Create a new buffer.
- * \param alignment buffer start address alignment in bytes
- * \param usage bitmask of PIPE_BUFFER_USAGE_x
- * \param size size in bytes
- */
- struct pipe_buffer *(*buffer_create)( struct pipe_screen *screen,
- unsigned alignment,
- unsigned usage,
- unsigned size );
-
- /**
* Create a buffer that wraps user-space data.
*
* Effectively this schedules a delayed call to buffer_create
@@ -175,76 +164,10 @@ struct pipe_screen {
* Note that ptr may be accessed at any time upto the time when the
* buffer is destroyed, so the data must not be freed before then.
*/
- struct pipe_buffer *(*user_buffer_create)(struct pipe_screen *screen,
- void *ptr,
- unsigned bytes);
-
-
-
- /**
- * Map the entire data store of a buffer object into the client's address.
- * flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
- */
- void *(*buffer_map)( struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned usage );
- /**
- * Map a subrange of the buffer data store into the client's address space.
- *
- * The returned pointer is always relative to buffer start, regardless of
- * the specified range. This is different from the ARB_map_buffer_range
- * semantics because we don't forbid multiple mappings of the same buffer
- * (yet).
- */
- void *(*buffer_map_range)( struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset,
- unsigned length,
- unsigned usage);
-
- /**
- * Notify a range that was actually written into.
- *
- * Can only be used if the buffer was mapped with the
- * PIPE_BUFFER_USAGE_CPU_WRITE and PIPE_BUFFER_USAGE_FLUSH_EXPLICIT flags
- * set.
- *
- * The range is relative to the buffer start, regardless of the range
- * specified to buffer_map_range. This is different from the
- * ARB_map_buffer_range semantics because we don't forbid multiple mappings
- * of the same buffer (yet).
- *
- */
- void (*buffer_flush_mapped_range)( struct pipe_screen *screen,
- struct pipe_buffer *buf,
- unsigned offset,
- unsigned length);
-
- /**
- * Unmap buffer.
- *
- * If the buffer was mapped with PIPE_BUFFER_USAGE_CPU_WRITE flag but not
- * PIPE_BUFFER_USAGE_FLUSH_EXPLICIT then the pipe driver will
- * assume that the whole buffer was written. This is mostly for backward
- * compatibility purposes and may affect performance -- the state tracker
- * should always specify exactly what got written while the buffer was
- * mapped.
- */
- void (*buffer_unmap)( struct pipe_screen *screen,
- struct pipe_buffer *buf );
-
- void (*buffer_destroy)( struct pipe_buffer *buf );
-
- /**
- * Create a video surface suitable for use as a decoding target by the
- * driver's pipe_video_context.
- */
- struct pipe_video_surface*
- (*video_surface_create)( struct pipe_screen *screen,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height );
-
- void (*video_surface_destroy)( struct pipe_video_surface *vsfc );
+ struct pipe_resource *(*user_buffer_create)(struct pipe_screen *screen,
+ void *ptr,
+ unsigned bytes,
+ unsigned bind_flags);
/**
* Do any special operations to ensure buffer size is correct
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 11072407d9..d281d69ff2 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -71,19 +71,6 @@ struct pipe_reference
};
-/**
- * The driver will certainly subclass this to include actual memory
- * management information.
- */
-struct pipe_buffer
-{
- struct pipe_reference reference;
- unsigned size;
- struct pipe_screen *screen;
- unsigned alignment;
- unsigned usage;
-};
-
/**
* Primitive (point/line/tri) rasterization info
@@ -285,20 +272,25 @@ struct pipe_sampler_state
struct pipe_surface
{
struct pipe_reference reference;
+ struct pipe_resource *texture; /**< resource into which this is a view */
enum pipe_format format;
+
unsigned width; /**< logical width in pixels */
unsigned height; /**< logical height in pixels */
+
unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */
unsigned offset; /**< offset from start of buffer, in bytes */
- unsigned usage; /**< bitmask of PIPE_BUFFER_USAGE_x */
+ unsigned usage; /**< bitmask of PIPE_BIND_x */
unsigned zslice;
- struct pipe_texture *texture; /**< texture into which this is a view */
unsigned face;
unsigned level;
};
+
+
+
/**
* A view into a texture that can be bound to a shader stage.
*/
@@ -306,7 +298,7 @@ struct pipe_sampler_view
{
struct pipe_reference reference;
enum pipe_format format; /**< typed PIPE_FORMAT_x */
- struct pipe_texture *texture; /**< texture into which this is a view */
+ struct pipe_resource *texture; /**< texture into which this is a view */
struct pipe_context *context; /**< context this view belongs to */
unsigned first_level:8; /**< first mipmap level */
unsigned last_level:8; /**< last mipmap level */
@@ -317,32 +309,22 @@ struct pipe_sampler_view
};
-/**
- * Transfer object. For data transfer to/from a texture.
- */
-struct pipe_transfer
+struct pipe_box
{
- unsigned x; /**< x offset from start of texture image */
- unsigned y; /**< y offset from start of texture image */
- unsigned width; /**< logical width in pixels */
- unsigned height; /**< logical height in pixels */
- unsigned stride; /**< stride in bytes between rows of blocks */
- enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_* */
-
- struct pipe_texture *texture; /**< texture to transfer to/from */
- unsigned face;
- unsigned level;
- unsigned zslice;
+ unsigned x;
+ unsigned y;
+ unsigned z;
+ unsigned width;
+ unsigned height;
+ unsigned depth;
};
-/**
- * Texture object.
- */
-struct pipe_texture
-{
- struct pipe_reference reference;
+struct pipe_resource
+{
+ struct pipe_reference reference;
+ struct pipe_screen *screen; /**< screen that this texture belongs to */
enum pipe_texture_target target; /**< PIPE_TEXTURE_x */
enum pipe_format format; /**< PIPE_FORMAT_x */
@@ -351,15 +333,37 @@ struct pipe_texture
unsigned depth0;
unsigned last_level:8; /**< Index of last mipmap level present/defined */
-
unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */
+ unsigned _usage:8; /* PIPE_USAGE_x (not a bitmask) */
- unsigned tex_usage; /**< bitmask of PIPE_TEXTURE_USAGE_* */
+ unsigned bind; /* PIPE_BIND_x */
+ unsigned flags; /* PIPE_RESOURCE_FLAG_x */
+};
- struct pipe_screen *screen; /**< screen that this texture belongs to */
+
+struct pipe_subresource
+{
+ unsigned face:16;
+ unsigned level:16;
+};
+
+
+/**
+ * Transfer object. For data transfer to/from a texture.
+ */
+struct pipe_transfer
+{
+ struct pipe_resource *resource; /**< resource to transfer to/from */
+ struct pipe_subresource sr;
+ enum pipe_transfer_usage usage;
+ struct pipe_box box;
+ unsigned stride;
+ unsigned slice_stride;
+ void *data;
};
+
/**
* A vertex buffer. Typically, all the vertex data/attributes for
* drawing something will be in one buffer. But it's also possible, for
@@ -370,7 +374,7 @@ struct pipe_vertex_buffer
unsigned stride; /**< stride to same attrib in next vertex, in bytes */
unsigned max_index; /**< number of vertices in this buffer */
unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */
- struct pipe_buffer *buffer; /**< the actual buffer */
+ struct pipe_resource *buffer; /**< the actual buffer */
};
diff --git a/src/gallium/include/pipe/p_video_context.h b/src/gallium/include/pipe/p_video_context.h
deleted file mode 100644
index 6ae31418fa..0000000000
--- a/src/gallium/include/pipe/p_video_context.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef PIPE_VIDEO_CONTEXT_H
-#define PIPE_VIDEO_CONTEXT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <pipe/p_video_state.h>
-
-struct pipe_screen;
-struct pipe_buffer;
-struct pipe_surface;
-struct pipe_video_surface;
-struct pipe_macroblock;
-struct pipe_picture_desc;
-struct pipe_fence_handle;
-
-/**
- * Gallium video rendering context
- */
-struct pipe_video_context
-{
- struct pipe_screen *screen;
- enum pipe_video_profile profile;
- enum pipe_video_chroma_format chroma_format;
- unsigned width;
- unsigned height;
-
- void *priv; /**< context private data (for DRI for example) */
-
- void (*destroy)(struct pipe_video_context *vpipe);
-
- /**
- * Picture decoding and displaying
- */
- /*@{*/
- void (*decode_bitstream)(struct pipe_video_context *vpipe,
- unsigned num_bufs,
- struct pipe_buffer **bitstream_buf);
-
- void (*decode_macroblocks)(struct pipe_video_context *vpipe,
- struct pipe_video_surface *past,
- struct pipe_video_surface *future,
- unsigned num_macroblocks,
- struct pipe_macroblock *macroblocks,
- struct pipe_fence_handle **fence);
-
- void (*clear_surface)(struct pipe_video_context *vpipe,
- unsigned x, unsigned y,
- unsigned width, unsigned height,
- unsigned value,
- struct pipe_surface *surface);
-
- void (*render_picture)(struct pipe_video_context *vpipe,
- /*struct pipe_surface *backround,
- struct pipe_video_rect *backround_area,*/
- struct pipe_video_surface *src_surface,
- enum pipe_mpeg12_picture_type picture_type,
- /*unsigned num_past_surfaces,
- struct pipe_video_surface *past_surfaces,
- unsigned num_future_surfaces,
- struct pipe_video_surface *future_surfaces,*/
- struct pipe_video_rect *src_area,
- struct pipe_surface *dst_surface,
- struct pipe_video_rect *dst_area,
- /*unsigned num_layers,
- struct pipe_texture *layers,
- struct pipe_video_rect *layer_src_areas,
- struct pipe_video_rect *layer_dst_areas,*/
- struct pipe_fence_handle **fence);
- /*@}*/
-
- /**
- * Parameter-like states (or properties)
- */
- /*@{*/
- void (*set_picture_desc)(struct pipe_video_context *vpipe,
- const struct pipe_picture_desc *desc);
-
- void (*set_decode_target)(struct pipe_video_context *vpipe,
- struct pipe_video_surface *dt);
-
- void (*set_csc_matrix)(struct pipe_video_context *vpipe, const float *mat);
-
- /* TODO: Interface for scaling modes, post-processing, etc. */
- /*@}*/
-};
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PIPE_VIDEO_CONTEXT_H */
diff --git a/src/gallium/include/pipe/p_video_state.h b/src/gallium/include/pipe/p_video_state.h
deleted file mode 100644
index 77e22d0a56..0000000000
--- a/src/gallium/include/pipe/p_video_state.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef PIPE_VIDEO_STATE_H
-#define PIPE_VIDEO_STATE_H
-
-/* u_reduce_video_profile() needs these */
-#include <pipe/p_compiler.h>
-
-#include <pipe/p_defines.h>
-#include <pipe/p_format.h>
-#include <pipe/p_state.h>
-#include <pipe/p_screen.h>
-#include <util/u_inlines.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct pipe_video_surface
-{
- struct pipe_reference reference;
- struct pipe_screen *screen;
- enum pipe_video_chroma_format chroma_format;
- /*enum pipe_video_surface_format surface_format;*/
- unsigned width;
- unsigned height;
-};
-
-static INLINE void
-pipe_video_surface_reference(struct pipe_video_surface **ptr, struct pipe_video_surface *surf)
-{
- struct pipe_video_surface *old_surf = *ptr;
-
- if (pipe_reference(&(*ptr)->reference, &surf->reference))
- old_surf->screen->video_surface_destroy(old_surf);
- *ptr = surf;
-}
-
-struct pipe_video_rect
-{
- unsigned x, y, w, h;
-};
-
-static INLINE enum pipe_video_codec
-u_reduce_video_profile(enum pipe_video_profile profile)
-{
- switch (profile)
- {
- case PIPE_VIDEO_PROFILE_MPEG1:
- case PIPE_VIDEO_PROFILE_MPEG2_SIMPLE:
- case PIPE_VIDEO_PROFILE_MPEG2_MAIN:
- return PIPE_VIDEO_CODEC_MPEG12;
-
- case PIPE_VIDEO_PROFILE_MPEG4_SIMPLE:
- case PIPE_VIDEO_PROFILE_MPEG4_ADVANCED_SIMPLE:
- return PIPE_VIDEO_CODEC_MPEG4;
-
- case PIPE_VIDEO_PROFILE_VC1_SIMPLE:
- case PIPE_VIDEO_PROFILE_VC1_MAIN:
- case PIPE_VIDEO_PROFILE_VC1_ADVANCED:
- return PIPE_VIDEO_CODEC_VC1;
-
- case PIPE_VIDEO_PROFILE_MPEG4_AVC_BASELINE:
- case PIPE_VIDEO_PROFILE_MPEG4_AVC_MAIN:
- case PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH:
- return PIPE_VIDEO_CODEC_MPEG4_AVC;
-
- default:
- assert(0);
- return PIPE_VIDEO_CODEC_UNKNOWN;
- }
-}
-
-enum pipe_mpeg12_picture_type
-{
- PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP,
- PIPE_MPEG12_PICTURE_TYPE_FIELD_BOTTOM,
- PIPE_MPEG12_PICTURE_TYPE_FRAME
-};
-
-enum pipe_mpeg12_macroblock_type
-{
- PIPE_MPEG12_MACROBLOCK_TYPE_INTRA,
- PIPE_MPEG12_MACROBLOCK_TYPE_FWD,
- PIPE_MPEG12_MACROBLOCK_TYPE_BKWD,
- PIPE_MPEG12_MACROBLOCK_TYPE_BI,
-
- PIPE_MPEG12_MACROBLOCK_NUM_TYPES
-};
-
-enum pipe_mpeg12_motion_type
-{
- PIPE_MPEG12_MOTION_TYPE_FIELD,
- PIPE_MPEG12_MOTION_TYPE_FRAME,
- PIPE_MPEG12_MOTION_TYPE_DUALPRIME,
- PIPE_MPEG12_MOTION_TYPE_16x8
-};
-
-enum pipe_mpeg12_dct_type
-{
- PIPE_MPEG12_DCT_TYPE_FIELD,
- PIPE_MPEG12_DCT_TYPE_FRAME
-};
-
-struct pipe_macroblock
-{
- enum pipe_video_codec codec;
-};
-
-struct pipe_mpeg12_macroblock
-{
- struct pipe_macroblock base;
-
- unsigned mbx;
- unsigned mby;
- enum pipe_mpeg12_macroblock_type mb_type;
- enum pipe_mpeg12_motion_type mo_type;
- enum pipe_mpeg12_dct_type dct_type;
- signed pmv[2][2][2];
- unsigned cbp;
- void *blocks;
-};
-
-#if 0
-struct pipe_picture_desc
-{
- enum pipe_video_format format;
-};
-
-struct pipe_mpeg12_picture_desc
-{
- struct pipe_picture_desc base;
-
- /* TODO: Use bitfields where possible? */
- struct pipe_surface *forward_reference;
- struct pipe_surface *backward_reference;
- unsigned picture_coding_type;
- unsigned fcode;
- unsigned intra_dc_precision;
- unsigned picture_structure;
- unsigned top_field_first;
- unsigned frame_pred_frame_dct;
- unsigned concealment_motion_vectors;
- unsigned q_scale_type;
- unsigned intra_vlc_format;
- unsigned alternate_scan;
- unsigned full_pel_forward_vector;
- unsigned full_pel_backward_vector;
- struct pipe_buffer *intra_quantizer_matrix;
- struct pipe_buffer *non_intra_quantizer_matrix;
- struct pipe_buffer *chroma_intra_quantizer_matrix;
- struct pipe_buffer *chroma_non_intra_quantizer_matrix;
-};
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PIPE_VIDEO_STATE_H */
diff --git a/src/gallium/include/state_tracker/dri1_api.h b/src/gallium/include/state_tracker/dri1_api.h
index bb1cd6d1d8..a48c5de5a0 100644
--- a/src/gallium/include/state_tracker/dri1_api.h
+++ b/src/gallium/include/state_tracker/dri1_api.h
@@ -11,7 +11,7 @@ struct pipe_screen;
struct pipe_winsys;
struct pipe_buffer;
struct pipe_context;
-struct pipe_texture;
+struct pipe_resource;
struct drm_clip_rect;
diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h
index 9780cf250b..50c8c1cf19 100644
--- a/src/gallium/include/state_tracker/drm_api.h
+++ b/src/gallium/include/state_tracker/drm_api.h
@@ -8,7 +8,7 @@ struct pipe_screen;
struct pipe_winsys;
struct pipe_buffer;
struct pipe_context;
-struct pipe_texture;
+struct pipe_resource;
enum drm_create_screen_mode {
DRM_CREATE_NORMAL = 0,
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index 70ad215bfc..8897ff7c25 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -119,7 +119,7 @@ enum st_context_resource_type {
typedef void (*st_proc_t)(void);
struct pipe_context;
-struct pipe_texture;
+struct pipe_resource;
struct pipe_fence_handle;
/**
@@ -132,7 +132,7 @@ struct st_context_resource
void *resource;
/* this is owned by the caller */
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
};
/**
@@ -145,7 +145,7 @@ struct st_egl_image
void *egl_image;
/* this is owned by the caller */
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
unsigned face;
unsigned level;
@@ -239,7 +239,7 @@ struct st_framebuffer_iface
boolean (*validate)(struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
- struct pipe_texture **out);
+ struct pipe_resource **out);
};
/**
@@ -292,7 +292,7 @@ struct st_context_iface
*/
boolean (*teximage)(struct st_context_iface *stctxi, enum st_texture_type target,
int level, enum pipe_format internal_format,
- struct pipe_texture *tex, boolean mipmap);
+ struct pipe_resource *tex, boolean mipmap);
/**
* Used to implement glXCopyContext.
diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h
index a87650dc77..d461dedb90 100644
--- a/src/gallium/include/state_tracker/sw_winsys.h
+++ b/src/gallium/include/state_tracker/sw_winsys.h
@@ -47,7 +47,7 @@ extern "C" {
struct winsys_handle;
struct pipe_screen;
struct pipe_context;
-struct pipe_texture;
+struct pipe_resource;
/**
@@ -81,7 +81,7 @@ struct sw_winsys
* pools, or obtained directly from the windowing system.
*
* This callback is invoked by the pipe_screen when creating a texture marked
- * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying
+ * with the PIPE_BIND_DISPLAY_TARGET flag to get the underlying
* storage.
*/
struct sw_displaytarget *
@@ -97,7 +97,7 @@ struct sw_winsys
*/
struct sw_displaytarget *
(*displaytarget_from_handle)( struct sw_winsys *ws,
- const struct pipe_texture *templat,
+ const struct pipe_resource *template,
struct winsys_handle *whandle,
unsigned *stride );
@@ -110,7 +110,7 @@ struct sw_winsys
struct winsys_handle *whandle );
/**
- * \param flags bitmask of PIPE_BUFFER_USAGE_x flags
+ * \param flags bitmask of PIPE_TRANSFER_x flags
*/
void *
(*displaytarget_map)( struct sw_winsys *ws,
diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.c b/src/gallium/state_trackers/dri/common/dri1_helper.c
index 7eeb868d42..b0dd974a96 100644
--- a/src/gallium/state_trackers/dri/common/dri1_helper.c
+++ b/src/gallium/state_trackers/dri/common/dri1_helper.c
@@ -84,7 +84,7 @@ dri1_swap_fences_clear(struct dri_drawable *drawable)
}
struct pipe_surface *
-dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex)
+dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_resource *ptex)
{
struct pipe_screen *pipe_screen = dri_screen(drawable->sPriv)->pipe_screen;
struct pipe_surface *psurf = drawable->dri1_surface;
@@ -93,7 +93,7 @@ dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex)
pipe_surface_reference(&drawable->dri1_surface, NULL);
drawable->dri1_surface = pipe_screen->get_tex_surface(pipe_screen,
- ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+ ptex, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
psurf = drawable->dri1_surface;
}
diff --git a/src/gallium/state_trackers/dri/common/dri1_helper.h b/src/gallium/state_trackers/dri/common/dri1_helper.h
index 3254b7ff87..c98adf2df2 100644
--- a/src/gallium/state_trackers/dri/common/dri1_helper.h
+++ b/src/gallium/state_trackers/dri/common/dri1_helper.h
@@ -47,7 +47,7 @@ void
dri1_swap_fences_clear(struct dri_drawable *drawable);
struct pipe_surface *
-dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_texture *ptex);
+dri1_get_pipe_surface(struct dri_drawable *drawable, struct pipe_resource *ptex);
void
dri1_destroy_pipe_surface(struct dri_drawable *drawable);
diff --git a/src/gallium/state_trackers/dri/common/dri_drawable.h b/src/gallium/state_trackers/dri/common/dri_drawable.h
index 98abeb9ec0..315b778165 100644
--- a/src/gallium/state_trackers/dri/common/dri_drawable.h
+++ b/src/gallium/state_trackers/dri/common/dri_drawable.h
@@ -55,7 +55,7 @@ struct dri_drawable
unsigned old_w;
unsigned old_h;
- struct pipe_texture *textures[ST_ATTACHMENT_COUNT];
+ struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
unsigned int texture_mask, texture_stamp;
struct pipe_fence_handle *swap_fences[DRI_SWAP_FENCES_MAX];
diff --git a/src/gallium/state_trackers/dri/common/dri_screen.c b/src/gallium/state_trackers/dri/common/dri_screen.c
index 6e1761443e..83616744ad 100644
--- a/src/gallium/state_trackers/dri/common/dri_screen.c
+++ b/src/gallium/state_trackers/dri/common/dri_screen.c
@@ -93,34 +93,34 @@ dri_fill_in_modes(struct dri_screen *screen,
pf_x8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24X8_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
pf_z24x8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_X8Z24_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
pf_s8z24 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
pf_z24s8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
pf_a8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8A8_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+ PIPE_BIND_RENDER_TARGET, 0);
pf_x8r8g8b8 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B8G8R8X8_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+ PIPE_BIND_RENDER_TARGET, 0);
pf_r5g6b5 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_B5G6R5_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0);
+ PIPE_BIND_RENDER_TARGET, 0);
/* We can only get a 16 or 32 bit depth buffer with getBuffersWithFormat */
if (dri_with_format(screen->sPriv)) {
pf_z16 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z16_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
pf_z32 = p_screen->is_format_supported(p_screen, PIPE_FORMAT_Z32_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
} else {
pf_z16 = FALSE;
pf_z32 = FALSE;
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.c b/src/gallium/state_trackers/dri/common/dri_st_api.c
index 902a48e6b4..261bae75a2 100644
--- a/src/gallium/state_trackers/dri/common/dri_st_api.c
+++ b/src/gallium/state_trackers/dri/common/dri_st_api.c
@@ -47,7 +47,7 @@ static boolean
dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
- struct pipe_texture **out)
+ struct pipe_resource **out)
{
struct dri_drawable *drawable =
(struct dri_drawable *) stfbi->st_manager_private;
@@ -100,7 +100,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
for (i = 0; i < count; i++) {
out[i] = NULL;
- pipe_texture_reference(&out[i], drawable->textures[statts[i]]);
+ pipe_resource_reference(&out[i], drawable->textures[statts[i]]);
}
return TRUE;
@@ -157,7 +157,7 @@ dri_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
int i;
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&drawable->textures[i], NULL);
+ pipe_resource_reference(&drawable->textures[i], NULL);
FREE(stfbi);
}
@@ -242,7 +242,7 @@ dri_st_manager_get_egl_image(struct st_manager *smapi,
return FALSE;
stimg->texture = NULL;
- pipe_texture_reference(&stimg->texture, img->texture);
+ pipe_resource_reference(&stimg->texture, img->texture);
stimg->face = img->face;
stimg->level = img->level;
stimg->zslice = img->zslice;
diff --git a/src/gallium/state_trackers/dri/common/dri_st_api.h b/src/gallium/state_trackers/dri/common/dri_st_api.h
index 8eb6bb424c..11d86cfbdf 100644
--- a/src/gallium/state_trackers/dri/common/dri_st_api.h
+++ b/src/gallium/state_trackers/dri/common/dri_st_api.h
@@ -35,7 +35,7 @@ struct dri_screen;
struct dri_drawable;
struct __DRIimageRec {
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
unsigned face;
unsigned level;
unsigned zslice;
diff --git a/src/gallium/state_trackers/dri/drm/dri1.c b/src/gallium/state_trackers/dri/drm/dri1.c
index cca7cd8f0c..3cac1557ca 100644
--- a/src/gallium/state_trackers/dri/drm/dri1.c
+++ b/src/gallium/state_trackers/dri/drm/dri1.c
@@ -172,7 +172,7 @@ dri1_swap_copy(struct pipe_context *pipe,
static void
dri1_present_texture_locked(__DRIdrawable * dPriv,
- struct pipe_texture *ptex,
+ struct pipe_resource *ptex,
const struct drm_clip_rect *sub_box,
struct pipe_fence_handle **fence)
{
@@ -216,7 +216,7 @@ dri1_present_texture_locked(__DRIdrawable * dPriv,
static void
dri1_copy_to_front(struct dri_context *ctx,
- struct pipe_texture *ptex,
+ struct pipe_resource *ptex,
__DRIdrawable * dPriv,
const struct drm_clip_rect *sub_box,
struct pipe_fence_handle **fence)
@@ -254,7 +254,7 @@ dri1_flush_frontbuffer(struct dri_drawable *draw,
struct dri_screen *screen = dri_screen(draw->sPriv);
struct pipe_screen *pipe_screen = screen->pipe_screen;
struct pipe_fence_handle *dummy_fence;
- struct pipe_texture *ptex;
+ struct pipe_resource *ptex;
if (!ctx)
return; /* For now */
@@ -278,7 +278,7 @@ dri1_swap_buffers(__DRIdrawable * dPriv)
struct dri_screen *screen = dri_screen(draw->sPriv);
struct pipe_screen *pipe_screen = screen->pipe_screen;
struct pipe_fence_handle *fence;
- struct pipe_texture *ptex;
+ struct pipe_resource *ptex;
assert(__dri1_api_hooks != NULL);
@@ -308,7 +308,7 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
struct drm_clip_rect sub_bbox;
struct dri_drawable *draw = dri_drawable(dPriv);
struct pipe_fence_handle *dummy_fence;
- struct pipe_texture *ptex;
+ struct pipe_resource *ptex;
assert(__dri1_api_hooks != NULL);
@@ -340,7 +340,7 @@ dri1_allocate_textures(struct dri_drawable *drawable,
unsigned mask)
{
struct dri_screen *screen = dri_screen(drawable->sPriv);
- struct pipe_texture templ;
+ struct pipe_resource templ;
unsigned width, height;
boolean resized;
int i;
@@ -354,7 +354,7 @@ dri1_allocate_textures(struct dri_drawable *drawable,
/* remove outdated textures */
if (resized) {
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&drawable->textures[i], NULL);
+ pipe_resource_reference(&drawable->textures[i], NULL);
}
memset(&templ, 0, sizeof(templ));
@@ -379,12 +379,12 @@ dri1_allocate_textures(struct dri_drawable *drawable,
case ST_ATTACHMENT_FRONT_RIGHT:
case ST_ATTACHMENT_BACK_RIGHT:
format = drawable->stvis.color_format;
- tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ tex_usage = PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_RENDER_TARGET;
break;
case ST_ATTACHMENT_DEPTH_STENCIL:
format = drawable->stvis.depth_stencil_format;
- tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ tex_usage = PIPE_BIND_DEPTH_STENCIL;
break;
default:
format = PIPE_FORMAT_NONE;
@@ -393,10 +393,10 @@ dri1_allocate_textures(struct dri_drawable *drawable,
if (format != PIPE_FORMAT_NONE) {
templ.format = format;
- templ.tex_usage = tex_usage;
+ templ.bind = tex_usage;
drawable->textures[i] =
- screen->pipe_screen->texture_create(screen->pipe_screen, &templ);
+ screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
}
}
diff --git a/src/gallium/state_trackers/dri/drm/dri2.c b/src/gallium/state_trackers/dri/drm/dri2.c
index bd2517f2cd..c6655847e9 100644
--- a/src/gallium/state_trackers/dri/drm/dri2.c
+++ b/src/gallium/state_trackers/dri/drm/dri2.c
@@ -77,7 +77,7 @@ dri2_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
{
struct dri_context *ctx = dri_context(pDRICtx);
struct dri_drawable *drawable = dri_drawable(dPriv);
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
dri_st_framebuffer_validate_att(drawable->stfb, ST_ATTACHMENT_FRONT_LEFT);
@@ -146,6 +146,7 @@ dri2_drawable_get_format(struct dri_drawable *drawable,
return format;
}
+
/**
* Retrieve __DRIbuffer from the DRI loader.
*/
@@ -251,7 +252,7 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
}
/**
- * Process __DRIbuffer and convert them into pipe_textures.
+ * Process __DRIbuffer and convert them into pipe_resources.
*/
static void
dri2_drawable_process_buffers(struct dri_drawable *drawable,
@@ -259,7 +260,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
{
struct dri_screen *screen = dri_screen(drawable->sPriv);
__DRIdrawable *dri_drawable = drawable->dPriv;
- struct pipe_texture templ;
+ struct pipe_resource templ;
struct winsys_handle whandle;
boolean have_depth = FALSE;
unsigned i;
@@ -271,10 +272,10 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
return;
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&drawable->textures[i], NULL);
+ pipe_resource_reference(&drawable->textures[i], NULL);
memset(&templ, 0, sizeof(templ));
- templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templ.bind = PIPE_BIND_RENDER_TARGET;
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
templ.width0 = dri_drawable->w;
@@ -327,7 +328,7 @@ dri2_drawable_process_buffers(struct dri_drawable *drawable,
whandle.stride = buf->pitch;
drawable->textures[statt] =
- screen->pipe_screen->texture_from_handle(screen->pipe_screen,
+ screen->pipe_screen->resource_from_handle(screen->pipe_screen,
&templ, &whandle);
}
@@ -389,12 +390,12 @@ dri2_create_image_from_name(__DRIcontext *context,
{
struct dri_screen *screen = dri_screen(context->driScreenPriv);
__DRIimage *img;
- struct pipe_texture templ;
+ struct pipe_resource templ;
struct winsys_handle whandle;
unsigned tex_usage;
enum pipe_format pf;
- tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_SAMPLER;
+ tex_usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW;
switch (format) {
case __DRI_IMAGE_FORMAT_RGB565:
@@ -418,7 +419,7 @@ dri2_create_image_from_name(__DRIcontext *context,
return NULL;
memset(&templ, 0, sizeof(templ));
- templ.tex_usage = tex_usage;
+ templ.bind = tex_usage;
templ.format = pf;
templ.target = PIPE_TEXTURE_2D;
templ.last_level = 0;
@@ -430,7 +431,7 @@ dri2_create_image_from_name(__DRIcontext *context,
whandle.handle = name;
whandle.stride = pitch * util_format_get_blocksize(pf);
- img->texture = screen->pipe_screen->texture_from_handle(screen->pipe_screen,
+ img->texture = screen->pipe_screen->resource_from_handle(screen->pipe_screen,
&templ, &whandle);
if (!img->texture) {
FREE(img);
@@ -461,7 +462,7 @@ dri2_create_image_from_renderbuffer(__DRIcontext *context,
static void
dri2_destroy_image(__DRIimage *img)
{
- pipe_texture_reference(&img->texture, NULL);
+ pipe_resource_reference(&img->texture, NULL);
FREE(img);
}
diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c
index 42fa789aaf..9106f0d5eb 100644
--- a/src/gallium/state_trackers/dri/sw/drisw.c
+++ b/src/gallium/state_trackers/dri/sw/drisw.c
@@ -89,7 +89,7 @@ drisw_put_image(struct dri_drawable *drawable,
static INLINE void
drisw_present_texture(__DRIdrawable *dPriv,
- struct pipe_texture *ptex)
+ struct pipe_resource *ptex)
{
struct dri_drawable *drawable = dri_drawable(dPriv);
struct dri_screen *screen = dri_screen(drawable->sPriv);
@@ -117,7 +117,7 @@ drisw_invalidate_drawable(__DRIdrawable *dPriv)
static INLINE void
drisw_copy_to_front(__DRIdrawable * dPriv,
- struct pipe_texture *ptex)
+ struct pipe_resource *ptex)
{
drisw_present_texture(dPriv, ptex);
@@ -133,7 +133,7 @@ drisw_swap_buffers(__DRIdrawable *dPriv)
{
struct dri_context *ctx = dri_get_current();
struct dri_drawable *drawable = dri_drawable(dPriv);
- struct pipe_texture *ptex;
+ struct pipe_resource *ptex;
if (!ctx)
return;
@@ -152,7 +152,7 @@ drisw_flush_frontbuffer(struct dri_drawable *drawable,
enum st_attachment_type statt)
{
struct dri_context *ctx = dri_get_current();
- struct pipe_texture *ptex;
+ struct pipe_resource *ptex;
if (!ctx)
return;
@@ -180,7 +180,7 @@ drisw_allocate_textures(struct dri_drawable *drawable,
unsigned mask)
{
struct dri_screen *screen = dri_screen(drawable->sPriv);
- struct pipe_texture templ;
+ struct pipe_resource templ;
unsigned width, height;
boolean resized;
int i;
@@ -194,7 +194,7 @@ drisw_allocate_textures(struct dri_drawable *drawable,
/* remove outdated textures */
if (resized) {
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&drawable->textures[i], NULL);
+ pipe_resource_reference(&drawable->textures[i], NULL);
}
memset(&templ, 0, sizeof(templ));
@@ -219,12 +219,12 @@ drisw_allocate_textures(struct dri_drawable *drawable,
case ST_ATTACHMENT_FRONT_RIGHT:
case ST_ATTACHMENT_BACK_RIGHT:
format = drawable->stvis.color_format;
- tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ tex_usage = PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_RENDER_TARGET;
break;
case ST_ATTACHMENT_DEPTH_STENCIL:
format = drawable->stvis.depth_stencil_format;
- tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ tex_usage = PIPE_BIND_DEPTH_STENCIL;
break;
default:
format = PIPE_FORMAT_NONE;
@@ -233,10 +233,10 @@ drisw_allocate_textures(struct dri_drawable *drawable,
if (format != PIPE_FORMAT_NONE) {
templ.format = format;
- templ.tex_usage = tex_usage;
+ templ.bind = tex_usage;
drawable->textures[i] =
- screen->pipe_screen->texture_create(screen->pipe_screen, &templ);
+ screen->pipe_screen->resource_create(screen->pipe_screen, &templ);
}
}
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.c b/src/gallium/state_trackers/egl/common/egl_g3d.c
index 8e39a8588e..efddf56cbf 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.c
@@ -667,7 +667,7 @@ destroy_surface(_EGLDisplay *dpy, _EGLSurface *surf)
if (!dpy->Initialized)
_eglLog(_EGL_FATAL, "destroy a surface with an unitialized display");
- pipe_texture_reference(&gsurf->render_texture, NULL);
+ pipe_resource_reference(&gsurf->render_texture, NULL);
egl_g3d_destroy_st_framebuffer(gsurf->stfbi);
if (gsurf->native)
gsurf->native->destroy(gsurf->native);
@@ -787,9 +787,10 @@ egl_g3d_find_pixmap_config(_EGLDisplay *dpy, EGLNativePixmapType pix)
*/
static struct pipe_surface *
get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf,
- enum native_attachment natt)
+ enum native_attachment natt,
+ unsigned bind)
{
- struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
struct pipe_surface *psurf;
textures[natt] = NULL;
@@ -798,8 +799,8 @@ get_pipe_surface(struct native_display *ndpy, struct native_surface *nsurf,
return NULL;
psurf = ndpy->screen->get_tex_surface(ndpy->screen, textures[natt],
- 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
- pipe_texture_reference(&textures[natt], NULL);
+ 0, 0, 0, bind);
+ pipe_resource_reference(&textures[natt], NULL);
return psurf;
}
@@ -843,12 +844,13 @@ egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
return EGL_FALSE;
}
- psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT);
+ psurf = get_pipe_surface(gdpy->native, nsurf, NATIVE_ATTACHMENT_FRONT_LEFT,
+ PIPE_BIND_BLIT_DESTINATION);
if (psurf) {
struct pipe_surface *psrc;
psrc = screen->get_tex_surface(screen, gsurf->render_texture,
- 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+ 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
if (psrc) {
gdpy->pipe->surface_copy(gdpy->pipe, psurf, 0, 0,
psrc, 0, 0, psurf->width, psurf->height);
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d.h b/src/gallium/state_trackers/egl/common/egl_g3d.h
index 69bb0b4c46..67dff53853 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d.h
+++ b/src/gallium/state_trackers/egl/common/egl_g3d.h
@@ -73,7 +73,7 @@ struct egl_g3d_surface {
/* the native surface; NULL for pbuffers */
struct native_surface *native;
- struct pipe_texture *render_texture;
+ struct pipe_resource *render_texture;
unsigned int sequence_number;
};
@@ -86,7 +86,7 @@ struct egl_g3d_config {
struct egl_g3d_image {
_EGLImage base;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
unsigned face;
unsigned level;
unsigned zslice;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_image.c b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
index d701f9c9a8..e49bcdedf1 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_image.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_image.c
@@ -40,13 +40,13 @@
/**
* Reference and return the front left buffer of the native pixmap.
*/
-static struct pipe_texture *
+static struct pipe_resource *
egl_g3d_reference_native_pixmap(_EGLDisplay *dpy, EGLNativePixmapType pix)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
struct egl_g3d_config *gconf;
struct native_surface *nsurf;
- struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
enum native_attachment natt;
gconf = egl_g3d_config(egl_g3d_find_pixmap_config(dpy, pix));
@@ -72,7 +72,7 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
EGLenum target, EGLClientBuffer buffer,
const EGLint *attribs)
{
- struct pipe_texture *ptex;
+ struct pipe_resource *ptex;
struct egl_g3d_image *gimg;
unsigned face = 0, level = 0, zslice = 0;
@@ -104,13 +104,13 @@ egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx,
if (level > ptex->last_level) {
_eglError(EGL_BAD_MATCH, "eglCreateEGLImageKHR");
- pipe_texture_reference(&gimg->texture, NULL);
+ pipe_resource_reference(&gimg->texture, NULL);
free(gimg);
return NULL;
}
if (zslice > ptex->depth0) {
_eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
- pipe_texture_reference(&gimg->texture, NULL);
+ pipe_resource_reference(&gimg->texture, NULL);
free(gimg);
return NULL;
}
@@ -129,7 +129,7 @@ egl_g3d_destroy_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLImage *img)
{
struct egl_g3d_image *gimg = egl_g3d_image(img);
- pipe_texture_reference(&gimg->texture, NULL);
+ pipe_resource_reference(&gimg->texture, NULL);
free(gimg);
return EGL_TRUE;
diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_st.c b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
index 6e5ea960e3..887c7b07c7 100644
--- a/src/gallium/state_trackers/egl/common/egl_g3d_st.c
+++ b/src/gallium/state_trackers/egl/common/egl_g3d_st.c
@@ -107,7 +107,7 @@ egl_g3d_st_manager_get_egl_image(struct st_manager *smapi,
gimg = egl_g3d_image(img);
stimg->texture = NULL;
- pipe_texture_reference(&stimg->texture, gimg->texture);
+ pipe_resource_reference(&stimg->texture, gimg->texture);
stimg->face = gimg->face;
stimg->level = gimg->level;
stimg->zslice = gimg->zslice;
@@ -152,11 +152,11 @@ static boolean
egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
- struct pipe_texture **out)
+ struct pipe_resource **out)
{
_EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
- struct pipe_texture templ;
+ struct pipe_resource templ;
unsigned i;
for (i = 0; i < count; i++) {
@@ -177,12 +177,12 @@ egl_g3d_st_framebuffer_validate_pbuffer(struct st_framebuffer_iface *stfbi,
templ.height0 = gsurf->base.Height;
templ.depth0 = 1;
templ.format = gsurf->stvis.color_format;
- templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templ.bind = PIPE_BIND_RENDER_TARGET;
- gsurf->render_texture = screen->texture_create(screen, &templ);
+ gsurf->render_texture = screen->resource_create(screen, &templ);
}
- pipe_texture_reference(&out[i], gsurf->render_texture);
+ pipe_resource_reference(&out[i], gsurf->render_texture);
}
return TRUE;
@@ -202,11 +202,11 @@ static boolean
egl_g3d_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
- struct pipe_texture **out)
+ struct pipe_resource **out)
{
_EGLSurface *surf = (_EGLSurface *) stfbi->st_manager_private;
struct egl_g3d_surface *gsurf = egl_g3d_surface(surf);
- struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
uint attachment_mask = 0;
unsigned i;
@@ -241,7 +241,7 @@ egl_g3d_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
return FALSE;
for (i = 0; i < count; i++) {
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
int natt;
switch (statts[i]) {
@@ -266,7 +266,7 @@ egl_g3d_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
tex = textures[natt];
if (statts[i] == stfbi->visual->render_buffer)
- pipe_texture_reference(&gsurf->render_texture, tex);
+ pipe_resource_reference(&gsurf->render_texture, tex);
if (attachment_mask & (1 << natt)) {
/* transfer the ownership to the caller */
@@ -275,7 +275,7 @@ egl_g3d_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
}
else {
/* the attachment is listed more than once */
- pipe_texture_reference(&out[i], tex);
+ pipe_resource_reference(&out[i], tex);
}
}
}
diff --git a/src/gallium/state_trackers/egl/common/native.h b/src/gallium/state_trackers/egl/common/native.h
index 7b9bea516d..5ab21b639e 100644
--- a/src/gallium/state_trackers/egl/common/native.h
+++ b/src/gallium/state_trackers/egl/common/native.h
@@ -93,7 +93,7 @@ struct native_surface {
* behavior might change in the future.
*/
boolean (*validate)(struct native_surface *nsurf, uint attachment_mask,
- unsigned int *seq_num, struct pipe_texture **textures,
+ unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height);
/**
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.c b/src/gallium/state_trackers/egl/kms/native_kms.c
index 649439bedd..e88c529476 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.c
+++ b/src/gallium/state_trackers/egl/kms/native_kms.c
@@ -37,13 +37,13 @@
static boolean
kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
- unsigned int *seq_num, struct pipe_texture **textures,
+ unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height)
{
struct kms_surface *ksurf = kms_surface(nsurf);
struct kms_display *kdpy = ksurf->kdpy;
struct pipe_screen *screen = kdpy->base.screen;
- struct pipe_texture templ, *ptex;
+ struct pipe_resource templ, *ptex;
int att;
if (attachment_mask) {
@@ -54,8 +54,7 @@ kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
templ.height0 = ksurf->height;
templ.depth0 = 1;
templ.format = ksurf->color_format;
- templ.tex_usage =
- PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_SCANOUT;
+ templ.bind = PIPE_BIND_RENDER_TARGET | PIPE_BIND_SCANOUT;
}
/* create textures */
@@ -66,13 +65,13 @@ kms_surface_validate(struct native_surface *nsurf, uint attachment_mask,
ptex = ksurf->textures[att];
if (!ptex) {
- ptex = screen->texture_create(screen, &templ);
+ ptex = screen->resource_create(screen, &templ);
ksurf->textures[att] = ptex;
}
if (textures) {
textures[att] = NULL;
- pipe_texture_reference(&textures[att], ptex);
+ pipe_resource_reference(&textures[att], ptex);
}
}
@@ -118,7 +117,7 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
if (!ksurf->textures[natt])
return FALSE;
- pipe_texture_reference(&fb->texture, ksurf->textures[natt]);
+ pipe_resource_reference(&fb->texture, ksurf->textures[natt]);
}
/* already initialized */
@@ -131,7 +130,7 @@ kms_surface_init_framebuffers(struct native_surface *nsurf, boolean need_back)
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_KMS;
- if (!kdpy->base.screen->texture_get_handle(kdpy->base.screen,
+ if (!kdpy->base.screen->resource_get_handle(kdpy->base.screen,
fb->texture, &whandle))
return FALSE;
@@ -169,7 +168,7 @@ kms_surface_swap_buffers(struct native_surface *nsurf)
struct kms_crtc *kcrtc = &ksurf->current_crtc;
struct kms_display *kdpy = ksurf->kdpy;
struct kms_framebuffer tmp_fb;
- struct pipe_texture *tmp_texture;
+ struct pipe_resource *tmp_texture;
int err;
if (!ksurf->back_fb.buffer_id) {
@@ -220,15 +219,15 @@ kms_surface_destroy(struct native_surface *nsurf)
if (ksurf->front_fb.buffer_id)
drmModeRmFB(ksurf->kdpy->fd, ksurf->front_fb.buffer_id);
- pipe_texture_reference(&ksurf->front_fb.texture, NULL);
+ pipe_resource_reference(&ksurf->front_fb.texture, NULL);
if (ksurf->back_fb.buffer_id)
drmModeRmFB(ksurf->kdpy->fd, ksurf->back_fb.buffer_id);
- pipe_texture_reference(&ksurf->back_fb.texture, NULL);
+ pipe_resource_reference(&ksurf->back_fb.texture, NULL);
for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
- struct pipe_texture *ptex = ksurf->textures[i];
- pipe_texture_reference(&ptex, NULL);
+ struct pipe_resource *ptex = ksurf->textures[i];
+ pipe_resource_reference(&ptex, NULL);
}
free(ksurf);
@@ -567,8 +566,8 @@ kms_display_is_format_supported(struct native_display *ndpy,
{
return ndpy->screen->is_format_supported(ndpy->screen,
fmt, PIPE_TEXTURE_2D,
- (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET :
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ (is_color) ? PIPE_BIND_RENDER_TARGET :
+ PIPE_BIND_DEPTH_STENCIL, 0);
}
static const struct native_config **
diff --git a/src/gallium/state_trackers/egl/kms/native_kms.h b/src/gallium/state_trackers/egl/kms/native_kms.h
index d841f4884e..3b08e930c5 100644
--- a/src/gallium/state_trackers/egl/kms/native_kms.h
+++ b/src/gallium/state_trackers/egl/kms/native_kms.h
@@ -65,7 +65,7 @@ struct kms_display {
};
struct kms_framebuffer {
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
boolean is_passive;
uint32_t buffer_id;
@@ -77,7 +77,7 @@ struct kms_surface {
struct kms_display *kdpy;
int width, height;
- struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
unsigned int sequence_number;
struct kms_framebuffer front_fb, back_fb;
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 7f0acf3238..10a36ff8f6 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -72,7 +72,7 @@ struct dri2_surface {
unsigned int server_stamp;
unsigned int client_stamp;
int width, height;
- struct pipe_texture *textures[NUM_NATIVE_ATTACHMENTS];
+ struct pipe_resource *textures[NUM_NATIVE_ATTACHMENTS];
uint valid_mask;
boolean have_back, have_fake;
@@ -113,14 +113,14 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
{
struct dri2_surface *dri2surf = dri2_surface(nsurf);
struct dri2_display *dri2dpy = dri2surf->dri2dpy;
- struct pipe_texture templ;
+ struct pipe_resource templ;
struct winsys_handle whandle;
uint valid_mask;
int i;
/* free the old textures */
for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++)
- pipe_texture_reference(&dri2surf->textures[i], NULL);
+ pipe_resource_reference(&dri2surf->textures[i], NULL);
dri2surf->valid_mask = 0x0;
dri2surf->have_back = FALSE;
@@ -136,7 +136,7 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
templ.height0 = dri2surf->height;
templ.depth0 = 1;
templ.format = dri2surf->color_format;
- templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templ.bind = PIPE_BIND_RENDER_TARGET;
valid_mask = 0x0;
for (i = 0; i < num_xbufs; i++) {
@@ -175,7 +175,7 @@ dri2_surface_process_drawable_buffers(struct native_surface *nsurf,
memset(&whandle, 0, sizeof(whandle));
whandle.stride = xbuf->pitch;
whandle.handle = xbuf->name;
- dri2surf->textures[natt] = dri2dpy->base.screen->texture_from_handle(
+ dri2surf->textures[natt] = dri2dpy->base.screen->resource_from_handle(
dri2dpy->base.screen, &templ, &whandle);
if (dri2surf->textures[natt])
valid_mask |= 1 << natt;
@@ -325,7 +325,7 @@ dri2_surface_swap_buffers(struct native_surface *nsurf)
static boolean
dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask,
- unsigned int *seq_num, struct pipe_texture **textures,
+ unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height)
{
struct dri2_surface *dri2surf = dri2_surface(nsurf);
@@ -343,10 +343,10 @@ dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask,
int att;
for (att = 0; att < NUM_NATIVE_ATTACHMENTS; att++) {
if (native_attachment_mask_test(attachment_mask, att)) {
- struct pipe_texture *ptex = dri2surf->textures[att];
+ struct pipe_resource *ptex = dri2surf->textures[att];
textures[att] = NULL;
- pipe_texture_reference(&textures[att], ptex);
+ pipe_resource_reference(&textures[att], ptex);
}
}
}
@@ -382,8 +382,8 @@ dri2_surface_destroy(struct native_surface *nsurf)
free(dri2surf->last_xbufs);
for (i = 0; i < NUM_NATIVE_ATTACHMENTS; i++) {
- struct pipe_texture *ptex = dri2surf->textures[i];
- pipe_texture_reference(&ptex, NULL);
+ struct pipe_resource *ptex = dri2surf->textures[i];
+ pipe_resource_reference(&ptex, NULL);
}
if (dri2surf->drawable) {
@@ -518,8 +518,8 @@ is_format_supported(struct pipe_screen *screen,
enum pipe_format fmt, boolean is_color)
{
return screen->is_format_supported(screen, fmt, PIPE_TEXTURE_2D,
- (is_color) ? PIPE_TEXTURE_USAGE_RENDER_TARGET :
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ (is_color) ? PIPE_BIND_RENDER_TARGET :
+ PIPE_BIND_DEPTH_STENCIL, 0);
}
static boolean
diff --git a/src/gallium/state_trackers/egl/x11/native_ximage.c b/src/gallium/state_trackers/egl/x11/native_ximage.c
index 216de53f74..1b28dbce77 100644
--- a/src/gallium/state_trackers/egl/x11/native_ximage.c
+++ b/src/gallium/state_trackers/egl/x11/native_ximage.c
@@ -65,7 +65,7 @@ struct ximage_display {
};
struct ximage_buffer {
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct xlib_drawable xdraw;
};
@@ -116,7 +116,7 @@ ximage_surface_free_buffer(struct native_surface *nsurf,
struct ximage_surface *xsurf = ximage_surface(nsurf);
struct ximage_buffer *xbuf = &xsurf->buffers[which];
- pipe_texture_reference(&xbuf->texture, NULL);
+ pipe_resource_reference(&xbuf->texture, NULL);
}
static boolean
@@ -126,7 +126,7 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf,
struct ximage_surface *xsurf = ximage_surface(nsurf);
struct ximage_buffer *xbuf = &xsurf->buffers[which];
struct pipe_screen *screen = xsurf->xdpy->base.screen;
- struct pipe_texture templ;
+ struct pipe_resource templ;
/* free old data */
if (xbuf->texture)
@@ -138,22 +138,21 @@ ximage_surface_alloc_buffer(struct native_surface *nsurf,
templ.width0 = xsurf->width;
templ.height0 = xsurf->height;
templ.depth0 = 1;
- templ.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ templ.bind = PIPE_BIND_RENDER_TARGET;
switch (which) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
case NATIVE_ATTACHMENT_FRONT_RIGHT:
- templ.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT;
+ templ.bind |= PIPE_BIND_SCANOUT;
break;
case NATIVE_ATTACHMENT_BACK_LEFT:
case NATIVE_ATTACHMENT_BACK_RIGHT:
- templ.tex_usage |= PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+ templ.bind |= PIPE_BIND_DISPLAY_TARGET;
break;
default:
break;
}
-
- xbuf->texture = screen->texture_create(screen, &templ);
+ xbuf->texture = screen->resource_create(screen, &templ);
if (xbuf->texture) {
xbuf->xdraw.visual = xsurf->visual.visual;
xbuf->xdraw.depth = xsurf->visual.depth;
@@ -265,7 +264,7 @@ ximage_surface_draw_buffer(struct native_surface *nsurf,
pipe_surface_reference(&xsurf->draw_surface, NULL);
psurf = screen->get_tex_surface(screen,
- xbuf->texture, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ);
+ xbuf->texture, 0, 0, 0, PIPE_BIND_DISPLAY_TARGET);
if (!psurf)
return FALSE;
@@ -321,7 +320,7 @@ ximage_surface_swap_buffers(struct native_surface *nsurf)
static boolean
ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask,
- unsigned int *seq_num, struct pipe_texture **textures,
+ unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height)
{
struct ximage_surface *xsurf = ximage_surface(nsurf);
@@ -342,7 +341,7 @@ ximage_surface_validate(struct native_surface *nsurf, uint attachment_mask,
struct ximage_buffer *xbuf = &xsurf->buffers[att];
textures[att] = NULL;
- pipe_texture_reference(&textures[att], xbuf->texture);
+ pipe_resource_reference(&textures[att], xbuf->texture);
}
}
}
diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c
index c394430b94..f3b0617f76 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_api.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_api.c
@@ -339,7 +339,7 @@ static enum pipe_format
choose_depth_stencil_format(XMesaDisplay xmdpy, int depth, int stencil)
{
const enum pipe_texture_target target = PIPE_TEXTURE_2D;
- const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ const unsigned tex_usage = PIPE_BIND_DEPTH_STENCIL;
const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE |
PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO);
enum pipe_format formats[8], fmt;
diff --git a/src/gallium/state_trackers/glx/xlib/xm_st.c b/src/gallium/state_trackers/glx/xlib/xm_st.c
index a00eef6e88..27b6da94bc 100644
--- a/src/gallium/state_trackers/glx/xlib/xm_st.c
+++ b/src/gallium/state_trackers/glx/xlib/xm_st.c
@@ -40,7 +40,7 @@ struct xmesa_st_framebuffer {
struct st_visual stvis;
unsigned texture_width, texture_height, texture_mask;
- struct pipe_texture *textures[ST_ATTACHMENT_COUNT];
+ struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
struct pipe_surface *display_surface;
};
@@ -59,7 +59,7 @@ xmesa_st_framebuffer_display(struct st_framebuffer_iface *stfbi,
enum st_attachment_type statt)
{
struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
- struct pipe_texture *ptex = xstfb->textures[statt];
+ struct pipe_resource *ptex = xstfb->textures[statt];
struct pipe_surface *psurf;
if (!ptex)
@@ -71,7 +71,7 @@ xmesa_st_framebuffer_display(struct st_framebuffer_iface *stfbi,
pipe_surface_reference(&xstfb->display_surface, NULL);
psurf = xstfb->screen->get_tex_surface(xstfb->screen,
- ptex, 0, 0, 0, PIPE_BUFFER_USAGE_CPU_READ);
+ ptex, 0, 0, 0, PIPE_BIND_DISPLAY_TARGET);
if (!psurf)
return FALSE;
@@ -94,8 +94,8 @@ xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi,
unsigned width, unsigned height)
{
struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
- struct pipe_texture *src_ptex = xstfb->textures[src_statt];
- struct pipe_texture *dst_ptex = xstfb->textures[dst_statt];
+ struct pipe_resource *src_ptex = xstfb->textures[src_statt];
+ struct pipe_resource *dst_ptex = xstfb->textures[dst_statt];
struct pipe_surface *src, *dst;
struct pipe_context *pipe;
@@ -111,9 +111,9 @@ xmesa_st_framebuffer_copy_textures(struct st_framebuffer_iface *stfbi,
}
src = xstfb->screen->get_tex_surface(xstfb->screen,
- src_ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+ src_ptex, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
dst = xstfb->screen->get_tex_surface(xstfb->screen,
- dst_ptex, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+ dst_ptex, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION);
if (src && dst)
pipe->surface_copy(pipe, dst, x, y, src, x, y, width, height);
@@ -131,13 +131,13 @@ xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
unsigned mask)
{
struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
- struct pipe_texture templ;
+ struct pipe_resource templ;
unsigned i;
/* remove outdated textures */
if (xstfb->texture_width != width || xstfb->texture_height != height) {
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&xstfb->textures[i], NULL);
+ pipe_resource_reference(&xstfb->textures[i], NULL);
}
memset(&templ, 0, sizeof(templ));
@@ -149,7 +149,7 @@ xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
enum pipe_format format;
- unsigned tex_usage;
+ unsigned bind;
/* the texture already exists or not requested */
if (xstfb->textures[i] || !(mask & (1 << i))) {
@@ -165,12 +165,12 @@ xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
case ST_ATTACHMENT_FRONT_RIGHT:
case ST_ATTACHMENT_BACK_RIGHT:
format = xstfb->stvis.color_format;
- tex_usage = PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ bind = PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_RENDER_TARGET;
break;
case ST_ATTACHMENT_DEPTH_STENCIL:
format = xstfb->stvis.depth_stencil_format;
- tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ bind = PIPE_BIND_DEPTH_STENCIL;
break;
default:
format = PIPE_FORMAT_NONE;
@@ -179,10 +179,10 @@ xmesa_st_framebuffer_validate_textures(struct st_framebuffer_iface *stfbi,
if (format != PIPE_FORMAT_NONE) {
templ.format = format;
- templ.tex_usage = tex_usage;
+ templ.bind = bind;
xstfb->textures[i] =
- xstfb->screen->texture_create(xstfb->screen, &templ);
+ xstfb->screen->resource_create(xstfb->screen, &templ);
}
}
@@ -195,7 +195,7 @@ static boolean
xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
const enum st_attachment_type *statts,
unsigned count,
- struct pipe_texture **out)
+ struct pipe_resource **out)
{
struct xmesa_st_framebuffer *xstfb = xmesa_st_framebuffer(stfbi);
unsigned statt_mask, new_mask, i;
@@ -232,7 +232,7 @@ xmesa_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
for (i = 0; i < count; i++) {
out[i] = NULL;
- pipe_texture_reference(&out[i], xstfb->textures[statts[i]]);
+ pipe_resource_reference(&out[i], xstfb->textures[statts[i]]);
}
return TRUE;
@@ -292,7 +292,7 @@ xmesa_destroy_st_framebuffer(struct st_framebuffer_iface *stfbi)
pipe_surface_reference(&xstfb->display_surface, NULL);
for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
- pipe_texture_reference(&xstfb->textures[i], NULL);
+ pipe_resource_reference(&xstfb->textures[i], NULL);
FREE(xstfb);
FREE(stfbi);
@@ -306,7 +306,7 @@ xmesa_swap_st_framebuffer(struct st_framebuffer_iface *stfbi)
ret = xmesa_st_framebuffer_display(stfbi, ST_ATTACHMENT_BACK_LEFT);
if (ret) {
- struct pipe_texture **front, **back, *tmp;
+ struct pipe_resource **front, **back, *tmp;
front = &xstfb->textures[ST_ATTACHMENT_FRONT_LEFT];
back = &xstfb->textures[ST_ATTACHMENT_BACK_LEFT];
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index aeed1cd118..c6084f78ae 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -72,9 +72,8 @@
%rename(Device) st_device;
%rename(Context) st_context;
-%rename(Texture) pipe_texture;
+%rename(Resource) pipe_resource;
%rename(Surface) st_surface;
-%rename(Buffer) pipe_buffer;
%rename(BlendColor) pipe_blend_color;
%rename(Blend) pipe_blend_state;
diff --git a/src/gallium/state_trackers/python/p_context.i b/src/gallium/state_trackers/python/p_context.i
index 02ce5647eb..882219f4bc 100644
--- a/src/gallium/state_trackers/python/p_context.i
+++ b/src/gallium/state_trackers/python/p_context.i
@@ -144,7 +144,7 @@ struct st_context {
}
void set_constant_buffer(unsigned shader, unsigned index,
- struct pipe_buffer *buffer )
+ struct pipe_resource *buffer )
{
$self->pipe->set_constant_buffer($self->pipe, shader, index, buffer);
}
@@ -168,7 +168,7 @@ struct st_context {
}
void set_fragment_sampler_texture(unsigned index,
- struct pipe_texture *texture) {
+ struct pipe_resource *texture) {
struct pipe_sampler_view templ;
if(!texture)
@@ -186,7 +186,7 @@ struct st_context {
}
void set_vertex_sampler_texture(unsigned index,
- struct pipe_texture *texture) {
+ struct pipe_resource *texture) {
struct pipe_sampler_view templ;
if(!texture)
@@ -208,7 +208,7 @@ struct st_context {
unsigned stride,
unsigned max_index,
unsigned buffer_offset,
- struct pipe_buffer *buffer)
+ struct pipe_resource *buffer)
{
unsigned i;
struct pipe_vertex_buffer state;
@@ -252,7 +252,7 @@ struct st_context {
$self->pipe->draw_arrays($self->pipe, mode, start, count);
}
- void draw_elements( struct pipe_buffer *indexBuffer,
+ void draw_elements( struct pipe_resource *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count)
{
@@ -262,7 +262,7 @@ struct st_context {
mode, start, count);
}
- void draw_range_elements( struct pipe_buffer *indexBuffer,
+ void draw_range_elements( struct pipe_resource *indexBuffer,
unsigned indexSize, unsigned minIndex, unsigned maxIndex,
unsigned mode, unsigned start, unsigned count)
{
@@ -279,7 +279,8 @@ struct st_context {
{
struct pipe_context *pipe = $self->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_buffer *vbuf;
+ struct pipe_resource *vbuf;
+ struct pipe_transfer *transfer;
struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
struct pipe_vertex_buffer vbuffer;
float *map;
@@ -289,17 +290,16 @@ struct st_context {
size = num_verts * num_attribs * 4 * sizeof(float);
vbuf = pipe_buffer_create(screen,
- 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ PIPE_BIND_VERTEX_BUFFER,
size);
if(!vbuf)
goto error1;
-
- map = pipe_buffer_map(screen, vbuf, PIPE_BUFFER_USAGE_CPU_WRITE);
+
+ map = pipe_buffer_map(pipe, vbuf, PIPE_TRANSFER_WRITE, &transfer);
if (!map)
goto error2;
memcpy(map, vertices, size);
- pipe_buffer_unmap(screen, vbuf);
+ pipe_buffer_unmap(pipe, vbuf, transfer);
cso_save_vertex_elements($self->cso);
@@ -326,7 +326,7 @@ struct st_context {
cso_restore_vertex_elements($self->cso);
error2:
- pipe_buffer_reference(&vbuf, NULL);
+ pipe_resource_reference(&vbuf, NULL);
error1:
;
}
@@ -362,11 +362,11 @@ error1:
struct pipe_surface *_dst = NULL;
struct pipe_surface *_src = NULL;
- _dst = st_pipe_surface(dst, PIPE_BUFFER_USAGE_GPU_WRITE);
+ _dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION);
if(!_dst)
SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing");
- _src = st_pipe_surface(src, PIPE_BUFFER_USAGE_GPU_READ);
+ _src = st_pipe_surface(src, PIPE_BIND_BLIT_SOURCE);
if(!_src)
SWIG_exception(SWIG_ValueError, "couldn't acquire source surface for reading");
@@ -384,7 +384,7 @@ error1:
{
struct pipe_surface *_dst = NULL;
- _dst = st_pipe_surface(dst, PIPE_BUFFER_USAGE_GPU_WRITE);
+ _dst = st_pipe_surface(dst, PIPE_BIND_BLIT_DESTINATION);
if(!_dst)
SWIG_exception(SWIG_ValueError, "couldn't acquire destination surface for writing");
@@ -400,7 +400,7 @@ error1:
unsigned x, unsigned y, unsigned w, unsigned h,
char **STRING, int *LENGTH)
{
- struct pipe_texture *texture = surface->texture;
+ struct pipe_resource *texture = surface->texture;
struct pipe_context *pipe = $self->pipe;
struct pipe_transfer *transfer;
unsigned stride;
@@ -411,16 +411,16 @@ error1:
if(!*STRING)
return;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_READ,
- x, y, w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_READ,
+ x, y, w, h);
if(transfer) {
pipe_get_tile_raw(pipe, transfer, 0, 0, w, h, *STRING, stride);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
@@ -430,7 +430,7 @@ error1:
unsigned x, unsigned y, unsigned w, unsigned h,
const char *STRING, unsigned LENGTH, unsigned stride = 0)
{
- struct pipe_texture *texture = surface->texture;
+ struct pipe_resource *texture = surface->texture;
struct pipe_context *pipe = $self->pipe;
struct pipe_transfer *transfer;
@@ -440,18 +440,18 @@ error1:
if(LENGTH < util_format_get_nblocksy(texture->format, h) * stride)
SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_WRITE,
- x, y, w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_WRITE,
+ x, y, w, h);
if(!transfer)
SWIG_exception(SWIG_MemoryError, "couldn't initiate transfer");
pipe_put_tile_raw(pipe, transfer, 0, 0, w, h, STRING, stride);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
fail:
return;
@@ -464,16 +464,16 @@ error1:
{
struct pipe_context *pipe = $self->pipe;
struct pipe_transfer *transfer;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_READ,
- x, y, w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_READ,
+ x, y, w, h);
if(transfer) {
pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
@@ -484,16 +484,16 @@ error1:
{
struct pipe_context *pipe = $self->pipe;
struct pipe_transfer *transfer;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_WRITE,
- x, y, w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_WRITE,
+ x, y, w, h);
if(transfer) {
pipe_put_tile_rgba(pipe, transfer, 0, 0, w, h, rgba);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
@@ -526,14 +526,13 @@ error1:
rgba8 = (unsigned char *) *STRING;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_READ,
- x, y,
- w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_READ,
+ x, y, w, h);
if(transfer) {
pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba);
for(j = 0; j < h; ++j) {
@@ -541,7 +540,7 @@ error1:
for(k = 0; k <4; ++k)
rgba8[j*w*4 + i*4 + k] = float_to_ubyte(rgba[j*w*4 + i*4 + k]);
}
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
free(rgba);
@@ -554,16 +553,16 @@ error1:
{
struct pipe_context *pipe = $self->pipe;
struct pipe_transfer *transfer;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_READ,
- x, y, w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_READ,
+ x, y, w, h);
if(transfer) {
pipe_get_tile_z(pipe, transfer, 0, 0, w, h, z);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
@@ -574,16 +573,16 @@ error1:
{
struct pipe_context *pipe = $self->pipe;
struct pipe_transfer *transfer;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_WRITE,
- x, y, w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_WRITE,
+ x, y, w, h);
if(transfer) {
pipe_put_tile_z(pipe, transfer, 0, 0, w, h, z);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
@@ -611,20 +610,20 @@ error1:
if(!rgba2)
return ~0;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_READ,
- x, y, w, h);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_READ,
+ x, y, w, h);
if(!transfer) {
FREE(rgba2);
return ~0;
}
pipe_get_tile_rgba(pipe, transfer, 0, 0, w, h, rgba2);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
p1 = rgba;
p2 = rgba2;
diff --git a/src/gallium/state_trackers/python/p_device.i b/src/gallium/state_trackers/python/p_device.i
index 0eba488a07..18d5efcffb 100644
--- a/src/gallium/state_trackers/python/p_device.i
+++ b/src/gallium/state_trackers/python/p_device.i
@@ -81,7 +81,7 @@ struct st_device {
/**
* Check if the given pipe_format is supported as a texture or
* drawing surface.
- * \param type one of PIPE_TEXTURE, PIPE_SURFACE
+ * \param tex_usage bitmask of PIPE_BIND flags
*/
int is_format_supported( enum pipe_format format,
enum pipe_texture_target target,
@@ -89,7 +89,7 @@ struct st_device {
unsigned geom_flags ) {
/* We can't really display surfaces with the python statetracker so mask
* out that usage */
- tex_usage &= ~PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+ tex_usage &= ~PIPE_BIND_DISPLAY_TARGET;
return $self->screen->is_format_supported( $self->screen,
format,
@@ -103,7 +103,7 @@ struct st_device {
return st_context_create($self);
}
- struct pipe_texture *
+ struct pipe_resource *
texture_create(
enum pipe_format format,
unsigned width,
@@ -113,11 +113,11 @@ struct st_device {
enum pipe_texture_target target = PIPE_TEXTURE_2D,
unsigned tex_usage = 0
) {
- struct pipe_texture templat;
+ struct pipe_resource templat;
/* We can't really display surfaces with the python statetracker so mask
* out that usage */
- tex_usage &= ~PIPE_TEXTURE_USAGE_DISPLAY_TARGET;
+ tex_usage &= ~PIPE_BIND_DISPLAY_TARGET;
memset(&templat, 0, sizeof(templat));
templat.format = format;
@@ -126,14 +126,14 @@ struct st_device {
templat.depth0 = depth;
templat.last_level = last_level;
templat.target = target;
- templat.tex_usage = tex_usage;
+ templat.bind = tex_usage;
- return $self->screen->texture_create($self->screen, &templat);
+ return $self->screen->resource_create($self->screen, &templat);
}
-
- struct pipe_buffer *
- buffer_create(unsigned size, unsigned alignment = 0, unsigned usage = 0) {
- return pipe_buffer_create($self->screen, alignment, usage, size);
+
+ struct pipe_resource *
+ buffer_create(unsigned size, unsigned bind = 0) {
+ return pipe_buffer_create($self->screen, bind, size);
}
};
diff --git a/src/gallium/state_trackers/python/p_state.i b/src/gallium/state_trackers/python/p_state.i
index eda77b56f8..c1e6ea1b43 100644
--- a/src/gallium/state_trackers/python/p_state.i
+++ b/src/gallium/state_trackers/python/p_state.i
@@ -114,7 +114,7 @@
SWIG_exception(SWIG_ValueError, "index out of bounds");
if(surface) {
- _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE);
+ _surface = st_pipe_surface(surface, PIPE_BIND_RENDER_TARGET);
if(!_surface)
SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing");
}
@@ -131,7 +131,7 @@
struct pipe_surface *_surface = NULL;
if(surface) {
- _surface = st_pipe_surface(surface, PIPE_BUFFER_USAGE_GPU_WRITE);
+ _surface = st_pipe_surface(surface, PIPE_BIND_DEPTH_STENCIL);
if(!_surface)
SWIG_exception(SWIG_ValueError, "couldn't acquire surface for writing");
}
diff --git a/src/gallium/state_trackers/python/p_texture.i b/src/gallium/state_trackers/python/p_texture.i
index 923a628528..1208976905 100644
--- a/src/gallium/state_trackers/python/p_texture.i
+++ b/src/gallium/state_trackers/python/p_texture.i
@@ -33,97 +33,144 @@
*/
-%nodefaultctor pipe_texture;
+%nodefaultctor pipe_resource;
%nodefaultctor st_surface;
-%nodefaultctor pipe_buffer;
-%nodefaultdtor pipe_texture;
+%nodefaultdtor pipe_resource;
%nodefaultdtor st_surface;
-%nodefaultdtor pipe_buffer;
-%ignore pipe_texture::screen;
+%ignore pipe_resource::screen;
%immutable st_surface::texture;
%immutable st_surface::face;
%immutable st_surface::level;
%immutable st_surface::zslice;
-%newobject pipe_texture::get_surface;
+%newobject pipe_resource::get_surface;
+/* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */
+%rename(read) read_;
+%rename(write) write_;
-%extend pipe_texture {
-
- ~pipe_texture() {
- struct pipe_texture *ptr = $self;
- pipe_texture_reference(&ptr, NULL);
+%extend pipe_resource {
+
+ ~pipe_resource() {
+ struct pipe_resource *ptr = $self;
+ pipe_resource_reference(&ptr, NULL);
}
-
+
unsigned get_width(unsigned level=0) {
return u_minify($self->width0, level);
}
-
+
unsigned get_height(unsigned level=0) {
return u_minify($self->height0, level);
}
-
+
unsigned get_depth(unsigned level=0) {
return u_minify($self->depth0, level);
}
-
+
/** Get a surface which is a "view" into a texture */
struct st_surface *
get_surface(unsigned face=0, unsigned level=0, unsigned zslice=0)
{
struct st_surface *surface;
-
+
if(face >= ($self->target == PIPE_TEXTURE_CUBE ? 6U : 1U))
SWIG_exception(SWIG_ValueError, "face out of bounds");
if(level > $self->last_level)
SWIG_exception(SWIG_ValueError, "level out of bounds");
if(zslice >= u_minify($self->depth0, level))
SWIG_exception(SWIG_ValueError, "zslice out of bounds");
-
+
surface = CALLOC_STRUCT(st_surface);
if(!surface)
return NULL;
-
- pipe_texture_reference(&surface->texture, $self);
+
+ pipe_resource_reference(&surface->texture, $self);
surface->face = face;
surface->level = level;
surface->zslice = zslice;
-
+
return surface;
fail:
return NULL;
}
-
+
+ unsigned __len__(void)
+ {
+ assert($self->target == PIPE_BUFFER);
+ assert(p_atomic_read(&$self->reference.count) > 0);
+ return $self->width0;
+ }
+
+ %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
+ void read_(char **STRING, int *LENGTH)
+ {
+ struct pipe_screen *screen = $self->screen;
+ /* XXX need context here not screen */
+
+ assert($self->target == PIPE_BUFFER);
+ assert(p_atomic_read(&$self->reference.count) > 0);
+
+ *LENGTH = $self->width0;
+ *STRING = (char *) malloc($self->width0);
+ if(!*STRING)
+ return;
+
+ pipe_buffer_read(screen, $self, 0, $self->width0, *STRING);
+ }
+
+ %cstring_input_binary(const char *STRING, unsigned LENGTH);
+ void write_(const char *STRING, unsigned LENGTH, unsigned offset = 0)
+ {
+ struct pipe_screen *screen = $self->screen;
+ /* XXX need context here not screen */
+
+ assert($self->target == PIPE_BUFFER);
+ assert(p_atomic_read(&$self->reference.count) > 0);
+
+ if(offset > $self->width0)
+ SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
+
+ if(offset + LENGTH > $self->width0)
+ SWIG_exception(SWIG_ValueError, "data length must fit inside the buffer");
+
+ pipe_buffer_write(screen, $self, offset, LENGTH, STRING);
+
+fail:
+ return;
+ }
+
+
};
struct st_surface
{
%immutable;
-
- struct pipe_texture *texture;
+
+ struct pipe_resource *texture;
unsigned face;
unsigned level;
unsigned zslice;
-
+
};
%extend st_surface {
-
+
%immutable;
-
+
unsigned format;
unsigned width;
unsigned height;
-
+
~st_surface() {
- pipe_texture_reference(&$self->texture, NULL);
+ pipe_resource_reference(&$self->texture, NULL);
FREE($self);
}
-
+
};
@@ -146,55 +193,3 @@ struct st_surface
return u_minify(surface->texture->height0, surface->level);
}
%}
-
-/* Avoid naming conflict with p_inlines.h's pipe_buffer_read/write */
-%rename(read) read_;
-%rename(write) write_;
-
-%extend pipe_buffer {
-
- ~pipe_buffer() {
- struct pipe_buffer *ptr = $self;
- pipe_buffer_reference(&ptr, NULL);
- }
-
- unsigned __len__(void)
- {
- assert(p_atomic_read(&$self->reference.count) > 0);
- return $self->size;
- }
-
- %cstring_output_allocate_size(char **STRING, int *LENGTH, free(*$1));
- void read_(char **STRING, int *LENGTH)
- {
- struct pipe_screen *screen = $self->screen;
-
- assert(p_atomic_read(&$self->reference.count) > 0);
-
- *LENGTH = $self->size;
- *STRING = (char *) malloc($self->size);
- if(!*STRING)
- return;
-
- pipe_buffer_read(screen, $self, 0, $self->size, *STRING);
- }
-
- %cstring_input_binary(const char *STRING, unsigned LENGTH);
- void write_(const char *STRING, unsigned LENGTH, unsigned offset = 0)
- {
- struct pipe_screen *screen = $self->screen;
-
- assert(p_atomic_read(&$self->reference.count) > 0);
-
- if(offset > $self->size)
- SWIG_exception(SWIG_ValueError, "offset must be smaller than buffer size");
-
- if(offset + LENGTH > $self->size)
- SWIG_exception(SWIG_ValueError, "data length must fit inside the buffer");
-
- pipe_buffer_write(screen, $self, offset, LENGTH, STRING);
-
-fail:
- return;
- }
-};
diff --git a/src/gallium/state_trackers/python/st_device.c b/src/gallium/state_trackers/python/st_device.c
index 4f227a092c..135acad45e 100644
--- a/src/gallium/state_trackers/python/st_device.c
+++ b/src/gallium/state_trackers/python/st_device.c
@@ -129,7 +129,7 @@ st_context_destroy(struct st_context *st_ctx)
pipe_sampler_view_reference(&st_ctx->fragment_sampler_views[i], NULL);
for(i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; ++i)
pipe_sampler_view_reference(&st_ctx->vertex_sampler_views[i], NULL);
- pipe_texture_reference(&st_ctx->default_texture, NULL);
+ pipe_resource_reference(&st_ctx->default_texture, NULL);
FREE(st_ctx);
@@ -231,8 +231,7 @@ st_context_create(struct st_device *st_dev)
{
struct pipe_context *pipe = st_ctx->pipe;
struct pipe_screen *screen = st_dev->screen;
- struct pipe_texture templat;
- struct pipe_transfer *transfer;
+ struct pipe_resource templat;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view;
unsigned i;
@@ -245,24 +244,21 @@ st_context_create(struct st_device *st_dev)
templat.depth0 = 1;
templat.last_level = 0;
- st_ctx->default_texture = screen->texture_create( screen, &templat );
+ st_ctx->default_texture = screen->resource_create( screen, &templat );
if(st_ctx->default_texture) {
- transfer = pipe->get_tex_transfer(pipe,
- st_ctx->default_texture,
- 0, 0, 0,
- PIPE_TRANSFER_WRITE,
- 0, 0,
- st_ctx->default_texture->width0,
- st_ctx->default_texture->height0);
- if (transfer) {
- uint32_t *map;
- map = (uint32_t *) pipe->transfer_map(pipe, transfer);
- if(map) {
- *map = 0x00000000;
- pipe->transfer_unmap(pipe, transfer);
- }
- pipe->tex_transfer_destroy(pipe, transfer);
- }
+ struct pipe_box box;
+ uint32_t zero = 0;
+
+ u_box_origin_2d( 1, 1, &box );
+
+ pipe->transfer_inline_write(pipe,
+ st_ctx->default_texture,
+ u_subresource(0,0),
+ PIPE_TRANSFER_WRITE,
+ &box,
+ &zero,
+ sizeof zero,
+ 0);
}
u_sampler_view_default_template(&view_templ,
diff --git a/src/gallium/state_trackers/python/st_device.h b/src/gallium/state_trackers/python/st_device.h
index dcd0dc6e27..2dca7a1974 100644
--- a/src/gallium/state_trackers/python/st_device.h
+++ b/src/gallium/state_trackers/python/st_device.h
@@ -40,7 +40,7 @@ struct st_winsys;
struct st_surface
{
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
unsigned face;
unsigned level;
unsigned zslice;
@@ -59,7 +59,7 @@ struct st_context
void *fs;
void *gs;
- struct pipe_texture *default_texture;
+ struct pipe_resource *default_texture;
struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS];
@@ -85,7 +85,7 @@ struct st_device
static INLINE struct pipe_surface *
st_pipe_surface(struct st_surface *surface, unsigned usage)
{
- struct pipe_texture *texture = surface->texture;
+ struct pipe_resource *texture = surface->texture;
struct pipe_screen *screen = texture->screen;
return screen->get_tex_surface(screen, texture, surface->face, surface->level, surface->zslice, usage);
}
diff --git a/src/gallium/state_trackers/python/st_sample.c b/src/gallium/state_trackers/python/st_sample.c
index 218a77fb0a..25bfbf1ab7 100644
--- a/src/gallium/state_trackers/python/st_sample.c
+++ b/src/gallium/state_trackers/python/st_sample.c
@@ -546,22 +546,22 @@ st_sample_surface(struct pipe_context *pipe,
float *rgba,
boolean norm)
{
- struct pipe_texture *texture = surface->texture;
+ struct pipe_resource *texture = surface->texture;
unsigned width = u_minify(texture->width0, surface->level);
unsigned height = u_minify(texture->height0, surface->level);
uint rgba_stride = width * 4;
struct pipe_transfer *transfer;
void *raw;
- transfer = pipe->get_tex_transfer(pipe,
- surface->texture,
- surface->face,
- surface->level,
- surface->zslice,
- PIPE_TRANSFER_WRITE,
- 0, 0,
- width,
- height);
+ transfer = pipe_get_transfer(pipe,
+ surface->texture,
+ surface->face,
+ surface->level,
+ surface->zslice,
+ PIPE_TRANSFER_WRITE,
+ 0, 0,
+ width,
+ height);
if (!transfer)
return;
@@ -590,6 +590,6 @@ st_sample_surface(struct pipe_context *pipe,
pipe->transfer_unmap(pipe, transfer);
}
-
- pipe->tex_transfer_destroy(pipe, transfer);
+
+ pipe->transfer_destroy(pipe, transfer);
}
diff --git a/src/gallium/state_trackers/vega/api_filters.c b/src/gallium/state_trackers/vega/api_filters.c
index a643f38624..b1c08af938 100644
--- a/src/gallium/state_trackers/vega/api_filters.c
+++ b/src/gallium/state_trackers/vega/api_filters.c
@@ -57,14 +57,14 @@ struct filter_info {
struct pipe_sampler_view *extra_texture_view;
};
-static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,
+static INLINE struct pipe_resource *create_texture_1d(struct vg_context *ctx,
const VGuint *color_data,
const VGint color_data_len)
{
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture *tex = 0;
- struct pipe_texture templ;
+ struct pipe_resource *tex = 0;
+ struct pipe_resource templ;
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_1D;
@@ -73,20 +73,20 @@ static INLINE struct pipe_texture *create_texture_1d(struct vg_context *ctx,
templ.width0 = color_data_len;
templ.height0 = 1;
templ.depth0 = 1;
- templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+ templ.bind = PIPE_BIND_SAMPLER_VIEW;
- tex = screen->texture_create(screen, &templ);
+ tex = screen->resource_create(screen, &templ);
{ /* upload color_data */
struct pipe_transfer *transfer =
- pipe->get_tex_transfer(pipe, tex,
+ pipe_get_transfer(pipe, tex,
0, 0, 0,
PIPE_TRANSFER_READ_WRITE ,
0, 0, tex->width0, tex->height0);
void *map = pipe->transfer_map(pipe, transfer);
memcpy(map, color_data, sizeof(VGint)*color_data_len);
pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
return tex;
@@ -97,7 +97,7 @@ static INLINE struct pipe_sampler_view *create_texture_1d_view(struct vg_context
const VGint color_data_len)
{
struct pipe_context *pipe = ctx->pipe;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view;
@@ -109,7 +109,7 @@ static INLINE struct pipe_sampler_view *create_texture_1d_view(struct vg_context
u_sampler_view_default_template(&view_templ, texture, texture->format);
view = pipe->create_sampler_view(pipe, texture, &view_templ);
/* want the texture to go away if the view is freed */
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
return view;
}
@@ -121,7 +121,7 @@ static INLINE struct pipe_surface * setup_framebuffer(struct vg_image *dst)
struct pipe_framebuffer_state fb;
struct pipe_surface *dst_surf = pipe->screen->get_tex_surface(
pipe->screen, dst->sampler_view->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
/* drawing dest */
memset(&fb, 0, sizeof(fb));
@@ -170,14 +170,14 @@ static void setup_constant_buffer(struct vg_context *ctx, const void *buffer,
VGint param_bytes)
{
struct pipe_context *pipe = ctx->pipe;
- struct pipe_buffer **cbuf = &ctx->filter.buffer;
+ struct pipe_resource **cbuf = &ctx->filter.buffer;
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization. */
- pipe_buffer_reference(cbuf, NULL);
+ pipe_resource_reference(cbuf, NULL);
- *cbuf = pipe_buffer_create(pipe->screen, 16,
- PIPE_BUFFER_USAGE_CONSTANT,
+ *cbuf = pipe_buffer_create(pipe->screen,
+ PIPE_BIND_CONSTANT_BUFFER,
param_bytes);
if (*cbuf) {
diff --git a/src/gallium/state_trackers/vega/api_images.c b/src/gallium/state_trackers/vega/api_images.c
index fec473d9d2..6c7fd3b346 100644
--- a/src/gallium/state_trackers/vega/api_images.c
+++ b/src/gallium/state_trackers/vega/api_images.c
@@ -441,9 +441,9 @@ void vgReadPixels(void * data, VGint dataStride,
{
struct pipe_transfer *transfer;
- transfer = pipe->get_tex_transfer(pipe, strb->texture, 0, 0, 0,
- PIPE_TRANSFER_READ,
- 0, 0, width, height);
+ transfer = pipe_get_transfer(pipe, strb->texture, 0, 0, 0,
+ PIPE_TRANSFER_READ,
+ 0, 0, width, height);
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
@@ -457,7 +457,7 @@ void vgReadPixels(void * data, VGint dataStride,
dst += dataStride;
}
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
diff --git a/src/gallium/state_trackers/vega/api_masks.c b/src/gallium/state_trackers/vega/api_masks.c
index 2f2d925252..7c28ea5c87 100644
--- a/src/gallium/state_trackers/vega/api_masks.c
+++ b/src/gallium/state_trackers/vega/api_masks.c
@@ -51,7 +51,7 @@ draw_clear_quad(struct vg_context *st,
const VGfloat color[4])
{
struct pipe_context *pipe = st->pipe;
- struct pipe_buffer *buf;
+ struct pipe_resource *buf;
VGuint i;
/* positions */
@@ -81,7 +81,8 @@ draw_clear_quad(struct vg_context *st,
/* put vertex data into vbuf */
buf = pipe_user_buffer_create(pipe->screen,
st->clear.vertices,
- sizeof(st->clear.vertices));
+ sizeof(st->clear.vertices),
+ PIPE_BIND_VERTEX_BUFFER);
/* draw */
@@ -93,7 +94,7 @@ draw_clear_quad(struct vg_context *st,
4, /* verts */
2); /* attribs/vert */
- pipe_buffer_reference(&buf, NULL);
+ pipe_resource_reference(&buf, NULL);
}
}
diff --git a/src/gallium/state_trackers/vega/image.c b/src/gallium/state_trackers/vega/image.c
index c3268a84a6..9c323b1809 100644
--- a/src/gallium/state_trackers/vega/image.c
+++ b/src/gallium/state_trackers/vega/image.c
@@ -81,7 +81,7 @@ static INLINE void vg_sync_size(VGfloat *src_loc, VGfloat *dst_loc)
static void vg_copy_texture(struct vg_context *ctx,
- struct pipe_texture *dst, VGint dx, VGint dy,
+ struct pipe_resource *dst, VGint dx, VGint dy,
struct pipe_sampler_view *src, VGint sx, VGint sy,
VGint width, VGint height)
{
@@ -217,9 +217,9 @@ void vg_copy_surface(struct vg_context *ctx,
}
-static struct pipe_texture *image_texture(struct vg_image *img)
+static struct pipe_resource *image_texture(struct vg_image *img)
{
- struct pipe_texture *tex = img->sampler_view->texture;
+ struct pipe_resource *tex = img->sampler_view->texture;
return tex;
}
@@ -251,7 +251,7 @@ struct vg_image * image_create(VGImageFormat format,
struct pipe_context *pipe = ctx->pipe;
struct vg_image *image = CALLOC_STRUCT(vg_image);
enum pipe_format pformat = vg_format_to_pipe(format);
- struct pipe_texture pt, *newtex;
+ struct pipe_resource pt, *newtex;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view;
struct pipe_screen *screen = ctx->pipe->screen;
@@ -270,7 +270,7 @@ struct vg_image * image_create(VGImageFormat format,
image->sampler.normalized_coords = 1;
assert(screen->is_format_supported(screen, pformat, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ PIPE_BIND_SAMPLER_VIEW, 0));
memset(&pt, 0, sizeof(pt));
pt.target = PIPE_TEXTURE_2D;
@@ -279,16 +279,16 @@ struct vg_image * image_create(VGImageFormat format,
pt.width0 = width;
pt.height0 = height;
pt.depth0 = 1;
- pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+ pt.bind = PIPE_BIND_SAMPLER_VIEW;
- newtex = screen->texture_create(screen, &pt);
+ newtex = screen->resource_create(screen, &pt);
debug_assert(newtex);
u_sampler_view_default_template(&view_templ, newtex, newtex->format);
view = pipe->create_sampler_view(pipe, newtex, &view_templ);
/* want the texture to go away if the view is freed */
- pipe_texture_reference(&newtex, NULL);
+ pipe_resource_reference(&newtex, NULL);
image->sampler_view = view;
@@ -388,7 +388,7 @@ void image_sub_data(struct vg_image *image,
VGint i;
struct vg_context *ctx = vg_current_context();
struct pipe_context *pipe = ctx->pipe;
- struct pipe_texture *texture = image_texture(image);
+ struct pipe_resource *texture = image_texture(image);
VGint xoffset = 0, yoffset = 0;
if (x < 0) {
@@ -421,7 +421,7 @@ void image_sub_data(struct vg_image *image,
}
{ /* upload color_data */
- struct pipe_transfer *transfer = pipe->get_tex_transfer(
+ struct pipe_transfer *transfer = pipe_get_transfer(
pipe, texture, 0, 0, 0,
PIPE_TRANSFER_WRITE, 0, 0, texture->width0, texture->height0);
src += (dataStride * yoffset);
@@ -431,7 +431,7 @@ void image_sub_data(struct vg_image *image,
y += yStep;
src += dataStride;
}
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
@@ -452,7 +452,7 @@ void image_get_sub_data(struct vg_image * image,
{
struct pipe_transfer *transfer =
- pipe->get_tex_transfer(pipe,
+ pipe_get_transfer(pipe,
image->sampler_view->texture, 0, 0, 0,
PIPE_TRANSFER_READ,
0, 0,
@@ -469,7 +469,7 @@ void image_get_sub_data(struct vg_image * image,
dst += dataStride;
}
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
}
@@ -576,7 +576,7 @@ void image_set_pixels(VGint dx, VGint dy,
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
surf = screen->get_tex_surface(screen, image_texture(src), 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BIND_BLIT_SOURCE);
vg_copy_surface(ctx, strb->surface, dx, dy,
surf, sx+src->x, sy+src->y, width, height);
@@ -601,8 +601,8 @@ void image_get_pixels(struct vg_image *dst, VGint dx, VGint dy,
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
surf = screen->get_tex_surface(screen, image_texture(dst), 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE |
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BIND_BLIT_SOURCE);
+
vg_copy_surface(ctx, surf, dst->x + dx, dst->y + dy,
strb->surface, sx, sy, width, height);
diff --git a/src/gallium/state_trackers/vega/image.h b/src/gallium/state_trackers/vega/image.h
index 805b35fab9..a990c9c587 100644
--- a/src/gallium/state_trackers/vega/image.h
+++ b/src/gallium/state_trackers/vega/image.h
@@ -30,7 +30,7 @@
#include "vg_context.h"
#include "pipe/p_state.h"
-struct pipe_texture;
+struct pipe_resource;
struct array;
struct vg_context;
struct pipe_surface;
diff --git a/src/gallium/state_trackers/vega/mask.c b/src/gallium/state_trackers/vega/mask.c
index 316ea7a9c9..6d627b0e8d 100644
--- a/src/gallium/state_trackers/vega/mask.c
+++ b/src/gallium/state_trackers/vega/mask.c
@@ -143,7 +143,7 @@ static void read_alpha_mask(void * data, VGint dataStride,
struct pipe_surface *surf;
surf = screen->get_tex_surface(screen, strb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_BIND_TRANSFER_READ);
/* Do a row at a time to flip image data vertically */
for (i = 0; i < height; i++) {
@@ -217,7 +217,7 @@ static void setup_mask_framebuffer(struct pipe_surface *surf,
static void setup_mask_operation(VGMaskOperation operation)
{
struct vg_context *ctx = vg_current_context();
- struct pipe_buffer **cbuf = &ctx->mask.cbuf;
+ struct pipe_resource **cbuf = &ctx->mask.cbuf;
const VGint param_bytes = 4 * sizeof(VGfloat);
const VGfloat ones[4] = {1.f, 1.f, 1.f, 1.f};
void *shader = 0;
@@ -225,10 +225,10 @@ static void setup_mask_operation(VGMaskOperation operation)
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
- pipe_buffer_reference(cbuf, NULL);
+ pipe_resource_reference(cbuf, NULL);
- *cbuf = pipe_buffer_create(ctx->pipe->screen, 1,
- PIPE_BUFFER_USAGE_CONSTANT,
+ *cbuf = pipe_buffer_create(ctx->pipe->screen,
+ PIPE_BIND_CONSTANT_BUFFER,
param_bytes);
if (*cbuf) {
st_no_flush_pipe_buffer_write(ctx, *cbuf,
@@ -318,16 +318,16 @@ static void setup_mask_samplers(struct pipe_sampler_view *umask)
static void setup_mask_fill(const VGfloat color[4])
{
struct vg_context *ctx = vg_current_context();
- struct pipe_buffer **cbuf = &ctx->mask.cbuf;
+ struct pipe_resource **cbuf = &ctx->mask.cbuf;
const VGint param_bytes = 4 * sizeof(VGfloat);
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
- pipe_buffer_reference(cbuf, NULL);
+ pipe_resource_reference(cbuf, NULL);
- *cbuf = pipe_buffer_create(ctx->pipe->screen, 1,
- PIPE_BUFFER_USAGE_CONSTANT,
+ *cbuf = pipe_buffer_create(ctx->pipe->screen,
+ PIPE_BIND_CONSTANT_BUFFER,
param_bytes);
if (*cbuf) {
st_no_flush_pipe_buffer_write(ctx, *cbuf, 0, param_bytes, color);
@@ -415,9 +415,9 @@ static void mask_using_texture(struct pipe_sampler_view *sampler_view,
VGint width, VGint height)
{
struct vg_context *ctx = vg_current_context();
- struct pipe_texture *texture = sampler_view->texture;
+ struct pipe_resource *texture = sampler_view->texture;
struct pipe_surface *surface =
- alpha_mask_surface(ctx, PIPE_BUFFER_USAGE_GPU_WRITE);
+ alpha_mask_surface(ctx, PIPE_BIND_RENDER_TARGET);
VGint offsets[4], loc[4];
if (!surface)
@@ -482,12 +482,12 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height)
mask->height = height;
{
- struct pipe_texture pt;
+ struct pipe_resource pt;
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = ctx->pipe->screen;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view = NULL;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
memset(&pt, 0, sizeof(pt));
pt.target = PIPE_TEXTURE_2D;
@@ -496,16 +496,16 @@ struct vg_mask_layer * mask_layer_create(VGint width, VGint height)
pt.width0 = width;
pt.height0 = height;
pt.depth0 = 1;
- pt.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+ pt.bind = PIPE_BIND_SAMPLER_VIEW;
pt.compressed = 0;
- texture = screen->texture_create(screen, &pt);
+ texture = screen->resource_create(screen, &pt);
if (texture) {
u_sampler_view_default_template(&view_templ, texture, texture->format);
view = pipe->create_sampler_view(pipe, texture, &view_templ);
}
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
mask->sampler_view = view;
}
@@ -519,7 +519,7 @@ void mask_layer_destroy(struct vg_mask_layer *layer)
struct vg_context *ctx = vg_current_context();
vg_context_remove_object(ctx, VG_OBJECT_MASK, layer);
- pipe_texture_release(&layer->texture);
+ pipe_resource_release(&layer->texture);
free(layer);
}
@@ -537,7 +537,7 @@ void mask_layer_fill(struct vg_mask_layer *layer,
surface = ctx->pipe->screen->get_tex_surface(
ctx->pipe->screen, layer->sampler_view->texture,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
surface_fill(surface,
layer->width, layer->height,
@@ -573,7 +573,7 @@ static void mask_layer_render_to(struct vg_mask_layer *layer,
struct pipe_surface *surface;
surface = screen->get_tex_surface(screen, layer->sampler_view->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
cso_save_framebuffer(ctx->cso_context);
cso_save_fragment_shader(ctx->cso_context);
@@ -664,7 +664,7 @@ void mask_fill(VGint x, VGint y, VGint width, VGint height,
struct vg_context *ctx = vg_current_context();
VGfloat alpha_color[4] = {.0f, .0f, .0f, value};
struct pipe_surface *surf = alpha_mask_surface(
- ctx, PIPE_BUFFER_USAGE_GPU_WRITE);
+ ctx, PIPE_BIND_RENDER_TARGET);
#if DEBUG_MASKS
debug_printf("mask_fill(%d, %d, %d, %d) with rgba(%f, %f, %f, %f)\n",
diff --git a/src/gallium/state_trackers/vega/mask.h b/src/gallium/state_trackers/vega/mask.h
index 4feacbefda..c626402c86 100644
--- a/src/gallium/state_trackers/vega/mask.h
+++ b/src/gallium/state_trackers/vega/mask.h
@@ -31,7 +31,7 @@
struct path;
struct vg_image;
-struct pipe_texture;
+struct pipe_resource;
struct vg_mask_layer *mask_layer_create(VGint width, VGint height);
void mask_layer_destroy(struct vg_mask_layer *layer);
diff --git a/src/gallium/state_trackers/vega/paint.c b/src/gallium/state_trackers/vega/paint.c
index 508e1863a5..05540e8275 100644
--- a/src/gallium/state_trackers/vega/paint.c
+++ b/src/gallium/state_trackers/vega/paint.c
@@ -79,7 +79,7 @@ struct vg_paint {
} pattern;
/* XXX next 3 all unneded? */
- struct pipe_buffer *cbuf;
+ struct pipe_resource *cbuf;
struct pipe_shader_state fs_state;
void *fs;
};
@@ -143,12 +143,12 @@ static INLINE void create_gradient_data(const VGfloat *ramp_stops,
data[size-1] = last_color;
}
-static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p)
+static INLINE struct pipe_resource *create_gradient_texture(struct vg_paint *p)
{
struct pipe_context *pipe = p->base.ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture *tex = 0;
- struct pipe_texture templ;
+ struct pipe_resource *tex = 0;
+ struct pipe_resource templ;
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_1D;
@@ -157,18 +157,18 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p)
templ.width0 = 1024;
templ.height0 = 1;
templ.depth0 = 1;
- templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+ templ.bind = PIPE_BIND_SAMPLER_VIEW;
- tex = screen->texture_create(screen, &templ);
+ tex = screen->resource_create(screen, &templ);
{ /* upload color_data */
struct pipe_transfer *transfer =
- st_no_flush_get_tex_transfer(p->base.ctx, tex, 0, 0, 0,
+ st_no_flush_get_transfer(p->base.ctx, tex, 0, 0, 0,
PIPE_TRANSFER_WRITE, 0, 0, 1024, 1);
void *map = pipe->transfer_map(pipe, transfer);
memcpy(map, p->gradient.color_data, sizeof(VGint)*1024);
pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
return tex;
@@ -177,7 +177,7 @@ static INLINE struct pipe_texture *create_gradient_texture(struct vg_paint *p)
static INLINE struct pipe_sampler_view *create_gradient_sampler_view(struct vg_paint *p)
{
struct pipe_context *pipe = p->base.ctx->pipe;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view;
@@ -189,7 +189,7 @@ static INLINE struct pipe_sampler_view *create_gradient_sampler_view(struct vg_p
u_sampler_view_default_template(&view_templ, texture, texture->format);
view = pipe->create_sampler_view(pipe, texture, &view_templ);
/* want the texture to go away if the view is freed */
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
return view;
}
diff --git a/src/gallium/state_trackers/vega/paint.h b/src/gallium/state_trackers/vega/paint.h
index 9ea67c4b1e..012cd3e561 100644
--- a/src/gallium/state_trackers/vega/paint.h
+++ b/src/gallium/state_trackers/vega/paint.h
@@ -35,7 +35,7 @@
struct vg_paint;
struct vg_image;
struct pipe_sampler_state;
-struct pipe_texture;
+struct pipe_resource;
struct vg_paint *paint_create(struct vg_context *ctx);
void paint_destroy(struct vg_paint *paint);
diff --git a/src/gallium/state_trackers/vega/polygon.c b/src/gallium/state_trackers/vega/polygon.c
index eef2c1eb87..d2b7e48912 100644
--- a/src/gallium/state_trackers/vega/polygon.c
+++ b/src/gallium/state_trackers/vega/polygon.c
@@ -58,7 +58,7 @@ struct polygon
VGint num_verts;
VGboolean dirty;
- struct pipe_buffer *vbuf;
+ struct pipe_resource *vbuf;
struct pipe_screen *screen;
};
@@ -110,7 +110,7 @@ struct polygon * polygon_create_from_data(float *data, int size)
void polygon_destroy(struct polygon *poly)
{
if (poly->vbuf)
- pipe_buffer_reference(&poly->vbuf, NULL);
+ pipe_resource_reference(&poly->vbuf, NULL);
free(poly->data);
free(poly);
@@ -272,13 +272,14 @@ static void draw_polygon(struct vg_context *ctx,
if (poly->vbuf == NULL || poly->dirty) {
if (poly->vbuf) {
- pipe_buffer_reference(&poly->vbuf,
+ pipe_resource_reference(&poly->vbuf,
NULL);
}
poly->screen = pipe->screen;
poly->vbuf= pipe_user_buffer_create(poly->screen,
poly->data,
- vert_size);
+ vert_size,
+ PIPE_BIND_VERTEX_BUFFER);
poly->dirty = VG_FALSE;
}
diff --git a/src/gallium/state_trackers/vega/renderer.c b/src/gallium/state_trackers/vega/renderer.c
index 2bb4c8bc75..48fbc3b330 100644
--- a/src/gallium/state_trackers/vega/renderer.c
+++ b/src/gallium/state_trackers/vega/renderer.c
@@ -61,7 +61,7 @@ static void setup_shaders(struct renderer *ctx)
ctx->fs = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D);
}
-static struct pipe_buffer *
+static struct pipe_resource *
setup_vertex_data(struct renderer *ctx,
float x0, float y0, float x1, float y1, float z)
{
@@ -91,10 +91,11 @@ setup_vertex_data(struct renderer *ctx,
return pipe_user_buffer_create( ctx->pipe->screen,
ctx->vertices,
- sizeof(ctx->vertices) );
+ sizeof(ctx->vertices),
+ PIPE_BIND_VERTEX_BUFFER);
}
-static struct pipe_buffer *
+static struct pipe_resource *
setup_vertex_data_tex(struct renderer *ctx,
float x0, float y0, float x1, float y1,
float s0, float t0, float s1, float t1,
@@ -126,11 +127,12 @@ setup_vertex_data_tex(struct renderer *ctx,
return pipe_user_buffer_create( ctx->pipe->screen,
ctx->vertices,
- sizeof(ctx->vertices) );
+ sizeof(ctx->vertices),
+ PIPE_BIND_VERTEX_BUFFER);
}
-static struct pipe_buffer *
+static struct pipe_resource *
setup_vertex_data_qtex(struct renderer *ctx,
float x0, float y0, float x1, float y1,
float x2, float y2, float x3, float y3,
@@ -163,7 +165,8 @@ setup_vertex_data_qtex(struct renderer *ctx,
return pipe_user_buffer_create( ctx->pipe->screen,
ctx->vertices,
- sizeof(ctx->vertices) );
+ sizeof(ctx->vertices),
+ PIPE_BIND_VERTEX_BUFFER);
}
struct renderer * renderer_create(struct vg_context *owner)
@@ -206,7 +209,7 @@ void renderer_draw_quad(struct renderer *r,
VGfloat x2, VGfloat y2,
VGfloat depth)
{
- struct pipe_buffer *buf;
+ struct pipe_resource *buf;
buf = setup_vertex_data(r, x1, y1, x2, y2, depth);
@@ -217,20 +220,20 @@ void renderer_draw_quad(struct renderer *r,
4, /* verts */
2); /* attribs/vert */
- pipe_buffer_reference( &buf,
+ pipe_resource_reference( &buf,
NULL );
}
}
void renderer_draw_texture(struct renderer *r,
- struct pipe_texture *tex,
+ struct pipe_resource *tex,
VGfloat x1offset, VGfloat y1offset,
VGfloat x2offset, VGfloat y2offset,
VGfloat x1, VGfloat y1,
VGfloat x2, VGfloat y2)
{
struct pipe_context *pipe = r->pipe;
- struct pipe_buffer *buf;
+ struct pipe_resource *buf;
VGfloat s0, t0, s1, t1;
assert(tex->width0 != 0);
@@ -256,7 +259,7 @@ void renderer_draw_texture(struct renderer *r,
4, /* verts */
2); /* attribs/vert */
- pipe_buffer_reference( &buf,
+ pipe_resource_reference( &buf,
NULL );
}
@@ -267,17 +270,17 @@ void renderer_copy_texture(struct renderer *ctx,
struct pipe_sampler_view *src,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
- struct pipe_texture *dst,
+ struct pipe_resource *dst,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2)
{
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture *tex = src->texture;
- struct pipe_buffer *buf;
+ struct pipe_resource *tex = src->texture;
+ struct pipe_resource *buf;
struct pipe_surface *dst_surf = screen->get_tex_surface(
screen, dst, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
struct pipe_framebuffer_state fb;
float s0, t0, s1, t1;
@@ -304,7 +307,7 @@ void renderer_copy_texture(struct renderer *ctx,
#endif
assert(screen->is_format_supported(screen, dst_surf->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
+ PIPE_BIND_RENDER_TARGET, 0));
/* save state (restored below) */
cso_save_blend(ctx->cso);
@@ -380,7 +383,7 @@ void renderer_copy_texture(struct renderer *ctx,
4, /* verts */
2); /* attribs/vert */
- pipe_buffer_reference( &buf,
+ pipe_resource_reference( &buf,
NULL );
}
@@ -407,10 +410,10 @@ void renderer_copy_surface(struct renderer *ctx,
{
struct pipe_context *pipe = ctx->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_buffer *buf;
+ struct pipe_resource *buf;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view;
- struct pipe_texture texTemp, *tex;
+ struct pipe_resource texTemp, *tex;
struct pipe_surface *texSurf;
struct pipe_framebuffer_state fb;
struct st_framebuffer *stfb = ctx->owner->draw_buffer;
@@ -437,11 +440,11 @@ void renderer_copy_surface(struct renderer *ctx,
}
assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ PIPE_BIND_SAMPLER_VIEW, 0));
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ PIPE_BIND_SAMPLER_VIEW, 0));
assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
+ PIPE_BIND_RENDER_TARGET, 0));
/*
* XXX for now we're always creating a temporary texture.
@@ -457,7 +460,7 @@ void renderer_copy_surface(struct renderer *ctx,
texTemp.height0 = srcH;
texTemp.depth0 = 1;
- tex = screen->texture_create(screen, &texTemp);
+ tex = screen->resource_create(screen, &texTemp);
if (!tex)
return;
@@ -468,7 +471,7 @@ void renderer_copy_surface(struct renderer *ctx,
return;
texSurf = screen->get_tex_surface(screen, tex, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
/* load temp texture */
if (pipe->surface_copy) {
@@ -554,7 +557,7 @@ void renderer_copy_surface(struct renderer *ctx,
4, /* verts */
2); /* attribs/vert */
- pipe_buffer_reference( &buf,
+ pipe_resource_reference( &buf,
NULL );
}
@@ -568,12 +571,12 @@ void renderer_copy_surface(struct renderer *ctx,
cso_restore_vertex_shader(ctx->cso);
cso_restore_viewport(ctx->cso);
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&tex, NULL);
pipe_sampler_view_reference(&view, NULL);
}
void renderer_texture_quad(struct renderer *r,
- struct pipe_texture *tex,
+ struct pipe_resource *tex,
VGfloat x1offset, VGfloat y1offset,
VGfloat x2offset, VGfloat y2offset,
VGfloat x1, VGfloat y1,
@@ -582,7 +585,7 @@ void renderer_texture_quad(struct renderer *r,
VGfloat x4, VGfloat y4)
{
struct pipe_context *pipe = r->pipe;
- struct pipe_buffer *buf;
+ struct pipe_resource *buf;
VGfloat s0, t0, s1, t1;
assert(tex->width0 != 0);
@@ -608,7 +611,7 @@ void renderer_texture_quad(struct renderer *r,
4, /* verts */
2); /* attribs/vert */
- pipe_buffer_reference(&buf,
+ pipe_resource_reference(&buf,
NULL);
}
diff --git a/src/gallium/state_trackers/vega/renderer.h b/src/gallium/state_trackers/vega/renderer.h
index 03366f1361..b1a9fb58be 100644
--- a/src/gallium/state_trackers/vega/renderer.h
+++ b/src/gallium/state_trackers/vega/renderer.h
@@ -32,7 +32,7 @@
struct renderer;
struct vg_context;
-struct pipe_texture;
+struct pipe_resource;
struct pipe_sampler_view;
struct pipe_surface;
@@ -44,13 +44,13 @@ void renderer_draw_quad(struct renderer *,
VGfloat x2, VGfloat y2,
VGfloat depth);
void renderer_draw_texture(struct renderer *,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
VGfloat x1offset, VGfloat y1offset,
VGfloat x2offset, VGfloat y2offset,
VGfloat x1, VGfloat y1,
VGfloat x2, VGfloat y2);
void renderer_texture_quad(struct renderer *,
- struct pipe_texture *texture,
+ struct pipe_resource *texture,
VGfloat x1offset, VGfloat y1offset,
VGfloat x2offset, VGfloat y2offset,
VGfloat x1, VGfloat y1,
@@ -61,7 +61,7 @@ void renderer_copy_texture(struct renderer *r,
struct pipe_sampler_view *src,
VGfloat sx1, VGfloat sy1,
VGfloat sx2, VGfloat sy2,
- struct pipe_texture *dst,
+ struct pipe_resource *dst,
VGfloat dx1, VGfloat dy1,
VGfloat dx2, VGfloat dy2);
void renderer_copy_surface(struct renderer *r,
diff --git a/src/gallium/state_trackers/vega/shader.c b/src/gallium/state_trackers/vega/shader.c
index f2ec24c57f..6eef94ce76 100644
--- a/src/gallium/state_trackers/vega/shader.c
+++ b/src/gallium/state_trackers/vega/shader.c
@@ -51,7 +51,7 @@ struct shader {
VGImageMode image_mode;
float constants[MAX_CONSTANTS];
- struct pipe_buffer *cbuf;
+ struct pipe_resource *cbuf;
struct pipe_shader_state fs_state;
void *fs;
};
@@ -96,7 +96,7 @@ static void setup_constant_buffer(struct shader *shader)
{
struct vg_context *ctx = shader->context;
struct pipe_context *pipe = shader->context->pipe;
- struct pipe_buffer **cbuf = &shader->cbuf;
+ struct pipe_resource **cbuf = &shader->cbuf;
VGint param_bytes = paint_constant_buffer_size(shader->paint);
float temp_buf[MAX_CONSTANTS];
@@ -106,12 +106,13 @@ static void setup_constant_buffer(struct shader *shader)
if (*cbuf == NULL ||
memcmp(temp_buf, shader->constants, param_bytes) != 0)
{
- pipe_buffer_reference(cbuf, NULL);
+ pipe_resource_reference(cbuf, NULL);
memcpy(shader->constants, temp_buf, param_bytes);
*cbuf = pipe_user_buffer_create(pipe->screen,
&shader->constants,
- sizeof(shader->constants));
+ sizeof(shader->constants),
+ PIPE_BIND_VERTEX_BUFFER);
}
ctx->pipe->set_constant_buffer(ctx->pipe, PIPE_SHADER_FRAGMENT, 0, *cbuf);
diff --git a/src/gallium/state_trackers/vega/st_inlines.h b/src/gallium/state_trackers/vega/st_inlines.h
index 4d12a4efdd..7eaa67c76a 100644
--- a/src/gallium/state_trackers/vega/st_inlines.h
+++ b/src/gallium/state_trackers/vega/st_inlines.h
@@ -42,8 +42,8 @@
#include "pipe/p_state.h"
static INLINE struct pipe_transfer *
-st_cond_flush_get_tex_transfer(struct vg_context *st,
- struct pipe_texture *pt,
+st_cond_flush_get_transfer(struct vg_context *st,
+ struct pipe_resource *pt,
unsigned int face,
unsigned int level,
unsigned int zslice,
@@ -52,20 +52,14 @@ st_cond_flush_get_tex_transfer(struct vg_context *st,
unsigned int w, unsigned int h)
{
struct pipe_context *pipe = st->pipe;
- unsigned referenced =
- pipe->is_texture_referenced(pipe, pt, face, level);
- if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
- (usage & PIPE_TRANSFER_WRITE)))
- vgFlush();
-
- return pipe->get_tex_transfer(pipe, pt, face, level, zslice, usage,
- x, y, w, h);
+ return pipe_get_transfer(pipe, pt, face, level, zslice, usage,
+ x, y, w, h);
}
static INLINE struct pipe_transfer *
-st_no_flush_get_tex_transfer(struct vg_context *st,
- struct pipe_texture *pt,
+st_no_flush_get_transfer(struct vg_context *st,
+ struct pipe_resource *pt,
unsigned int face,
unsigned int level,
unsigned int zslice,
@@ -75,82 +69,53 @@ st_no_flush_get_tex_transfer(struct vg_context *st,
{
struct pipe_context *pipe = st->pipe;
- return pipe->get_tex_transfer(pipe, pt, face, level,
- zslice, usage, x, y, w, h);
-}
-
-static INLINE void *
-st_cond_flush_pipe_buffer_map(struct vg_context *st,
- struct pipe_buffer *buf,
- unsigned int map_flags)
-{
- struct pipe_context *pipe = st->pipe;
- unsigned int referenced = pipe->is_buffer_referenced(pipe, buf);
-
- if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
- (map_flags & PIPE_BUFFER_USAGE_CPU_WRITE)))
- vgFlush();
-
- return pipe_buffer_map(pipe->screen, buf, map_flags);
-}
-
-static INLINE void *
-st_no_flush_pipe_buffer_map(struct vg_context *st,
- struct pipe_buffer *buf,
- unsigned int map_flags)
-{
- return pipe_buffer_map(st->pipe->screen, buf, map_flags);
+ return pipe_get_transfer(pipe, pt, face, level,
+ zslice, usage, x, y, w, h);
}
static INLINE void
st_cond_flush_pipe_buffer_write(struct vg_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
const void * data)
{
struct pipe_context *pipe = st->pipe;
- if (pipe->is_buffer_referenced(pipe, buf))
- vgFlush();
-
- pipe_buffer_write(pipe->screen, buf, offset, size, data);
+ pipe_buffer_write(pipe, buf, offset, size, data);
}
static INLINE void
st_no_flush_pipe_buffer_write(struct vg_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
const void * data)
{
- pipe_buffer_write(st->pipe->screen, buf, offset, size, data);
+ pipe_buffer_write(st->pipe, buf, offset, size, data);
}
static INLINE void
st_cond_flush_pipe_buffer_read(struct vg_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
void * data)
{
struct pipe_context *pipe = st->pipe;
- if (pipe->is_buffer_referenced(pipe, buf) & PIPE_REFERENCED_FOR_WRITE)
- vgFlush();
-
- pipe_buffer_read(pipe->screen, buf, offset, size, data);
+ pipe_buffer_read(pipe, buf, offset, size, data);
}
static INLINE void
st_no_flush_pipe_buffer_read(struct vg_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
void * data)
{
- pipe_buffer_read(st->pipe->screen, buf, offset, size, data);
+ pipe_buffer_read(st->pipe, buf, offset, size, data);
}
#endif
diff --git a/src/gallium/state_trackers/vega/vg_context.c b/src/gallium/state_trackers/vega/vg_context.c
index 11ebbbe544..1a8952ce34 100644
--- a/src/gallium/state_trackers/vega/vg_context.c
+++ b/src/gallium/state_trackers/vega/vg_context.c
@@ -132,8 +132,8 @@ struct vg_context * vg_create_context(struct pipe_context *pipe,
void vg_destroy_context(struct vg_context *ctx)
{
- struct pipe_buffer **cbuf = &ctx->mask.cbuf;
- struct pipe_buffer **vsbuf = &ctx->vs_const_buffer;
+ struct pipe_resource **cbuf = &ctx->mask.cbuf;
+ struct pipe_resource **vsbuf = &ctx->vs_const_buffer;
util_destroy_blit(ctx->blit);
renderer_destroy(ctx->renderer);
@@ -142,10 +142,10 @@ void vg_destroy_context(struct vg_context *ctx)
paint_destroy(ctx->default_paint);
if (*cbuf)
- pipe_buffer_reference(cbuf, NULL);
+ pipe_resource_reference(cbuf, NULL);
if (*vsbuf)
- pipe_buffer_reference(vsbuf, NULL);
+ pipe_resource_reference(vsbuf, NULL);
if (ctx->clear.fs) {
cso_delete_fragment_shader(ctx->cso_context, ctx->clear.fs);
@@ -381,14 +381,14 @@ void vg_validate_state(struct vg_context *ctx)
2.f/fb->width, 2.f/fb->height, 1, 1,
-1, -1, 0, 0
};
- struct pipe_buffer **cbuf = &ctx->vs_const_buffer;
+ struct pipe_resource **cbuf = &ctx->vs_const_buffer;
vg_set_viewport(ctx, VEGA_Y0_BOTTOM);
- pipe_buffer_reference(cbuf, NULL);
- *cbuf = pipe_buffer_create(ctx->pipe->screen, 16,
- PIPE_BUFFER_USAGE_CONSTANT,
- param_bytes);
+ pipe_resource_reference(cbuf, NULL);
+ *cbuf = pipe_buffer_create(ctx->pipe->screen,
+ PIPE_BIND_CONSTANT_BUFFER,
+ param_bytes);
if (*cbuf) {
st_no_flush_pipe_buffer_write(ctx, *cbuf,
@@ -451,7 +451,8 @@ void vg_prepare_blend_surface(struct vg_context *ctx)
dest_surface = pipe->screen->get_tex_surface(pipe->screen,
stfb->blend_texture_view->texture,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION |
+ PIPE_BIND_RENDER_TARGET);
/* flip it, because we want to use it as a sampler */
util_blit_pixels_tex(ctx->blit,
view,
@@ -487,7 +488,8 @@ void vg_prepare_blend_surface_from_mask(struct vg_context *ctx)
dest_surface = pipe->screen->get_tex_surface(pipe->screen,
stfb->blend_texture_view->texture,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION |
+ PIPE_BIND_RENDER_TARGET);
/* flip it, because we want to use it as a sampler */
util_blit_pixels_tex(ctx->blit,
diff --git a/src/gallium/state_trackers/vega/vg_context.h b/src/gallium/state_trackers/vega/vg_context.h
index c9e36d7d76..dac67192a5 100644
--- a/src/gallium/state_trackers/vega/vg_context.h
+++ b/src/gallium/state_trackers/vega/vg_context.h
@@ -46,7 +46,7 @@ struct vg_shader;
struct st_renderbuffer {
enum pipe_format format;
struct pipe_surface *surface;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
VGint width, height;
};
@@ -121,7 +121,7 @@ struct vg_context
} clear;
struct {
- struct pipe_buffer *cbuf;
+ struct pipe_resource *cbuf;
struct pipe_sampler_state sampler;
struct vg_shader *union_fs;
@@ -134,7 +134,7 @@ struct vg_context
struct cso_context *cso_context;
- struct pipe_buffer *stencil_quad;
+ struct pipe_resource *stencil_quad;
VGfloat stencil_vertices[4][2][4];
struct renderer *renderer;
@@ -143,7 +143,7 @@ struct vg_context
struct pipe_sampler_state blend_sampler;
struct {
- struct pipe_buffer *buffer;
+ struct pipe_resource *buffer;
void *color_matrix_fs;
} filter;
struct vg_paint *default_paint;
@@ -153,7 +153,7 @@ struct vg_context
struct vg_shader *plain_vs;
struct vg_shader *clear_vs;
struct vg_shader *texture_vs;
- struct pipe_buffer *vs_const_buffer;
+ struct pipe_resource *vs_const_buffer;
struct pipe_vertex_element velems[2];
};
diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c
index 7bc0006769..256c23775e 100644
--- a/src/gallium/state_trackers/vega/vg_manager.c
+++ b/src/gallium/state_trackers/vega/vg_manager.c
@@ -78,7 +78,7 @@ vg_manager_validate_framebuffer(struct vg_context *ctx)
struct pipe_screen *screen = ctx->pipe->screen;
struct st_framebuffer *stfb = ctx->draw_buffer;
struct st_renderbuffer *rb;
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
/* no binding surface */
if (!stfb)
@@ -101,17 +101,19 @@ vg_manager_validate_framebuffer(struct vg_context *ctx)
rb = stfb->strb;
if (rb->texture == pt) {
- pipe_texture_reference(&pt, NULL);
+ pipe_resource_reference(&pt, NULL);
return;
}
/* unreference existing ones */
pipe_surface_reference(&rb->surface, NULL);
- pipe_texture_reference(&rb->texture, NULL);
+ pipe_resource_reference(&rb->texture, NULL);
rb->texture = pt;
rb->surface = screen->get_tex_surface(screen, rb->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION);
rb->width = rb->surface->width;
rb->height = rb->surface->height;
@@ -195,7 +197,7 @@ static void
destroy_renderbuffer(struct st_renderbuffer *strb)
{
pipe_surface_reference(&strb->surface, NULL);
- pipe_texture_reference(&strb->texture, NULL);
+ pipe_resource_reference(&strb->texture, NULL);
free(strb);
}
diff --git a/src/gallium/state_trackers/vega/vg_tracker.c b/src/gallium/state_trackers/vega/vg_tracker.c
index 108dd6a975..117c6d3977 100644
--- a/src/gallium/state_trackers/vega/vg_tracker.c
+++ b/src/gallium/state_trackers/vega/vg_tracker.c
@@ -40,11 +40,11 @@
/* advertise OpenVG support */
PUBLIC const int st_api_OpenVG = 1;
-static struct pipe_texture *
+static struct pipe_resource *
create_texture(struct pipe_context *pipe, enum pipe_format format,
VGint width, VGint height)
{
- struct pipe_texture templ;
+ struct pipe_resource templ;
memset(&templ, 0, sizeof(templ));
@@ -62,21 +62,21 @@ create_texture(struct pipe_context *pipe, enum pipe_format format,
templ.last_level = 0;
if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) {
- templ.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ templ.bind = PIPE_BIND_DEPTH_STENCIL;
} else {
- templ.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_RENDER_TARGET |
- PIPE_TEXTURE_USAGE_SAMPLER);
+ templ.bind = (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_SAMPLER_VIEW);
}
- return pipe->screen->texture_create(pipe->screen, &templ);
+ return pipe->screen->resource_create(pipe->screen, &templ);
}
static struct pipe_sampler_view *
create_tex_and_view(struct pipe_context *pipe, enum pipe_format format,
VGint width, VGint height)
{
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *view;
@@ -88,7 +88,7 @@ create_tex_and_view(struct pipe_context *pipe, enum pipe_format format,
u_sampler_view_default_template(&view_templ, texture, texture->format);
view = pipe->create_sampler_view(pipe, texture, &view_templ);
/* want the texture to go away if the view is freed */
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
return view;
}
@@ -129,13 +129,14 @@ st_renderbuffer_alloc_storage(struct vg_context * ctx,
/* Free the old surface and texture
*/
pipe_surface_reference(&strb->surface, NULL);
- pipe_texture_reference(&strb->texture, NULL);
+ pipe_resource_reference(&strb->texture, NULL);
/* Probably need dedicated flags for surface usage too:
*/
- surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ surface_usage = (PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION);
strb->texture = create_texture(pipe, strb->format, width, height);
@@ -255,12 +256,13 @@ static void setup_new_alpha_mask(struct vg_context *ctx,
pipe->screen,
stfb->alpha_mask_view->texture,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_DESTINATION);
struct pipe_surface *old_surface = pipe->screen->get_tex_surface(
pipe->screen,
old_sampler_view->texture,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BIND_BLIT_SOURCE);
if (pipe->surface_copy) {
pipe->surface_copy(pipe,
surface,
@@ -360,11 +362,11 @@ void st_set_framebuffer_surface(struct st_framebuffer *stfb,
/* unreference existing surfaces */
pipe_surface_reference( &rb->surface, NULL );
- pipe_texture_reference( &rb->texture, NULL );
+ pipe_resource_reference( &rb->texture, NULL );
/* reference new ones */
pipe_surface_reference( &rb->surface, surf );
- pipe_texture_reference( &rb->texture, surf->texture );
+ pipe_resource_reference( &rb->texture, surf->texture );
rb->width = surf->width;
rb->height = surf->height;
@@ -379,7 +381,7 @@ int st_get_framebuffer_surface(struct st_framebuffer *stfb,
}
int st_get_framebuffer_texture(struct st_framebuffer *stfb,
- uint surfIndex, struct pipe_texture **tex)
+ uint surfIndex, struct pipe_resource **tex)
{
struct st_renderbuffer *rb = stfb->strb;
*tex = rb->texture;
diff --git a/src/gallium/state_trackers/vega/vg_tracker.h b/src/gallium/state_trackers/vega/vg_tracker.h
index 165a6b7a33..c16d55fc34 100644
--- a/src/gallium/state_trackers/vega/vg_tracker.h
+++ b/src/gallium/state_trackers/vega/vg_tracker.h
@@ -90,7 +90,7 @@ int st_get_framebuffer_surface(struct st_framebuffer *stfb,
PUBLIC
int st_get_framebuffer_texture(struct st_framebuffer *stfb,
- uint surfIndex, struct pipe_texture **tex);
+ uint surfIndex, struct pipe_resource **tex);
PUBLIC
void *st_framebuffer_private(struct st_framebuffer *stfb);
diff --git a/src/gallium/state_trackers/wgl/stw_pixelformat.c b/src/gallium/state_trackers/wgl/stw_pixelformat.c
index 02ff89a388..a07de994ca 100644
--- a/src/gallium/state_trackers/wgl/stw_pixelformat.c
+++ b/src/gallium/state_trackers/wgl/stw_pixelformat.c
@@ -218,8 +218,8 @@ stw_pixelformat_init( void )
const struct stw_pf_color_info *color = &stw_pf_color[j];
if(!screen->is_format_supported(screen, color->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET |
- PIPE_TEXTURE_USAGE_DISPLAY_TARGET, 0))
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_DISPLAY_TARGET, 0))
continue;
for(k = 0; k < Elements(stw_pf_doublebuffer); ++k) {
@@ -229,7 +229,7 @@ stw_pixelformat_init( void )
const struct stw_pf_depth_info *depth = &stw_pf_depth_stencil[l];
if(!screen->is_format_supported(screen, depth->format, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0))
+ PIPE_BIND_DEPTH_STENCIL, 0))
continue;
stw_pixelformat_add( stw_dev, color, depth, 0, doublebuffer, samples );
diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
index eef428232b..669bd9edcf 100644
--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
@@ -62,7 +62,7 @@ struct crtc_private
drmModeCrtcPtr drm_crtc;
/* hwcursor */
- struct pipe_texture *cursor_tex;
+ struct pipe_resource *cursor_tex;
struct kms_bo *cursor_bo;
unsigned cursor_handle;
@@ -197,12 +197,12 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
struct pipe_transfer *transfer;
if (!crtcp->cursor_tex) {
- struct pipe_texture templat;
+ struct pipe_resource templat;
struct winsys_handle whandle;
memset(&templat, 0, sizeof(templat));
- templat.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
- templat.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT;
+ templat.bind |= PIPE_BIND_RENDER_TARGET;
+ templat.bind |= PIPE_BIND_SCANOUT;
templat.target = PIPE_TEXTURE_2D;
templat.last_level = 0;
templat.depth0 = 1;
@@ -213,14 +213,14 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_KMS;
- crtcp->cursor_tex = ms->screen->texture_create(ms->screen,
+ crtcp->cursor_tex = ms->screen->resource_create(ms->screen,
&templat);
- ms->screen->texture_get_handle(ms->screen, crtcp->cursor_tex, &whandle);
+ ms->screen->resource_get_handle(ms->screen, crtcp->cursor_tex, &whandle);
crtcp->cursor_handle = whandle.handle;
}
- transfer = ms->ctx->get_tex_transfer(ms->ctx, crtcp->cursor_tex,
+ transfer = pipe_get_transfer(ms->ctx, crtcp->cursor_tex,
0, 0, 0,
PIPE_TRANSFER_WRITE,
0, 0, 64, 64);
@@ -229,7 +229,7 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
transfer->stride, 0, 0,
64, 64, (void*)image, 64 * 4, 0, 0);
ms->ctx->transfer_unmap(ms->ctx, transfer);
- ms->ctx->tex_transfer_destroy(ms->ctx, transfer);
+ ms->ctx->transfer_destroy(ms->ctx, transfer);
}
#if HAVE_LIBKMS
@@ -329,7 +329,7 @@ xorg_crtc_cursor_destroy(xf86CrtcPtr crtc)
struct crtc_private *crtcp = crtc->driver_private;
if (crtcp->cursor_tex)
- pipe_texture_reference(&crtcp->cursor_tex, NULL);
+ pipe_resource_reference(&crtcp->cursor_tex, NULL);
#ifdef HAVE_LIBKMS
if (crtcp->cursor_bo)
kms_bo_destroy(&crtcp->cursor_bo);
diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
index 91c251bb4f..b90f9c908d 100644
--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
@@ -53,14 +53,14 @@ static Bool set_format_in_do_create_buffer;
typedef struct {
PixmapPtr pPixmap;
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
struct pipe_fence_handle *fence;
} *BufferPrivatePtr;
static Bool
dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format)
{
- struct pipe_texture *tex = NULL;
+ struct pipe_resource *tex = NULL;
ScreenPtr pScreen = pDraw->pScreen;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
modesettingPtr ms = modesettingPTR(pScrn);
@@ -101,9 +101,9 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
/* Fall through */
case DRI2BufferDepth:
if (exa_priv->depth_stencil_tex)
- pipe_texture_reference(&tex, exa_priv->depth_stencil_tex);
+ pipe_resource_reference(&tex, exa_priv->depth_stencil_tex);
else {
- struct pipe_texture template;
+ struct pipe_resource template;
unsigned depthBits = (format != 0) ? format : pDraw->depth;
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
@@ -128,10 +128,10 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
template.height0 = pDraw->height;
template.depth0 = 1;
template.last_level = 0;
- template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
- PIPE_TEXTURE_USAGE_SHARED;
- tex = ms->screen->texture_create(ms->screen, &template);
- pipe_texture_reference(&exa_priv->depth_stencil_tex, tex);
+ template.bind = PIPE_BIND_DEPTH_STENCIL |
+ PIPE_BIND_SHARED;
+ tex = ms->screen->resource_create(ms->screen, &template);
+ pipe_resource_reference(&exa_priv->depth_stencil_tex, tex);
}
break;
}
@@ -157,7 +157,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int form
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_SHARED;
- ms->screen->texture_get_handle(ms->screen, tex, &whandle);
+ ms->screen->resource_get_handle(ms->screen, tex, &whandle);
buffer->name = whandle.handle;
buffer->pitch = whandle.stride;
@@ -185,9 +185,9 @@ dri2_do_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
BufferPrivatePtr private = buffer->driverPrivate;
struct exa_pixmap_priv *exa_priv = exaGetPixmapDriverPrivate(private->pPixmap);
- pipe_texture_reference(&private->tex, NULL);
+ pipe_resource_reference(&private->tex, NULL);
ms->screen->fence_reference(ms->screen, &private->fence, NULL);
- pipe_texture_reference(&exa_priv->depth_stencil_tex, NULL);
+ pipe_resource_reference(&exa_priv->depth_stencil_tex, NULL);
(*pScreen->DestroyPixmap)(private->pPixmap);
}
@@ -437,11 +437,11 @@ xorg_dri2_init(ScreenPtr pScreen)
ms->d_depth_bits_last =
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24X8_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
ms->ds_depth_bits_last =
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0);
+ PIPE_BIND_DEPTH_STENCIL, 0);
return DRI2ScreenInit(pScreen, &dri2info);
}
diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
index a59e8dcad5..3687ee0db4 100644
--- a/src/gallium/state_trackers/xorg/xorg_driver.c
+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
@@ -985,7 +985,7 @@ drv_destroy_front_buffer_ga3d(ScrnInfoPtr pScrn)
ms->fb_id = -1;
}
- pipe_texture_reference(&ms->root_texture, NULL);
+ pipe_resource_reference(&ms->root_texture, NULL);
return TRUE;
}
@@ -993,7 +993,7 @@ static Bool
drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
struct winsys_handle whandle;
unsigned fb_id;
int ret;
@@ -1009,7 +1009,7 @@ drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn)
memset(&whandle, 0, sizeof(whandle));
whandle.type = DRM_API_HANDLE_TYPE_KMS;
- if (!ms->screen->texture_get_handle(ms->screen, tex, &whandle))
+ if (!ms->screen->resource_get_handle(ms->screen, tex, &whandle))
goto err_destroy;
ret = drmModeAddFB(ms->fd,
@@ -1033,14 +1033,14 @@ drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn)
pScrn->frameY0 = 0;
drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
- pipe_texture_reference(&ms->root_texture, tex);
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&ms->root_texture, tex);
+ pipe_resource_reference(&tex, NULL);
ms->fb_id = fb_id;
return TRUE;
err_destroy:
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&tex, NULL);
return FALSE;
}
@@ -1050,7 +1050,7 @@ drv_bind_front_buffer_ga3d(ScrnInfoPtr pScrn)
modesettingPtr ms = modesettingPTR(pScrn);
ScreenPtr pScreen = pScrn->pScreen;
PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen);
- struct pipe_texture *check;
+ struct pipe_resource *check;
xorg_exa_set_displayed_usage(rootPixmap);
xorg_exa_set_shared_usage(rootPixmap);
@@ -1062,7 +1062,7 @@ drv_bind_front_buffer_ga3d(ScrnInfoPtr pScrn)
if (ms->root_texture != check)
FatalError("Created new root texture\n");
- pipe_texture_reference(&check, NULL);
+ pipe_resource_reference(&check, NULL);
return TRUE;
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
index 76e6411bb8..d5a1be8174 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.c
+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
@@ -188,7 +188,7 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst,
if (!priv || !priv->tex)
return FALSE;
- transfer = exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0,
+ transfer = pipe_get_transfer(exa->pipe, priv->tex, 0, 0, 0,
PIPE_TRANSFER_READ, x, y, w, h);
if (!transfer)
return FALSE;
@@ -203,7 +203,7 @@ ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst,
transfer->stride, 0, 0);
exa->pipe->transfer_unmap(exa->pipe, transfer);
- exa->pipe->tex_transfer_destroy(exa->pipe, transfer);
+ exa->pipe->transfer_destroy(exa->pipe, transfer);
return TRUE;
}
@@ -222,7 +222,7 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
if (!priv || !priv->tex)
return FALSE;
- transfer = exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0,
+ transfer = pipe_get_transfer(exa->pipe, priv->tex, 0, 0, 0,
PIPE_TRANSFER_WRITE, x, y, w, h);
if (!transfer)
return FALSE;
@@ -237,7 +237,7 @@ ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src,
(unsigned char*)src, src_pitch, 0, 0);
exa->pipe->transfer_unmap(exa->pipe, transfer);
- exa->pipe->tex_transfer_destroy(exa->pipe, transfer);
+ exa->pipe->transfer_destroy(exa->pipe, transfer);
return TRUE;
}
@@ -265,7 +265,7 @@ ExaPrepareAccess(PixmapPtr pPix, int index)
assert(pPix->drawable.height <= priv->tex->height0);
priv->map_transfer =
- exa->pipe->get_tex_transfer(exa->pipe, priv->tex, 0, 0, 0,
+ pipe_get_transfer(exa->pipe, priv->tex, 0, 0, 0,
#ifdef EXA_MIXED_PIXMAPS
PIPE_TRANSFER_MAP_DIRECTLY |
#endif
@@ -309,7 +309,7 @@ ExaFinishAccess(PixmapPtr pPix, int index)
if (--priv->map_count == 0) {
assert(priv->map_transfer);
exa->pipe->transfer_unmap(exa->pipe, priv->map_transfer);
- exa->pipe->tex_transfer_destroy(exa->pipe, priv->map_transfer);
+ exa->pipe->transfer_destroy(exa->pipe, priv->map_transfer);
priv->map_transfer = NULL;
pPix->devPrivate.ptr = NULL;
}
@@ -347,7 +347,7 @@ ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg)
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
priv->tex->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
XORG_FALLBACK("format %s", util_format_name(priv->tex->format));
}
@@ -428,12 +428,12 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
priv->tex->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
+ PIPE_BIND_RENDER_TARGET, 0))
XORG_FALLBACK("pDst format %s", util_format_name(priv->tex->format));
if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format,
src_priv->tex->target,
- PIPE_TEXTURE_USAGE_SAMPLER, 0))
+ PIPE_BIND_SAMPLER_VIEW, 0))
XORG_FALLBACK("pSrc format %s", util_format_name(src_priv->tex->format));
exa->copy.src = src_priv;
@@ -453,13 +453,13 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
exa->scrn->get_tex_surface( exa->scrn,
exa->copy.src->tex,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BIND_BLIT_SOURCE);
exa->copy.dst_surface =
exa->scrn->get_tex_surface( exa->scrn,
exa->copy.dst->tex,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE );
+ PIPE_BIND_BLIT_DESTINATION );
}
else {
exa->copy.use_surface_copy = FALSE;
@@ -468,14 +468,14 @@ ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir,
exa->copy.src_texture = renderer_clone_texture( exa->renderer,
exa->copy.src->tex );
else
- pipe_texture_reference(&exa->copy.src_texture,
+ pipe_resource_reference(&exa->copy.src_texture,
exa->copy.src->tex);
exa->copy.dst_surface =
exa->scrn->get_tex_surface(exa->scrn,
exa->copy.dst->tex,
0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION);
renderer_copy_prepare(exa->renderer,
@@ -541,7 +541,7 @@ ExaDoneCopy(PixmapPtr pPixmap)
exa->copy.dst = NULL;
pipe_surface_reference(&exa->copy.src_surface, NULL);
pipe_surface_reference(&exa->copy.dst_surface, NULL);
- pipe_texture_reference(&exa->copy.src_texture, NULL);
+ pipe_resource_reference(&exa->copy.src_texture, NULL);
}
@@ -639,7 +639,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
priv->tex->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))
+ PIPE_BIND_RENDER_TARGET, 0))
XORG_FALLBACK("pDst format: %s", util_format_name(priv->tex->format));
if (priv->picture_format != pDstPicture->format)
@@ -654,7 +654,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
priv->tex->target,
- PIPE_TEXTURE_USAGE_SAMPLER, 0))
+ PIPE_BIND_SAMPLER_VIEW, 0))
XORG_FALLBACK("pSrc format: %s", util_format_name(priv->tex->format));
if (!picture_check_formats(priv, pSrcPicture))
@@ -671,7 +671,7 @@ ExaPrepareComposite(int op, PicturePtr pSrcPicture,
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format,
priv->tex->target,
- PIPE_TEXTURE_USAGE_SAMPLER, 0))
+ PIPE_BIND_SAMPLER_VIEW, 0))
XORG_FALLBACK("pMask format: %s", util_format_name(priv->tex->format));
if (!picture_check_formats(priv, pMaskPicture))
@@ -744,7 +744,7 @@ ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv)
if (!priv)
return;
- pipe_texture_reference(&priv->tex, NULL);
+ pipe_resource_reference(&priv->tex, NULL);
xfree(priv);
}
@@ -776,7 +776,7 @@ xorg_exa_set_displayed_usage(PixmapPtr pPixmap)
return 0;
}
- priv->flags |= PIPE_TEXTURE_USAGE_SCANOUT;
+ priv->flags |= PIPE_BIND_SCANOUT;
return 0;
}
@@ -792,7 +792,7 @@ xorg_exa_set_shared_usage(PixmapPtr pPixmap)
return 0;
}
- priv->flags |= PIPE_TEXTURE_USAGE_SHARED;
+ priv->flags |= PIPE_BIND_SHARED;
return 0;
}
@@ -867,8 +867,8 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
!size_match(width, priv->tex->width0) ||
!size_match(height, priv->tex->height0) ||
priv->tex_flags != priv->flags)) {
- struct pipe_texture *texture = NULL;
- struct pipe_texture template;
+ struct pipe_resource *texture = NULL;
+ struct pipe_resource template;
memset(&template, 0, sizeof(template));
template.target = PIPE_TEXTURE_2D;
@@ -884,16 +884,16 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
template.depth0 = 1;
template.last_level = 0;
- template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET | priv->flags;
+ template.bind = PIPE_BIND_RENDER_TARGET | priv->flags;
priv->tex_flags = priv->flags;
- texture = exa->scrn->texture_create(exa->scrn, &template);
+ texture = exa->scrn->resource_create(exa->scrn, &template);
if (priv->tex) {
struct pipe_surface *dst_surf;
struct pipe_surface *src_surf;
dst_surf = exa->scrn->get_tex_surface(
- exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
+ exa->scrn, texture, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION);
src_surf = xorg_gpu_surface(exa->pipe->screen, priv);
if (exa->pipe->surface_copy) {
exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
@@ -908,29 +908,29 @@ ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height,
exa->scrn->tex_surface_destroy(src_surf);
}
- pipe_texture_reference(&priv->tex, texture);
+ pipe_resource_reference(&priv->tex, texture);
/* the texture we create has one reference */
- pipe_texture_reference(&texture, NULL);
+ pipe_resource_reference(&texture, NULL);
}
return TRUE;
}
-struct pipe_texture *
+struct pipe_resource *
xorg_exa_get_texture(PixmapPtr pPixmap)
{
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
- struct pipe_texture *tex = NULL;
- pipe_texture_reference(&tex, priv->tex);
+ struct pipe_resource *tex = NULL;
+ pipe_resource_reference(&tex, priv->tex);
return tex;
}
Bool
-xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_texture *tex)
+xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_resource *tex)
{
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
- int mask = PIPE_TEXTURE_USAGE_SHARED | PIPE_TEXTURE_USAGE_SCANOUT;
+ int mask = PIPE_BIND_SHARED | PIPE_BIND_SCANOUT;
if (!priv)
return FALSE;
@@ -939,20 +939,20 @@ xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_texture *tex)
pPixmap->drawable.height != tex->height0)
return FALSE;
- pipe_texture_reference(&priv->tex, tex);
- priv->tex_flags = tex->tex_usage & mask;
+ pipe_resource_reference(&priv->tex, tex);
+ priv->tex_flags = tex->bind & mask;
return TRUE;
}
-struct pipe_texture *
+struct pipe_resource *
xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
int width, int height,
int depth, int bitsPerPixel)
{
modesettingPtr ms = modesettingPTR(pScrn);
struct exa_context *exa = ms->exa;
- struct pipe_texture template;
+ struct pipe_resource template;
int dummy;
memset(&template, 0, sizeof(template));
@@ -962,11 +962,11 @@ xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
template.height0 = height;
template.depth0 = 1;
template.last_level = 0;
- template.tex_usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
- template.tex_usage |= PIPE_TEXTURE_USAGE_SCANOUT;
- template.tex_usage |= PIPE_TEXTURE_USAGE_SHARED;
+ template.bind |= PIPE_BIND_RENDER_TARGET;
+ template.bind |= PIPE_BIND_SCANOUT;
+ template.bind |= PIPE_BIND_SHARED;
- return exa->scrn->texture_create(exa->scrn, &template);
+ return exa->scrn->resource_create(exa->scrn, &template);
}
void
@@ -1073,9 +1073,12 @@ out_err:
struct pipe_surface *
xorg_gpu_surface(struct pipe_screen *scrn, struct exa_pixmap_priv *priv)
{
+
+ /* seems to get called both for blits and render target usage */
return scrn->get_tex_surface(scrn, priv->tex, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION |
+ PIPE_BIND_RENDER_TARGET);
}
diff --git a/src/gallium/state_trackers/xorg/xorg_exa.h b/src/gallium/state_trackers/xorg/xorg_exa.h
index 41b1906159..a35e9a5c90 100644
--- a/src/gallium/state_trackers/xorg/xorg_exa.h
+++ b/src/gallium/state_trackers/xorg/xorg_exa.h
@@ -43,7 +43,7 @@ struct exa_context
struct pipe_surface *src_surface;
struct pipe_surface *dst_surface;
- struct pipe_texture *src_texture;
+ struct pipe_resource *src_texture;
} copy;
};
@@ -56,8 +56,8 @@ struct exa_pixmap_priv
int picture_format;
- struct pipe_texture *tex;
- struct pipe_texture *depth_stencil_tex;
+ struct pipe_resource *tex;
+ struct pipe_resource *depth_stencil_tex;
struct pipe_transfer *map_transfer;
unsigned map_count;
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.c b/src/gallium/state_trackers/xorg/xorg_renderer.c
index 81b0dcf656..13fa561390 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.c
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.c
@@ -42,14 +42,16 @@ static INLINE void map_point(float *mat, float x, float y,
}
}
-static INLINE struct pipe_buffer *
+static INLINE struct pipe_resource *
renderer_buffer_create(struct xorg_renderer *r)
{
- struct pipe_buffer *buf =
+ struct pipe_resource *buf =
pipe_user_buffer_create(r->pipe->screen,
r->buffer,
sizeof(float)*
- r->buffer_size);
+ r->buffer_size,
+/* XXX was: PIPE_BUFFER_USAGE_PIXEL/PIPE_BUFFER_USAGE_GPU_WRITE even though this is a vertex buffer??? */
+ PIPE_BIND_VERTEX_BUFFER);
r->buffer_size = 0;
return buf;
@@ -59,7 +61,7 @@ static INLINE void
renderer_draw(struct xorg_renderer *r)
{
struct pipe_context *pipe = r->pipe;
- struct pipe_buffer *buf = 0;
+ struct pipe_resource *buf = 0;
int num_verts = r->buffer_size/(r->attrs_per_vertex * NUM_COMPONENTS);
if (!r->buffer_size)
@@ -76,7 +78,7 @@ renderer_draw(struct xorg_renderer *r)
num_verts, /* verts */
r->attrs_per_vertex); /* attribs/vert */
- pipe_buffer_reference(&buf, NULL);
+ pipe_resource_reference(&buf, NULL);
}
}
@@ -161,7 +163,7 @@ static void
add_vertex_data1(struct xorg_renderer *r,
float srcX, float srcY, float dstX, float dstY,
float width, float height,
- struct pipe_texture *src, float *src_matrix)
+ struct pipe_resource *src, float *src_matrix)
{
float s0, t0, s1, t1, s2, t2, s3, t3;
float pt0[2], pt1[2], pt2[2], pt3[2];
@@ -231,8 +233,8 @@ static void
add_vertex_data2(struct xorg_renderer *r,
float srcX, float srcY, float maskX, float maskY,
float dstX, float dstY, float width, float height,
- struct pipe_texture *src,
- struct pipe_texture *mask,
+ struct pipe_resource *src,
+ struct pipe_resource *mask,
float *src_matrix, float *mask_matrix)
{
float src_s0, src_t0, src_s1, src_t1;
@@ -284,11 +286,11 @@ add_vertex_data2(struct xorg_renderer *r,
src_s0, src_t1, mask_s0, mask_t1);
}
-static struct pipe_buffer *
+static struct pipe_resource *
setup_vertex_data_yuv(struct xorg_renderer *r,
float srcX, float srcY, float srcW, float srcH,
float dstX, float dstY, float dstW, float dstH,
- struct pipe_texture **tex)
+ struct pipe_resource **tex)
{
float s0, t0, s1, t1;
float spt0[2], spt1[2];
@@ -390,14 +392,14 @@ struct xorg_renderer * renderer_create(struct pipe_context *pipe)
void renderer_destroy(struct xorg_renderer *r)
{
- struct pipe_buffer **vsbuf = &r->vs_const_buffer;
- struct pipe_buffer **fsbuf = &r->fs_const_buffer;
+ struct pipe_resource **vsbuf = &r->vs_const_buffer;
+ struct pipe_resource **fsbuf = &r->fs_const_buffer;
if (*vsbuf)
- pipe_buffer_reference(vsbuf, NULL);
+ pipe_resource_reference(vsbuf, NULL);
if (*fsbuf)
- pipe_buffer_reference(fsbuf, NULL);
+ pipe_resource_reference(fsbuf, NULL);
if (r->shaders) {
xorg_shaders_destroy(r->shaders);
@@ -420,17 +422,17 @@ void renderer_set_constants(struct xorg_renderer *r,
const float *params,
int param_bytes)
{
- struct pipe_buffer **cbuf =
+ struct pipe_resource **cbuf =
(shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer :
&r->fs_const_buffer;
- pipe_buffer_reference(cbuf, NULL);
- *cbuf = pipe_buffer_create(r->pipe->screen, 16,
- PIPE_BUFFER_USAGE_CONSTANT,
+ pipe_resource_reference(cbuf, NULL);
+ *cbuf = pipe_buffer_create(r->pipe->screen,
+ PIPE_BIND_CONSTANT_BUFFER,
param_bytes);
if (*cbuf) {
- pipe_buffer_write(r->pipe->screen, *cbuf,
+ pipe_buffer_write(r->pipe, *cbuf,
0, param_bytes, params);
}
r->pipe->set_constant_buffer(r->pipe, shader_type, 0, *cbuf);
@@ -439,7 +441,7 @@ void renderer_set_constants(struct xorg_renderer *r,
void renderer_copy_prepare(struct xorg_renderer *r,
struct pipe_surface *dst_surface,
- struct pipe_texture *src_texture)
+ struct pipe_resource *src_texture)
{
struct pipe_context *pipe = r->pipe;
struct pipe_screen *screen = pipe->screen;
@@ -447,7 +449,7 @@ void renderer_copy_prepare(struct xorg_renderer *r,
assert(screen->is_format_supported(screen, dst_surface->format,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ PIPE_BIND_RENDER_TARGET,
0));
(void) screen;
@@ -506,24 +508,24 @@ void renderer_copy_prepare(struct xorg_renderer *r,
r->attrs_per_vertex = 2;
}
-struct pipe_texture *
+struct pipe_resource *
renderer_clone_texture(struct xorg_renderer *r,
- struct pipe_texture *src)
+ struct pipe_resource *src)
{
enum pipe_format format;
struct pipe_context *pipe = r->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture *pt;
- struct pipe_texture templ;
+ struct pipe_resource *pt;
+ struct pipe_resource templ;
- if (pipe->is_texture_referenced(pipe, src, 0, 0) &
+ if (pipe->is_resource_referenced(pipe, src, 0, 0) &
PIPE_REFERENCED_FOR_WRITE)
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
/* the coming in texture should already have that invariance */
debug_assert(screen->is_format_supported(screen, src->format,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ PIPE_BIND_SAMPLER_VIEW, 0));
format = src->format;
@@ -534,9 +536,9 @@ renderer_clone_texture(struct xorg_renderer *r,
templ.width0 = src->width0;
templ.height0 = src->height0;
templ.depth0 = 1;
- templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+ templ.bind = PIPE_BIND_SAMPLER_VIEW;
- pt = screen->texture_create(screen, &templ);
+ pt = screen->resource_create(screen, &templ);
debug_assert(!pt || pipe_is_referenced(&pt->reference));
@@ -546,9 +548,9 @@ renderer_clone_texture(struct xorg_renderer *r,
{
/* copy source framebuffer surface into texture */
struct pipe_surface *ps_read = screen->get_tex_surface(
- screen, src, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_READ);
+ screen, src, 0, 0, 0, PIPE_BIND_BLIT_SOURCE);
struct pipe_surface *ps_tex = screen->get_tex_surface(
- screen, pt, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE );
+ screen, pt, 0, 0, 0, PIPE_BIND_BLIT_DESTINATION );
if (pipe->surface_copy) {
pipe->surface_copy(pipe,
ps_tex, /* dest */
@@ -608,10 +610,10 @@ void renderer_copy_pixmap(struct xorg_renderer *r,
void renderer_draw_yuv(struct xorg_renderer *r,
int src_x, int src_y, int src_w, int src_h,
int dst_x, int dst_y, int dst_w, int dst_h,
- struct pipe_texture **textures)
+ struct pipe_resource **textures)
{
struct pipe_context *pipe = r->pipe;
- struct pipe_buffer *buf = 0;
+ struct pipe_resource *buf = 0;
buf = setup_vertex_data_yuv(r,
src_x, src_y, src_w, src_h,
@@ -628,7 +630,7 @@ void renderer_draw_yuv(struct xorg_renderer *r,
4, /* verts */
num_attribs); /* attribs/vert */
- pipe_buffer_reference(&buf, NULL);
+ pipe_resource_reference(&buf, NULL);
}
}
diff --git a/src/gallium/state_trackers/xorg/xorg_renderer.h b/src/gallium/state_trackers/xorg/xorg_renderer.h
index cc5802e79b..0454a6513d 100644
--- a/src/gallium/state_trackers/xorg/xorg_renderer.h
+++ b/src/gallium/state_trackers/xorg/xorg_renderer.h
@@ -23,8 +23,8 @@ struct xorg_renderer {
int fb_width;
int fb_height;
- struct pipe_buffer *vs_const_buffer;
- struct pipe_buffer *fs_const_buffer;
+ struct pipe_resource *vs_const_buffer;
+ struct pipe_resource *fs_const_buffer;
float buffer[BUF_SIZE];
int buffer_size;
@@ -56,7 +56,7 @@ void renderer_set_constants(struct xorg_renderer *r,
void renderer_draw_yuv(struct xorg_renderer *r,
int src_x, int src_y, int src_w, int src_h,
int dst_x, int dst_y, int dst_w, int dst_h,
- struct pipe_texture **textures);
+ struct pipe_resource **textures);
void renderer_begin_solid(struct xorg_renderer *r);
void renderer_solid(struct xorg_renderer *r,
@@ -77,13 +77,13 @@ void renderer_texture(struct xorg_renderer *r,
void renderer_draw_flush(struct xorg_renderer *r);
-struct pipe_texture *
+struct pipe_resource *
renderer_clone_texture(struct xorg_renderer *r,
- struct pipe_texture *src);
+ struct pipe_resource *src);
void renderer_copy_prepare(struct xorg_renderer *r,
struct pipe_surface *dst_surface,
- struct pipe_texture *src_texture);
+ struct pipe_resource *src_texture);
void renderer_copy_pixmap(struct xorg_renderer *r,
int dx, int dy,
diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
index c1884ebd11..cb6773424a 100644
--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
@@ -118,7 +118,7 @@ typedef struct _modesettingRec
struct pipe_context *ctx;
boolean d_depth_bits_last;
boolean ds_depth_bits_last;
- struct pipe_texture *root_texture;
+ struct pipe_resource *root_texture;
/* exa */
struct exa_context *exa;
@@ -142,7 +142,7 @@ Bool xorg_has_gallium(ScrnInfoPtr pScrn);
/***********************************************************************
* xorg_exa.c
*/
-struct pipe_texture *
+struct pipe_resource *
xorg_exa_get_texture(PixmapPtr pPixmap);
int
@@ -152,9 +152,9 @@ int
xorg_exa_set_shared_usage(PixmapPtr pPixmap);
Bool
-xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_texture *tex);
+xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_resource *tex);
-struct pipe_texture *
+struct pipe_resource *
xorg_exa_create_root_texture(ScrnInfoPtr pScrn,
int width, int height,
int depth, int bpp);
diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
index 5efda6837d..a221594454 100644
--- a/src/gallium/state_trackers/xorg/xorg_xv.c
+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
@@ -91,7 +91,7 @@ struct xorg_xv_port_priv {
int current_set;
/* juggle two sets of seperate Y, U and V
* textures */
- struct pipe_texture *yuv[2][3];
+ struct pipe_resource *yuv[2][3];
struct pipe_sampler_view *yuv_views[2][3];
};
@@ -156,13 +156,13 @@ query_best_size(ScrnInfoPtr pScrn,
*p_h = drw_h;
}
-static INLINE struct pipe_texture *
+static INLINE struct pipe_resource *
create_component_texture(struct pipe_context *pipe,
int width, int height)
{
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture *tex = 0;
- struct pipe_texture templ;
+ struct pipe_resource *tex = 0;
+ struct pipe_resource templ;
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
@@ -171,9 +171,9 @@ create_component_texture(struct pipe_context *pipe,
templ.width0 = width;
templ.height0 = height;
templ.depth0 = 1;
- templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
+ templ.bind = PIPE_BIND_SAMPLER_VIEW;
- tex = screen->texture_create(screen, &templ);
+ tex = screen->resource_create(screen, &templ);
return tex;
}
@@ -181,7 +181,7 @@ create_component_texture(struct pipe_context *pipe,
static int
check_yuv_textures(struct xorg_xv_port_priv *priv, int width, int height)
{
- struct pipe_texture **dst = priv->yuv[priv->current_set];
+ struct pipe_resource **dst = priv->yuv[priv->current_set];
struct pipe_sampler_view **dst_view = priv->yuv_views[priv->current_set];
struct pipe_sampler_view view_templ;
struct pipe_context *pipe = priv->r->pipe;
@@ -189,19 +189,19 @@ check_yuv_textures(struct xorg_xv_port_priv *priv, int width, int height)
if (!dst[0] ||
dst[0]->width0 != width ||
dst[0]->height0 != height) {
- pipe_texture_reference(&dst[0], NULL);
+ pipe_resource_reference(&dst[0], NULL);
pipe_sampler_view_reference(&dst_view[0], NULL);
}
if (!dst[1] ||
dst[1]->width0 != width ||
dst[1]->height0 != height) {
- pipe_texture_reference(&dst[1], NULL);
+ pipe_resource_reference(&dst[1], NULL);
pipe_sampler_view_reference(&dst_view[1], NULL);
}
if (!dst[2] ||
dst[2]->width0 != width ||
dst[2]->height0 != height) {
- pipe_texture_reference(&dst[2], NULL);
+ pipe_resource_reference(&dst[2], NULL);
pipe_sampler_view_reference(&dst_view[2], NULL);
}
@@ -303,7 +303,7 @@ copy_packed_data(ScrnInfoPtr pScrn,
unsigned short w, unsigned short h)
{
int i, j;
- struct pipe_texture **dst = port->yuv[port->current_set];
+ struct pipe_resource **dst = port->yuv[port->current_set];
struct pipe_transfer *ytrans, *utrans, *vtrans;
struct pipe_context *pipe = port->r->pipe;
char *ymap, *vmap, *umap;
@@ -311,15 +311,15 @@ copy_packed_data(ScrnInfoPtr pScrn,
int yidx, uidx, vidx;
int y_array_size = w * h;
- ytrans = pipe->get_tex_transfer(pipe, dst[0],
+ ytrans = pipe_get_transfer(pipe, dst[0],
0, 0, 0,
PIPE_TRANSFER_WRITE,
left, top, w, h);
- utrans = pipe->get_tex_transfer(pipe, dst[1],
+ utrans = pipe_get_transfer(pipe, dst[1],
0, 0, 0,
PIPE_TRANSFER_WRITE,
left, top, w, h);
- vtrans = pipe->get_tex_transfer(pipe, dst[2],
+ vtrans = pipe_get_transfer(pipe, dst[2],
0, 0, 0,
PIPE_TRANSFER_WRITE,
left, top, w, h);
@@ -395,9 +395,9 @@ copy_packed_data(ScrnInfoPtr pScrn,
pipe->transfer_unmap(pipe, ytrans);
pipe->transfer_unmap(pipe, utrans);
pipe->transfer_unmap(pipe, vtrans);
- pipe->tex_transfer_destroy(pipe, ytrans);
- pipe->tex_transfer_destroy(pipe, utrans);
- pipe->tex_transfer_destroy(pipe, vtrans);
+ pipe->transfer_destroy(pipe, ytrans);
+ pipe->transfer_destroy(pipe, utrans);
+ pipe->transfer_destroy(pipe, vtrans);
}
@@ -416,7 +416,7 @@ draw_yuv(struct xorg_xv_port_priv *port,
int src_x, int src_y, int src_w, int src_h,
int dst_x, int dst_y, int dst_w, int dst_h)
{
- struct pipe_texture **textures = port->yuv[port->current_set];
+ struct pipe_resource **textures = port->yuv[port->current_set];
/*debug_printf(" draw_yuv([%d, %d, %d ,%d], [%d, %d, %d, %d])\n",
src_x, src_y, src_w, src_h,
@@ -461,12 +461,12 @@ bind_shaders(struct xorg_xv_port_priv *port)
}
static INLINE void
-conditional_flush(struct pipe_context *pipe, struct pipe_texture **tex,
+conditional_flush(struct pipe_context *pipe, struct pipe_resource **tex,
int num)
{
int i;
for (i = 0; i < num; ++i) {
- if (tex[i] && pipe->is_texture_referenced(pipe, tex[i], 0, 0) &
+ if (tex[i] && pipe->is_resource_referenced(pipe, tex[i], 0, 0) &
PIPE_REFERENCED_FOR_WRITE) {
pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
return;
@@ -479,7 +479,7 @@ bind_samplers(struct xorg_xv_port_priv *port)
{
struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
struct pipe_sampler_state sampler;
- struct pipe_texture **dst = port->yuv[port->current_set];
+ struct pipe_resource **dst = port->yuv[port->current_set];
struct pipe_sampler_view **dst_views = port->yuv_views[port->current_set];
memset(&sampler, 0, sizeof(struct pipe_sampler_state));
diff --git a/src/gallium/state_trackers/xorg/xvmc/Makefile b/src/gallium/state_trackers/xorg/xvmc/Makefile
deleted file mode 100644
index 126dc6d58f..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-LIBNAME = xvmctracker
-
-LIBRARY_INCLUDES = \
- $(shell pkg-config --cflags-only-I xvmc) \
- -I$(TOP)/src/gallium/winsys/g3dvl
-
-C_SOURCES = block.c \
- surface.c \
- context.c \
- subpicture.c \
- attributes.c
-
-include ../../../Makefile.template
diff --git a/src/gallium/state_trackers/xorg/xvmc/SConscript b/src/gallium/state_trackers/xorg/xvmc/SConscript
deleted file mode 100644
index cb25d68bd8..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/SConscript
+++ /dev/null
@@ -1,27 +0,0 @@
-#######################################################################
-# SConscript for xvmc state_tracker
-
-Import('*')
-
-if 'xorg/xvmc' in env['statetrackers']:
-
- env = env.Clone()
-
- env.Append(CPPPATH = [
- '#/src/gallium/include',
- '#/src/gallium/auxiliary',
- '#/src/gallium/winsys/g3dvl',
- ])
-
- env.ParseConfig('pkg-config --cflags --libs xvmc')
-
- st_xvmc = env.ConvenienceLibrary(
- target = 'st_xvmc',
- source = [ 'block.c',
- 'surface.c',
- 'context.c',
- 'subpicture.c',
- 'attributes.c',
- ]
- )
- Export('st_xvmc')
diff --git a/src/gallium/state_trackers/xorg/xvmc/block.c b/src/gallium/state_trackers/xorg/xvmc/block.c
deleted file mode 100644
index 5102375fcf..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/block.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/XvMClib.h>
-#include <util/u_memory.h>
-#include "xvmc_private.h"
-
-Status XvMCCreateBlocks(Display *dpy, XvMCContext *context, unsigned int num_blocks, XvMCBlockArray *blocks)
-{
- assert(dpy);
-
- if (!context)
- return XvMCBadContext;
- if (num_blocks == 0)
- return BadValue;
-
- assert(blocks);
-
- blocks->context_id = context->context_id;
- blocks->num_blocks = num_blocks;
- blocks->blocks = MALLOC(BLOCK_SIZE_BYTES * num_blocks);
- blocks->privData = NULL;
-
- return Success;
-}
-
-Status XvMCDestroyBlocks(Display *dpy, XvMCBlockArray *blocks)
-{
- assert(dpy);
- assert(blocks);
- FREE(blocks->blocks);
-
- return Success;
-}
-
-Status XvMCCreateMacroBlocks(Display *dpy, XvMCContext *context, unsigned int num_blocks, XvMCMacroBlockArray *blocks)
-{
- assert(dpy);
-
- if (!context)
- return XvMCBadContext;
- if (num_blocks == 0)
- return BadValue;
-
- assert(blocks);
-
- blocks->context_id = context->context_id;
- blocks->num_blocks = num_blocks;
- blocks->macro_blocks = MALLOC(sizeof(XvMCMacroBlock) * num_blocks);
- blocks->privData = NULL;
-
- return Success;
-}
-
-Status XvMCDestroyMacroBlocks(Display *dpy, XvMCMacroBlockArray *blocks)
-{
- assert(dpy);
- assert(blocks);
- FREE(blocks->macro_blocks);
-
- return Success;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/context.c b/src/gallium/state_trackers/xorg/xvmc/context.c
deleted file mode 100644
index c8a389385a..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/context.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <X11/Xlibint.h>
-#include <X11/extensions/XvMClib.h>
-#include <pipe/p_screen.h>
-#include <pipe/p_video_context.h>
-#include <pipe/p_video_state.h>
-#include <pipe/p_state.h>
-#include <vl_winsys.h>
-#include <util/u_memory.h>
-#include <util/u_debug.h>
-#include <vl/vl_csc.h>
-#include "xvmc_private.h"
-
-static Status Validate(Display *dpy, XvPortID port, int surface_type_id,
- unsigned int width, unsigned int height, int flags,
- bool *found_port, int *screen, int *chroma_format,
- int *mc_type, int *surface_flags)
-{
- bool found_surface = false;
- XvAdaptorInfo *adaptor_info;
- unsigned int num_adaptors;
- int num_types;
- unsigned int max_width, max_height;
- Status ret;
-
- assert(dpy);
- assert(found_port);
- assert(screen);
- assert(chroma_format);
- assert(mc_type);
- assert(surface_flags);
-
- *found_port = false;
-
- for (unsigned int i = 0; i < XScreenCount(dpy); ++i) {
- ret = XvQueryAdaptors(dpy, XRootWindow(dpy, i), &num_adaptors, &adaptor_info);
- if (ret != Success)
- return ret;
-
- for (unsigned int j = 0; j < num_adaptors && !*found_port; ++j) {
- for (unsigned int k = 0; k < adaptor_info[j].num_ports && !*found_port; ++k) {
- XvMCSurfaceInfo *surface_info;
-
- if (adaptor_info[j].base_id + k != port)
- continue;
-
- *found_port = true;
-
- surface_info = XvMCListSurfaceTypes(dpy, adaptor_info[j].base_id, &num_types);
- if (!surface_info) {
- XvFreeAdaptorInfo(adaptor_info);
- return BadAlloc;
- }
-
- for (unsigned int l = 0; l < num_types && !found_surface; ++l) {
- if (surface_info[l].surface_type_id != surface_type_id)
- continue;
-
- found_surface = true;
- max_width = surface_info[l].max_width;
- max_height = surface_info[l].max_height;
- *chroma_format = surface_info[l].chroma_format;
- *mc_type = surface_info[l].mc_type;
- *surface_flags = surface_info[l].flags;
- *screen = i;
- }
-
- XFree(surface_info);
- }
- }
-
- XvFreeAdaptorInfo(adaptor_info);
- }
-
- if (!*found_port)
- return XvBadPort;
- if (!found_surface)
- return BadMatch;
- if (width > max_width || height > max_height)
- return BadValue;
- if (flags != XVMC_DIRECT && flags != 0)
- return BadValue;
-
- return Success;
-}
-
-static enum pipe_video_profile ProfileToPipe(int xvmc_profile)
-{
- if (xvmc_profile & XVMC_MPEG_1)
- assert(0);
- if (xvmc_profile & XVMC_MPEG_2)
- return PIPE_VIDEO_PROFILE_MPEG2_MAIN;
- if (xvmc_profile & XVMC_H263)
- assert(0);
- if (xvmc_profile & XVMC_MPEG_4)
- assert(0);
-
- assert(0);
-
- return -1;
-}
-
-static enum pipe_video_chroma_format FormatToPipe(int xvmc_format)
-{
- switch (xvmc_format) {
- case XVMC_CHROMA_FORMAT_420:
- return PIPE_VIDEO_CHROMA_FORMAT_420;
- case XVMC_CHROMA_FORMAT_422:
- return PIPE_VIDEO_CHROMA_FORMAT_422;
- case XVMC_CHROMA_FORMAT_444:
- return PIPE_VIDEO_CHROMA_FORMAT_444;
- default:
- assert(0);
- }
-
- return -1;
-}
-
-Status XvMCCreateContext(Display *dpy, XvPortID port, int surface_type_id,
- int width, int height, int flags, XvMCContext *context)
-{
- bool found_port;
- int scrn;
- int chroma_format;
- int mc_type;
- int surface_flags;
- Status ret;
- struct pipe_screen *screen;
- struct pipe_video_context *vpipe;
- XvMCContextPrivate *context_priv;
- float csc[16];
-
- assert(dpy);
-
- if (!context)
- return XvMCBadContext;
-
- ret = Validate(dpy, port, surface_type_id, width, height, flags,
- &found_port, &scrn, &chroma_format, &mc_type, &surface_flags);
-
- /* Success and XvBadPort have the same value */
- if (ret != Success || !found_port)
- return ret;
-
- /* XXX: Current limits */
- if (chroma_format != XVMC_CHROMA_FORMAT_420) {
- debug_printf("[XvMCg3dvl] Cannot decode requested surface type. Unsupported chroma format.\n");
- return BadImplementation;
- }
- if (mc_type != (XVMC_MOCOMP | XVMC_MPEG_2)) {
- debug_printf("[XvMCg3dvl] Cannot decode requested surface type. Non-MPEG2/Mocomp acceleration unsupported.\n");
- return BadImplementation;
- }
- if (!(surface_flags & XVMC_INTRA_UNSIGNED)) {
- debug_printf("[XvMCg3dvl] Cannot decode requested surface type. Signed intra unsupported.\n");
- return BadImplementation;
- }
-
- context_priv = CALLOC(1, sizeof(XvMCContextPrivate));
- if (!context_priv)
- return BadAlloc;
-
- /* TODO: Reuse screen if process creates another context */
- screen = vl_screen_create(dpy, scrn);
-
- if (!screen) {
- FREE(context_priv);
- return BadAlloc;
- }
-
- vpipe = vl_video_create(dpy, scrn, screen, ProfileToPipe(mc_type),
- FormatToPipe(chroma_format), width, height);
-
- if (!vpipe) {
- screen->destroy(screen);
- FREE(context_priv);
- return BadAlloc;
- }
-
- /* TODO: Define some Xv attribs to allow users to specify color standard, procamp */
- vl_csc_get_matrix
- (
- debug_get_bool_option("G3DVL_NO_CSC", FALSE) ?
- VL_CSC_COLOR_STANDARD_IDENTITY : VL_CSC_COLOR_STANDARD_BT_601,
- NULL, true, csc
- );
- vpipe->set_csc_matrix(vpipe, csc);
-
- context_priv->vpipe = vpipe;
-
- context->context_id = XAllocID(dpy);
- context->surface_type_id = surface_type_id;
- context->width = width;
- context->height = height;
- context->flags = flags;
- context->port = port;
- context->privData = context_priv;
-
- SyncHandle();
-
- return Success;
-}
-
-Status XvMCDestroyContext(Display *dpy, XvMCContext *context)
-{
- struct pipe_screen *screen;
- struct pipe_video_context *vpipe;
- XvMCContextPrivate *context_priv;
-
- assert(dpy);
-
- if (!context || !context->privData)
- return XvMCBadContext;
-
- context_priv = context->privData;
- vpipe = context_priv->vpipe;
- pipe_surface_reference(&context_priv->backbuffer, NULL);
- screen = vpipe->screen;
- vpipe->destroy(vpipe);
- screen->destroy(screen);
- FREE(context_priv);
- context->privData = NULL;
-
- return Success;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/subpicture.c b/src/gallium/state_trackers/xorg/xvmc/subpicture.c
deleted file mode 100644
index 69898d5fcd..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/subpicture.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <X11/Xlibint.h>
-#include <X11/extensions/XvMClib.h>
-
-Status XvMCCreateSubpicture(Display *dpy, XvMCContext *context, XvMCSubpicture *subpicture,
- unsigned short width, unsigned short height, int xvimage_id)
-{
- assert(dpy);
-
- if (!context)
- return XvMCBadContext;
-
- assert(subpicture);
-
- /*if (width > || height > )
- return BadValue;*/
-
- /*if (xvimage_id != )
- return BadMatch;*/
-
- subpicture->subpicture_id = XAllocID(dpy);
- subpicture->context_id = context->context_id;
- subpicture->xvimage_id = xvimage_id;
- subpicture->width = width;
- subpicture->height = height;
- subpicture->num_palette_entries = 0;
- subpicture->entry_bytes = 0;
- subpicture->component_order[0] = 0;
- subpicture->component_order[1] = 0;
- subpicture->component_order[2] = 0;
- subpicture->component_order[3] = 0;
- /* TODO: subpicture->privData = ;*/
-
- SyncHandle();
-
- return Success;
-}
-
-Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, short y,
- unsigned short width, unsigned short height, unsigned int color)
-{
- assert(dpy);
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- /* TODO: Assert clear rect is within bounds? Or clip? */
-
- return Success;
-}
-
-Status XvMCCompositeSubpicture(Display *dpy, XvMCSubpicture *subpicture, XvImage *image,
- short srcx, short srcy, unsigned short width, unsigned short height,
- short dstx, short dsty)
-{
- assert(dpy);
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- assert(image);
-
- if (subpicture->xvimage_id != image->id)
- return BadMatch;
-
- /* TODO: Assert rects are within bounds? Or clip? */
-
- return Success;
-}
-
-Status XvMCDestroySubpicture(Display *dpy, XvMCSubpicture *subpicture)
-{
- assert(dpy);
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- return BadImplementation;
-}
-
-Status XvMCSetSubpicturePalette(Display *dpy, XvMCSubpicture *subpicture, unsigned char *palette)
-{
- assert(dpy);
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- assert(palette);
-
- /* We don't support paletted subpictures */
- return BadMatch;
-}
-
-Status XvMCBlendSubpicture(Display *dpy, XvMCSurface *target_surface, XvMCSubpicture *subpicture,
- short subx, short suby, unsigned short subw, unsigned short subh,
- short surfx, short surfy, unsigned short surfw, unsigned short surfh)
-{
- assert(dpy);
-
- if (!target_surface)
- return XvMCBadSurface;
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- if (target_surface->context_id != subpicture->context_id)
- return BadMatch;
-
- /* TODO: Assert rects are within bounds? Or clip? */
- return Success;
-}
-
-Status XvMCBlendSubpicture2(Display *dpy, XvMCSurface *source_surface, XvMCSurface *target_surface,
- XvMCSubpicture *subpicture, short subx, short suby, unsigned short subw, unsigned short subh,
- short surfx, short surfy, unsigned short surfw, unsigned short surfh)
-{
- assert(dpy);
-
- if (!source_surface || !target_surface)
- return XvMCBadSurface;
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- if (source_surface->context_id != subpicture->context_id)
- return BadMatch;
-
- if (source_surface->context_id != subpicture->context_id)
- return BadMatch;
-
- /* TODO: Assert rects are within bounds? Or clip? */
- return Success;
-}
-
-Status XvMCSyncSubpicture(Display *dpy, XvMCSubpicture *subpicture)
-{
- assert(dpy);
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- return Success;
-}
-
-Status XvMCFlushSubpicture(Display *dpy, XvMCSubpicture *subpicture)
-{
- assert(dpy);
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- return Success;
-}
-
-Status XvMCGetSubpictureStatus(Display *dpy, XvMCSubpicture *subpicture, int *status)
-{
- assert(dpy);
-
- if (!subpicture)
- return XvMCBadSubpicture;
-
- assert(status);
-
- /* TODO */
- *status = 0;
-
- return Success;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/surface.c b/src/gallium/state_trackers/xorg/xvmc/surface.c
deleted file mode 100644
index 12d94e0c5c..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/surface.c
+++ /dev/null
@@ -1,408 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <X11/Xlibint.h>
-#include <pipe/p_video_context.h>
-#include <pipe/p_video_state.h>
-#include <pipe/p_state.h>
-#include <util/u_memory.h>
-#include "xvmc_private.h"
-
-static enum pipe_mpeg12_macroblock_type TypeToPipe(int xvmc_mb_type)
-{
- if (xvmc_mb_type & XVMC_MB_TYPE_INTRA)
- return PIPE_MPEG12_MACROBLOCK_TYPE_INTRA;
- if ((xvmc_mb_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) == XVMC_MB_TYPE_MOTION_FORWARD)
- return PIPE_MPEG12_MACROBLOCK_TYPE_FWD;
- if ((xvmc_mb_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) == XVMC_MB_TYPE_MOTION_BACKWARD)
- return PIPE_MPEG12_MACROBLOCK_TYPE_BKWD;
- if ((xvmc_mb_type & (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD)) == (XVMC_MB_TYPE_MOTION_FORWARD | XVMC_MB_TYPE_MOTION_BACKWARD))
- return PIPE_MPEG12_MACROBLOCK_TYPE_BI;
-
- assert(0);
-
- return -1;
-}
-
-static enum pipe_mpeg12_picture_type PictureToPipe(int xvmc_pic)
-{
- switch (xvmc_pic) {
- case XVMC_TOP_FIELD:
- return PIPE_MPEG12_PICTURE_TYPE_FIELD_TOP;
- case XVMC_BOTTOM_FIELD:
- return PIPE_MPEG12_PICTURE_TYPE_FIELD_BOTTOM;
- case XVMC_FRAME_PICTURE:
- return PIPE_MPEG12_PICTURE_TYPE_FRAME;
- default:
- assert(0);
- }
-
- return -1;
-}
-
-static enum pipe_mpeg12_motion_type MotionToPipe(int xvmc_motion_type, int xvmc_dct_type)
-{
- switch (xvmc_motion_type) {
- case XVMC_PREDICTION_FRAME:
- return xvmc_dct_type == XVMC_DCT_TYPE_FIELD ?
- PIPE_MPEG12_MOTION_TYPE_16x8 : PIPE_MPEG12_MOTION_TYPE_FRAME;
- case XVMC_PREDICTION_FIELD:
- return PIPE_MPEG12_MOTION_TYPE_FIELD;
- case XVMC_PREDICTION_DUAL_PRIME:
- return PIPE_MPEG12_MOTION_TYPE_DUALPRIME;
- default:
- assert(0);
- }
-
- return -1;
-}
-
-static bool
-CreateOrResizeBackBuffer(struct pipe_video_context *vpipe, unsigned int width, unsigned int height,
- struct pipe_surface **backbuffer)
-{
- struct pipe_texture template;
- struct pipe_texture *tex;
-
- assert(vpipe);
-
- if (*backbuffer) {
- if ((*backbuffer)->width != width || (*backbuffer)->height != height)
- pipe_surface_reference(backbuffer, NULL);
- else
- return true;
- }
-
- memset(&template, 0, sizeof(struct pipe_texture));
- template.target = PIPE_TEXTURE_2D;
- /* XXX: Needs to match the drawable's format? */
- template.format = PIPE_FORMAT_B8G8R8X8_UNORM;
- template.last_level = 0;
- template.width0 = width;
- template.height0 = height;
- template.depth0 = 1;
- template.tex_usage = PIPE_TEXTURE_USAGE_SHARED;
-
- tex = vpipe->screen->texture_create(vpipe->screen, &template);
- if (!tex)
- return false;
-
- *backbuffer = vpipe->screen->get_tex_surface(vpipe->screen, tex, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
- pipe_texture_reference(&tex, NULL);
-
- if (!*backbuffer)
- return false;
-
- /* Clear the backbuffer in case the video doesn't cover the whole window */
- /* FIXME: Need to clear every time a frame moves and leaves dirty rects */
- vpipe->clear_surface(vpipe, 0, 0, width, height, 0, *backbuffer);
-
- return true;
-}
-
-static void
-MacroBlocksToPipe(const XvMCMacroBlockArray *xvmc_macroblocks,
- const XvMCBlockArray *xvmc_blocks,
- unsigned int first_macroblock,
- unsigned int num_macroblocks,
- struct pipe_mpeg12_macroblock *pipe_macroblocks)
-{
- unsigned int i, j, k, l;
- XvMCMacroBlock *xvmc_mb;
-
- assert(xvmc_macroblocks);
- assert(xvmc_blocks);
- assert(pipe_macroblocks);
- assert(num_macroblocks);
-
- xvmc_mb = xvmc_macroblocks->macro_blocks + first_macroblock;
-
- for (i = 0; i < num_macroblocks; ++i) {
- pipe_macroblocks->base.codec = PIPE_VIDEO_CODEC_MPEG12;
- pipe_macroblocks->mbx = xvmc_mb->x;
- pipe_macroblocks->mby = xvmc_mb->y;
- pipe_macroblocks->mb_type = TypeToPipe(xvmc_mb->macroblock_type);
- if (pipe_macroblocks->mb_type != PIPE_MPEG12_MACROBLOCK_TYPE_INTRA)
- pipe_macroblocks->mo_type = MotionToPipe(xvmc_mb->motion_type, xvmc_mb->dct_type);
- /* Get rid of Valgrind 'undefined' warnings */
- else
- pipe_macroblocks->mo_type = -1;
- pipe_macroblocks->dct_type = xvmc_mb->dct_type == XVMC_DCT_TYPE_FIELD ?
- PIPE_MPEG12_DCT_TYPE_FIELD : PIPE_MPEG12_DCT_TYPE_FRAME;
-
- for (j = 0; j < 2; ++j)
- for (k = 0; k < 2; ++k)
- for (l = 0; l < 2; ++l)
- pipe_macroblocks->pmv[j][k][l] = xvmc_mb->PMV[j][k][l];
-
- pipe_macroblocks->cbp = xvmc_mb->coded_block_pattern;
- pipe_macroblocks->blocks = xvmc_blocks->blocks + xvmc_mb->index * BLOCK_SIZE_SAMPLES;
-
- ++pipe_macroblocks;
- ++xvmc_mb;
- }
-}
-
-Status XvMCCreateSurface(Display *dpy, XvMCContext *context, XvMCSurface *surface)
-{
- XvMCContextPrivate *context_priv;
- struct pipe_video_context *vpipe;
- XvMCSurfacePrivate *surface_priv;
- struct pipe_video_surface *vsfc;
-
- assert(dpy);
-
- if (!context)
- return XvMCBadContext;
- if (!surface)
- return XvMCBadSurface;
-
- context_priv = context->privData;
- vpipe = context_priv->vpipe;
-
- surface_priv = CALLOC(1, sizeof(XvMCSurfacePrivate));
- if (!surface_priv)
- return BadAlloc;
-
- vsfc = vpipe->screen->video_surface_create(vpipe->screen, vpipe->chroma_format,
- vpipe->width, vpipe->height);
- if (!vsfc) {
- FREE(surface_priv);
- return BadAlloc;
- }
-
- surface_priv->pipe_vsfc = vsfc;
- surface_priv->context = context;
-
- surface->surface_id = XAllocID(dpy);
- surface->context_id = context->context_id;
- surface->surface_type_id = context->surface_type_id;
- surface->width = context->width;
- surface->height = context->height;
- surface->privData = surface_priv;
-
- SyncHandle();
-
- return Success;
-}
-
-Status XvMCRenderSurface(Display *dpy, XvMCContext *context, unsigned int picture_structure,
- XvMCSurface *target_surface, XvMCSurface *past_surface, XvMCSurface *future_surface,
- unsigned int flags, unsigned int num_macroblocks, unsigned int first_macroblock,
- XvMCMacroBlockArray *macroblocks, XvMCBlockArray *blocks
-)
-{
- struct pipe_video_context *vpipe;
- struct pipe_surface *t_vsfc;
- struct pipe_surface *p_vsfc;
- struct pipe_surface *f_vsfc;
- XvMCContextPrivate *context_priv;
- XvMCSurfacePrivate *target_surface_priv;
- XvMCSurfacePrivate *past_surface_priv;
- XvMCSurfacePrivate *future_surface_priv;
- struct pipe_mpeg12_macroblock pipe_macroblocks[num_macroblocks];
-
- assert(dpy);
-
- if (!context || !context->privData)
- return XvMCBadContext;
- if (!target_surface || !target_surface->privData)
- return XvMCBadSurface;
-
- if (picture_structure != XVMC_TOP_FIELD &&
- picture_structure != XVMC_BOTTOM_FIELD &&
- picture_structure != XVMC_FRAME_PICTURE)
- return BadValue;
- /* Bkwd pred equivalent to fwd (past && !future) */
- if (future_surface && !past_surface)
- return BadMatch;
-
- assert(context->context_id == target_surface->context_id);
- assert(!past_surface || context->context_id == past_surface->context_id);
- assert(!future_surface || context->context_id == future_surface->context_id);
-
- assert(macroblocks);
- assert(blocks);
-
- assert(macroblocks->context_id == context->context_id);
- assert(blocks->context_id == context->context_id);
-
- assert(flags == 0 || flags == XVMC_SECOND_FIELD);
-
- target_surface_priv = target_surface->privData;
- past_surface_priv = past_surface ? past_surface->privData : NULL;
- future_surface_priv = future_surface ? future_surface->privData : NULL;
-
- assert(target_surface_priv->context == context);
- assert(!past_surface || past_surface_priv->context == context);
- assert(!future_surface || future_surface_priv->context == context);
-
- context_priv = context->privData;
- vpipe = context_priv->vpipe;
-
- t_vsfc = target_surface_priv->pipe_vsfc;
- p_vsfc = past_surface ? past_surface_priv->pipe_vsfc : NULL;
- f_vsfc = future_surface ? future_surface_priv->pipe_vsfc : NULL;
-
- MacroBlocksToPipe(macroblocks, blocks, first_macroblock,
- num_macroblocks, pipe_macroblocks);
-
- vpipe->set_decode_target(vpipe, t_vsfc);
- vpipe->decode_macroblocks(vpipe, p_vsfc, f_vsfc, num_macroblocks,
- &pipe_macroblocks->base, target_surface_priv->render_fence);
-
- return Success;
-}
-
-Status XvMCFlushSurface(Display *dpy, XvMCSurface *surface)
-{
- assert(dpy);
-
- if (!surface)
- return XvMCBadSurface;
-
- return Success;
-}
-
-Status XvMCSyncSurface(Display *dpy, XvMCSurface *surface)
-{
- assert(dpy);
-
- if (!surface)
- return XvMCBadSurface;
-
- return Success;
-}
-
-Status XvMCPutSurface(Display *dpy, XvMCSurface *surface, Drawable drawable,
- short srcx, short srcy, unsigned short srcw, unsigned short srch,
- short destx, short desty, unsigned short destw, unsigned short desth,
- int flags)
-{
- Window root;
- int x, y;
- unsigned int width, height;
- unsigned int border_width;
- unsigned int depth;
- struct pipe_video_context *vpipe;
- XvMCSurfacePrivate *surface_priv;
- XvMCContextPrivate *context_priv;
- XvMCContext *context;
- struct pipe_video_rect src_rect = {srcx, srcy, srcw, srch};
- struct pipe_video_rect dst_rect = {destx, desty, destw, desth};
-
- assert(dpy);
-
- if (!surface || !surface->privData)
- return XvMCBadSurface;
-
- if (XGetGeometry(dpy, drawable, &root, &x, &y, &width, &height, &border_width, &depth) == BadDrawable)
- return BadDrawable;
-
- assert(flags == XVMC_TOP_FIELD || flags == XVMC_BOTTOM_FIELD || flags == XVMC_FRAME_PICTURE);
- assert(srcx + srcw - 1 < surface->width);
- assert(srcy + srch - 1 < surface->height);
- /*
- * Some apps (mplayer) hit these asserts because they call
- * this function after the window has been resized by the WM
- * but before they've handled the corresponding XEvent and
- * know about the new dimensions. The output should be clipped
- * until the app updates destw and desth.
- */
- /*
- assert(destx + destw - 1 < width);
- assert(desty + desth - 1 < height);
- */
-
- surface_priv = surface->privData;
- context = surface_priv->context;
- context_priv = context->privData;
- vpipe = context_priv->vpipe;
-
- if (!CreateOrResizeBackBuffer(vpipe, width, height, &context_priv->backbuffer))
- return BadAlloc;
-
- vpipe->render_picture(vpipe, surface_priv->pipe_vsfc, PictureToPipe(flags), &src_rect,
- context_priv->backbuffer, &dst_rect, surface_priv->disp_fence);
-
- vl_video_bind_drawable(vpipe, drawable);
-
- vpipe->screen->flush_frontbuffer
- (
- vpipe->screen,
- context_priv->backbuffer,
- vpipe->priv
- );
-
- return Success;
-}
-
-Status XvMCGetSurfaceStatus(Display *dpy, XvMCSurface *surface, int *status)
-{
- assert(dpy);
-
- if (!surface)
- return XvMCBadSurface;
-
- assert(status);
-
- *status = 0;
-
- return Success;
-}
-
-Status XvMCDestroySurface(Display *dpy, XvMCSurface *surface)
-{
- XvMCSurfacePrivate *surface_priv;
-
- assert(dpy);
-
- if (!surface || !surface->privData)
- return XvMCBadSurface;
-
- surface_priv = surface->privData;
- pipe_video_surface_reference(&surface_priv->pipe_vsfc, NULL);
- FREE(surface_priv);
- surface->privData = NULL;
-
- return Success;
-}
-
-Status XvMCHideSurface(Display *dpy, XvMCSurface *surface)
-{
- assert(dpy);
-
- if (!surface || !surface->privData)
- return XvMCBadSurface;
-
- /* No op, only for overlaid rendering */
-
- return Success;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/.gitignore b/src/gallium/state_trackers/xorg/xvmc/tests/.gitignore
deleted file mode 100644
index e1d2f9023d..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-test_context
-test_surface
-test_blocks
-test_rendering
-xvmc_bench
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/Makefile b/src/gallium/state_trackers/xorg/xvmc/tests/Makefile
deleted file mode 100644
index c875dd7605..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/Makefile
+++ /dev/null
@@ -1,28 +0,0 @@
-TOP = ../../../../../..
-include $(TOP)/configs/current
-
-LIBS = -lXvMCW -lXvMC -lXv -lX11
-
-#############################################
-
-.PHONY: default clean
-
-default: test_context test_surface test_blocks test_rendering xvmc_bench
-
-test_context: test_context.o testlib.o
- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-test_surface: test_surface.o testlib.o
- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-test_blocks: test_blocks.o testlib.o
- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-test_rendering: test_rendering.o testlib.o
- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-xvmc_bench: xvmc_bench.o testlib.o
- $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
-
-clean:
- $(RM) -rf *.o test_context test_surface test_blocks test_rendering xvmc_bench
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_blocks.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_blocks.c
deleted file mode 100644
index 994e3ca4d1..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/test_blocks.c
+++ /dev/null
@@ -1,111 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <error.h>
-#include "testlib.h"
-
-int main(int argc, char **argv)
-{
- const unsigned int width = 16, height = 16;
- const unsigned int min_required_blocks = 1, min_required_macroblocks = 1;
- const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
-
- Display *display;
- XvPortID port_num;
- int surface_type_id;
- unsigned int is_overlay, intra_unsigned;
- int colorkey;
- XvMCContext context;
- XvMCSurface surface;
- XvMCBlockArray blocks = {0};
- XvMCMacroBlockArray macroblocks = {0};
-
- display = XOpenDisplay(NULL);
-
- if (!GetPort
- (
- display,
- width,
- height,
- XVMC_CHROMA_FORMAT_420,
- mc_types,
- 2,
- &port_num,
- &surface_type_id,
- &is_overlay,
- &intra_unsigned
- ))
- {
- XCloseDisplay(display);
- error(1, 0, "Error, unable to find a good port.\n");
- }
-
- if (is_overlay)
- {
- Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
- XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
- }
-
- assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
- assert(XvMCCreateSurface(display, &context, &surface) == Success);
-
- /* Test NULL context */
- assert(XvMCCreateBlocks(display, NULL, 1, &blocks) == XvMCBadContext);
- /* Test 0 blocks */
- assert(XvMCCreateBlocks(display, &context, 0, &blocks) == BadValue);
- /* Test valid params */
- assert(XvMCCreateBlocks(display, &context, min_required_blocks, &blocks) == Success);
- /* Test context id assigned and correct */
- assert(blocks.context_id == context.context_id);
- /* Test number of blocks assigned and correct */
- assert(blocks.num_blocks == min_required_blocks);
- /* Test block pointer valid */
- assert(blocks.blocks != NULL);
- /* Test NULL context */
- assert(XvMCCreateMacroBlocks(display, NULL, 1, &macroblocks) == XvMCBadContext);
- /* Test 0 macroblocks */
- assert(XvMCCreateMacroBlocks(display, &context, 0, &macroblocks) == BadValue);
- /* Test valid params */
- assert(XvMCCreateMacroBlocks(display, &context, min_required_macroblocks, &macroblocks) == Success);
- /* Test context id assigned and correct */
- assert(macroblocks.context_id == context.context_id);
- /* Test macroblock pointer valid */
- assert(macroblocks.macro_blocks != NULL);
- /* Test valid params */
- assert(XvMCDestroyMacroBlocks(display, &macroblocks) == Success);
- /* Test valid params */
- assert(XvMCDestroyBlocks(display, &blocks) == Success);
-
- assert(XvMCDestroySurface(display, &surface) == Success);
- assert(XvMCDestroyContext(display, &context) == Success);
-
- XvUngrabPort(display, port_num, CurrentTime);
- XCloseDisplay(display);
-
- return 0;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_context.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_context.c
deleted file mode 100644
index 3da957c933..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/test_context.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <error.h>
-#include "testlib.h"
-
-int main(int argc, char **argv)
-{
- const unsigned int width = 16, height = 16;
- const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
-
- Display *display;
- XvPortID port_num;
- int surface_type_id;
- unsigned int is_overlay, intra_unsigned;
- int colorkey;
- XvMCContext context = {0};
-
- display = XOpenDisplay(NULL);
-
- if (!GetPort
- (
- display,
- width,
- height,
- XVMC_CHROMA_FORMAT_420,
- mc_types,
- 2,
- &port_num,
- &surface_type_id,
- &is_overlay,
- &intra_unsigned
- ))
- {
- XCloseDisplay(display);
- error(1, 0, "Error, unable to find a good port.\n");
- }
-
- if (is_overlay)
- {
- Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
- XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
- }
-
- /* Test NULL context */
- /* XXX: XvMCBadContext not a valid return for XvMCCreateContext in the XvMC API, but openChrome driver returns it */
- assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, NULL) == XvMCBadContext);
- /* Test invalid port */
- /* XXX: Success and XvBadPort have the same value, if this call actually gets passed the validation step as of now we'll crash later */
- assert(XvMCCreateContext(display, -1, surface_type_id, width, height, XVMC_DIRECT, &context) == XvBadPort);
- /* Test invalid surface */
- assert(XvMCCreateContext(display, port_num, -1, width, height, XVMC_DIRECT, &context) == BadMatch);
- /* Test invalid flags */
- assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, -1, &context) == BadValue);
- /* Test huge width */
- assert(XvMCCreateContext(display, port_num, surface_type_id, 16384, height, XVMC_DIRECT, &context) == BadValue);
- /* Test huge height */
- assert(XvMCCreateContext(display, port_num, surface_type_id, width, 16384, XVMC_DIRECT, &context) == BadValue);
- /* Test huge width & height */
- assert(XvMCCreateContext(display, port_num, surface_type_id, 16384, 16384, XVMC_DIRECT, &context) == BadValue);
- /* Test valid params */
- assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
- /* Test context id assigned */
- assert(context.context_id != 0);
- /* Test surface type id assigned and correct */
- assert(context.surface_type_id == surface_type_id);
- /* Test width & height assigned and correct */
- assert(context.width == width && context.height == height);
- /* Test port assigned and correct */
- assert(context.port == port_num);
- /* Test flags assigned and correct */
- assert(context.flags == XVMC_DIRECT);
- /* Test NULL context */
- assert(XvMCDestroyContext(display, NULL) == XvMCBadContext);
- /* Test valid params */
- assert(XvMCDestroyContext(display, &context) == Success);
- /* Test awkward but valid width */
- assert(XvMCCreateContext(display, port_num, surface_type_id, width + 1, height, XVMC_DIRECT, &context) == Success);
- assert(context.width >= width + 1);
- assert(XvMCDestroyContext(display, &context) == Success);
- /* Test awkward but valid height */
- assert(XvMCCreateContext(display, port_num, surface_type_id, width, height + 1, XVMC_DIRECT, &context) == Success);
- assert(context.height >= height + 1);
- assert(XvMCDestroyContext(display, &context) == Success);
- /* Test awkward but valid width & height */
- assert(XvMCCreateContext(display, port_num, surface_type_id, width + 1, height + 1, XVMC_DIRECT, &context) == Success);
- assert(context.width >= width + 1 && context.height >= height + 1);
- assert(XvMCDestroyContext(display, &context) == Success);
-
- XvUngrabPort(display, port_num, CurrentTime);
- XCloseDisplay(display);
-
- return 0;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_rendering.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_rendering.c
deleted file mode 100644
index 6058783a79..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/test_rendering.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <error.h>
-#include "testlib.h"
-
-#define BLOCK_WIDTH 8
-#define BLOCK_HEIGHT 8
-#define BLOCK_SIZE (BLOCK_WIDTH * BLOCK_HEIGHT)
-#define MACROBLOCK_WIDTH 16
-#define MACROBLOCK_HEIGHT 16
-#define MACROBLOCK_WIDTH_IN_BLOCKS (MACROBLOCK_WIDTH / BLOCK_WIDTH)
-#define MACROBLOCK_HEIGHT_IN_BLOCKS (MACROBLOCK_HEIGHT / BLOCK_HEIGHT)
-#define BLOCKS_PER_MACROBLOCK 6
-
-#define INPUT_WIDTH 16
-#define INPUT_HEIGHT 16
-#define INPUT_WIDTH_IN_MACROBLOCKS (INPUT_WIDTH / MACROBLOCK_WIDTH)
-#define INPUT_HEIGHT_IN_MACROBLOCKS (INPUT_HEIGHT / MACROBLOCK_HEIGHT)
-#define NUM_MACROBLOCKS (INPUT_WIDTH_IN_MACROBLOCKS * INPUT_HEIGHT_IN_MACROBLOCKS)
-
-#define DEFAULT_OUTPUT_WIDTH INPUT_WIDTH
-#define DEFAULT_OUTPUT_HEIGHT INPUT_HEIGHT
-#define DEFAULT_ACCEPTABLE_ERR 0.01
-
-void ParseArgs(int argc, char **argv, unsigned int *output_width, unsigned int *output_height, double *acceptable_error, int *prompt);
-void Gradient(short *block, unsigned int start, unsigned int stop, int horizontal);
-
-void ParseArgs(int argc, char **argv, unsigned int *output_width, unsigned int *output_height, double *acceptable_error, int *prompt)
-{
- int fail = 0;
- int i;
-
- *output_width = DEFAULT_OUTPUT_WIDTH;
- *output_height = DEFAULT_OUTPUT_WIDTH;
- *acceptable_error = DEFAULT_ACCEPTABLE_ERR;
- *prompt = 1;
-
- for (i = 1; i < argc && !fail; ++i)
- {
- if (!strcmp(argv[i], "-w"))
- {
- if (sscanf(argv[++i], "%u", output_width) != 1)
- fail = 1;
- }
- else if (!strcmp(argv[i], "-h"))
- {
- if (sscanf(argv[++i], "%u", output_height) != 1)
- fail = 1;
- }
- else if (!strcmp(argv[i], "-e"))
- {
- if (sscanf(argv[++i], "%lf", acceptable_error) != 1)
- fail = 1;
- }
- else if (strcmp(argv[i], "-n"))
- *prompt = 0;
- else
- fail = 1;
- }
-
- if (fail)
- error
- (
- 1, 0,
- "Bad argument.\n"
- "\n"
- "Usage: %s [options]\n"
- "\t-w <width>\tOutput width\n"
- "\t-h <height>\tOutput height\n"
- "\t-e <error>\tAcceptable margin of error per pixel, from 0 to 1\n"
- "\t-n\tDon't prompt for quit\n",
- argv[0]
- );
-}
-
-void Gradient(short *block, unsigned int start, unsigned int stop, int horizontal)
-{
- unsigned int x, y;
- unsigned int range = stop - start;
-
- if (horizontal)
- {
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- for (x = 0; x < BLOCK_WIDTH; ++x)
- block[y * BLOCK_WIDTH + x] = (short)(start + range * (x / (float)(BLOCK_WIDTH - 1)));
- }
- else
- {
- for (y = 0; y < BLOCK_HEIGHT; ++y)
- for (x = 0; x < BLOCK_WIDTH; ++x)
- block[y * BLOCK_WIDTH + x] = (short)(start + range * (y / (float)(BLOCK_HEIGHT - 1)));
- }
-}
-
-int main(int argc, char **argv)
-{
- unsigned int output_width;
- unsigned int output_height;
- double acceptable_error;
- int prompt;
- Display *display;
- Window root, window;
- const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
- XvPortID port_num;
- int surface_type_id;
- unsigned int is_overlay, intra_unsigned;
- int colorkey;
- XvMCContext context;
- XvMCSurface surface;
- XvMCBlockArray block_array;
- XvMCMacroBlockArray mb_array;
- int mbx, mby, bx, by;
- XvMCMacroBlock *mb;
- short *blocks;
- int quit = 0;
-
- ParseArgs(argc, argv, &output_width, &output_height, &acceptable_error, &prompt);
-
- display = XOpenDisplay(NULL);
-
- if (!GetPort
- (
- display,
- INPUT_WIDTH,
- INPUT_HEIGHT,
- XVMC_CHROMA_FORMAT_420,
- mc_types,
- 2,
- &port_num,
- &surface_type_id,
- &is_overlay,
- &intra_unsigned
- ))
- {
- XCloseDisplay(display);
- error(1, 0, "Error, unable to find a good port.\n");
- }
-
- if (is_overlay)
- {
- Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
- XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
- }
-
- root = XDefaultRootWindow(display);
- window = XCreateSimpleWindow(display, root, 0, 0, output_width, output_height, 0, 0, colorkey);
-
- assert(XvMCCreateContext(display, port_num, surface_type_id, INPUT_WIDTH, INPUT_HEIGHT, XVMC_DIRECT, &context) == Success);
- assert(XvMCCreateSurface(display, &context, &surface) == Success);
- assert(XvMCCreateBlocks(display, &context, NUM_MACROBLOCKS * BLOCKS_PER_MACROBLOCK, &block_array) == Success);
- assert(XvMCCreateMacroBlocks(display, &context, NUM_MACROBLOCKS, &mb_array) == Success);
-
- mb = mb_array.macro_blocks;
- blocks = block_array.blocks;
-
- for (mby = 0; mby < INPUT_HEIGHT_IN_MACROBLOCKS; ++mby)
- for (mbx = 0; mbx < INPUT_WIDTH_IN_MACROBLOCKS; ++mbx)
- {
- mb->x = mbx;
- mb->y = mby;
- mb->macroblock_type = XVMC_MB_TYPE_INTRA;
- /*mb->motion_type = ;*/
- /*mb->motion_vertical_field_select = ;*/
- mb->dct_type = XVMC_DCT_TYPE_FRAME;
- /*mb->PMV[0][0][0] = ;
- mb->PMV[0][0][1] = ;
- mb->PMV[0][1][0] = ;
- mb->PMV[0][1][1] = ;
- mb->PMV[1][0][0] = ;
- mb->PMV[1][0][1] = ;
- mb->PMV[1][1][0] = ;
- mb->PMV[1][1][1] = ;*/
- mb->index = (mby * INPUT_WIDTH_IN_MACROBLOCKS + mbx) * BLOCKS_PER_MACROBLOCK;
- mb->coded_block_pattern = 0x3F;
-
- mb++;
-
- for (by = 0; by < MACROBLOCK_HEIGHT_IN_BLOCKS; ++by)
- for (bx = 0; bx < MACROBLOCK_WIDTH_IN_BLOCKS; ++bx)
- {
- const int start = 16, stop = 235, range = stop - start;
-
- Gradient
- (
- blocks,
- (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))),
- (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))),
- 1
- );
-
- blocks += BLOCK_SIZE;
- }
-
- for (by = 0; by < MACROBLOCK_HEIGHT_IN_BLOCKS / 2; ++by)
- for (bx = 0; bx < MACROBLOCK_WIDTH_IN_BLOCKS / 2; ++bx)
- {
- const int start = 16, stop = 240, range = stop - start;
-
- Gradient
- (
- blocks,
- (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))),
- (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))),
- 1
- );
-
- blocks += BLOCK_SIZE;
-
- Gradient
- (
- blocks,
- (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH) / (float)(INPUT_WIDTH - 1))),
- (short)(start + range * ((mbx * MACROBLOCK_WIDTH + bx * BLOCK_WIDTH + BLOCK_WIDTH - 1) / (float)(INPUT_WIDTH - 1))),
- 1
- );
-
- blocks += BLOCK_SIZE;
- }
- }
-
- XSelectInput(display, window, ExposureMask | KeyPressMask);
- XMapWindow(display, window);
- XSync(display, 0);
-
- /* Test NULL context */
- assert(XvMCRenderSurface(display, NULL, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == XvMCBadContext);
- /* Test NULL surface */
- assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, NULL, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == XvMCBadSurface);
- /* Test bad picture structure */
- assert(XvMCRenderSurface(display, &context, 0, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == BadValue);
- /* Test valid params */
- assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, NUM_MACROBLOCKS, 0, &mb_array, &block_array) == Success);
-
- /* Test NULL surface */
- assert(XvMCPutSurface(display, NULL, window, 0, 0, INPUT_WIDTH, INPUT_HEIGHT, 0, 0, output_width, output_height, XVMC_FRAME_PICTURE) == XvMCBadSurface);
- /* Test bad window */
- /* XXX: X halts with a bad drawable for some reason, doesn't return BadDrawable as expected */
- /*assert(XvMCPutSurface(display, &surface, 0, 0, 0, width, height, 0, 0, width, height, XVMC_FRAME_PICTURE) == BadDrawable);*/
-
- if (prompt)
- {
- puts("Press any button to quit...");
-
- while (!quit)
- {
- if (XPending(display) > 0)
- {
- XEvent event;
-
- XNextEvent(display, &event);
-
- switch (event.type)
- {
- case Expose:
- {
- /* Test valid params */
- assert
- (
- XvMCPutSurface
- (
- display, &surface, window,
- 0, 0, INPUT_WIDTH, INPUT_HEIGHT,
- 0, 0, output_width, output_height,
- XVMC_FRAME_PICTURE
- ) == Success
- );
- break;
- }
- case KeyPress:
- {
- quit = 1;
- break;
- }
- }
- }
- }
- }
-
- assert(XvMCDestroyBlocks(display, &block_array) == Success);
- assert(XvMCDestroyMacroBlocks(display, &mb_array) == Success);
- assert(XvMCDestroySurface(display, &surface) == Success);
- assert(XvMCDestroyContext(display, &context) == Success);
-
- XvUngrabPort(display, port_num, CurrentTime);
- XDestroyWindow(display, window);
- XCloseDisplay(display);
-
- return 0;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/test_surface.c b/src/gallium/state_trackers/xorg/xvmc/tests/test_surface.c
deleted file mode 100644
index b65eb265c0..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/test_surface.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <error.h>
-#include "testlib.h"
-
-int main(int argc, char **argv)
-{
- const unsigned int width = 16, height = 16;
- const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
-
- Display *display;
- XvPortID port_num;
- int surface_type_id;
- unsigned int is_overlay, intra_unsigned;
- int colorkey;
- XvMCContext context;
- XvMCSurface surface = {0};
-
- display = XOpenDisplay(NULL);
-
- if (!GetPort
- (
- display,
- width,
- height,
- XVMC_CHROMA_FORMAT_420,
- mc_types,
- 2,
- &port_num,
- &surface_type_id,
- &is_overlay,
- &intra_unsigned
- ))
- {
- XCloseDisplay(display);
- error(1, 0, "Error, unable to find a good port.\n");
- }
-
- if (is_overlay)
- {
- Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
- XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
- }
-
- assert(XvMCCreateContext(display, port_num, surface_type_id, width, height, XVMC_DIRECT, &context) == Success);
-
- /* Test NULL context */
- assert(XvMCCreateSurface(display, NULL, &surface) == XvMCBadContext);
- /* Test NULL surface */
- assert(XvMCCreateSurface(display, &context, NULL) == XvMCBadSurface);
- /* Test valid params */
- assert(XvMCCreateSurface(display, &context, &surface) == Success);
- /* Test surface id assigned */
- assert(surface.surface_id != 0);
- /* Test context id assigned and correct */
- assert(surface.context_id == context.context_id);
- /* Test surface type id assigned and correct */
- assert(surface.surface_type_id == surface_type_id);
- /* Test width & height assigned and correct */
- assert(surface.width == width && surface.height == height);
- /* Test valid params */
- assert(XvMCDestroySurface(display, &surface) == Success);
- /* Test NULL surface */
- assert(XvMCDestroySurface(display, NULL) == XvMCBadSurface);
-
- assert(XvMCDestroyContext(display, &context) == Success);
-
- XvUngrabPort(display, port_num, CurrentTime);
- XCloseDisplay(display);
-
- return 0;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/testlib.c b/src/gallium/state_trackers/xorg/xvmc/tests/testlib.c
deleted file mode 100644
index 142c09bb59..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/testlib.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "testlib.h"
-#include <stdio.h>
-
-/*
-void test(int pred, const char *pred_string, const char *doc_string, const char *file, unsigned int line)
-{
- fputs(doc_string, stderr);
- if (!pred)
- fprintf(stderr, " FAIL!\n\t\"%s\" at %s:%u\n", pred_string, file, line);
- else
- fputs(" PASS!\n", stderr);
-}
-*/
-
-int GetPort
-(
- Display *display,
- unsigned int width,
- unsigned int height,
- unsigned int chroma_format,
- const unsigned int *mc_types,
- unsigned int num_mc_types,
- XvPortID *port_id,
- int *surface_type_id,
- unsigned int *is_overlay,
- unsigned int *intra_unsigned
-)
-{
- unsigned int found_port = 0;
- XvAdaptorInfo *adaptor_info;
- unsigned int num_adaptors;
- int num_types;
- int ev_base, err_base;
- unsigned int i, j, k, l;
-
- if (!XvMCQueryExtension(display, &ev_base, &err_base))
- return 0;
- if (XvQueryAdaptors(display, XDefaultRootWindow(display), &num_adaptors, &adaptor_info) != Success)
- return 0;
-
- for (i = 0; i < num_adaptors && !found_port; ++i)
- {
- if (adaptor_info[i].type & XvImageMask)
- {
- XvMCSurfaceInfo *surface_info = XvMCListSurfaceTypes(display, adaptor_info[i].base_id, &num_types);
-
- if (surface_info)
- {
- for (j = 0; j < num_types && !found_port; ++j)
- {
- if
- (
- surface_info[j].chroma_format == chroma_format &&
- surface_info[j].max_width >= width &&
- surface_info[j].max_height >= height
- )
- {
- for (k = 0; k < num_mc_types && !found_port; ++k)
- {
- if (surface_info[j].mc_type == mc_types[k])
- {
- for (l = 0; l < adaptor_info[i].num_ports && !found_port; ++l)
- {
- if (XvGrabPort(display, adaptor_info[i].base_id + l, CurrentTime) == Success)
- {
- *port_id = adaptor_info[i].base_id + l;
- *surface_type_id = surface_info[j].surface_type_id;
- *is_overlay = surface_info[j].flags & XVMC_OVERLAID_SURFACE;
- *intra_unsigned = surface_info[j].flags & XVMC_INTRA_UNSIGNED;
- found_port = 1;
- }
- }
- }
- }
- }
- }
-
- XFree(surface_info);
- }
- }
- }
-
- XvFreeAdaptorInfo(adaptor_info);
-
- return found_port;
-}
-
-unsigned int align(unsigned int value, unsigned int alignment)
-{
- return (value + alignment - 1) & ~(alignment - 1);
-}
-
-/* From the glibc manual */
-int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
-{
- /* Perform the carry for the later subtraction by updating y. */
- if (x->tv_usec < y->tv_usec)
- {
- int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
- y->tv_usec -= 1000000 * nsec;
- y->tv_sec += nsec;
- }
- if (x->tv_usec - y->tv_usec > 1000000)
- {
- int nsec = (x->tv_usec - y->tv_usec) / 1000000;
- y->tv_usec += 1000000 * nsec;
- y->tv_sec -= nsec;
- }
-
- /*
- * Compute the time remaining to wait.
- * tv_usec is certainly positive.
- */
- result->tv_sec = x->tv_sec - y->tv_sec;
- result->tv_usec = x->tv_usec - y->tv_usec;
-
- /* Return 1 if result is negative. */
- return x->tv_sec < y->tv_sec;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/testlib.h b/src/gallium/state_trackers/xorg/xvmc/tests/testlib.h
deleted file mode 100644
index 0438e52928..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/testlib.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef testlib_h
-#define testlib_h
-
-/*
-#define TEST(pred, doc) test(pred, #pred, doc, __FILE__, __LINE__)
-
-void test(int pred, const char *pred_string, const char *doc_string, const char *file, unsigned int line);
-*/
-
-#include <sys/time.h>
-#include <X11/Xlib.h>
-#include <X11/extensions/XvMClib.h>
-
-/*
- * display: IN A valid X display
- * width, height: IN Surface size that the port must display
- * chroma_format: IN Chroma format that the port must display
- * mc_types, num_mc_types: IN List of MC types that the port must support, first port that matches the first mc_type will be returned
- * port_id: OUT Your port's ID
- * surface_type_id: OUT Your port's surface ID
- * is_overlay: OUT If 1, port uses overlay surfaces, you need to set a colorkey
- * intra_unsigned: OUT If 1, port uses unsigned values for intra-coded blocks
- */
-int GetPort
-(
- Display *display,
- unsigned int width,
- unsigned int height,
- unsigned int chroma_format,
- const unsigned int *mc_types,
- unsigned int num_mc_types,
- XvPortID *port_id,
- int *surface_type_id,
- unsigned int *is_overlay,
- unsigned int *intra_unsigned
-);
-
-unsigned int align(unsigned int value, unsigned int alignment);
-
-int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);
-
-#endif
diff --git a/src/gallium/state_trackers/xorg/xvmc/tests/xvmc_bench.c b/src/gallium/state_trackers/xorg/xvmc/tests/xvmc_bench.c
deleted file mode 100644
index bf94d85623..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/tests/xvmc_bench.c
+++ /dev/null
@@ -1,300 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <assert.h>
-#include <stdio.h>
-#include <string.h>
-#include <error.h>
-#include <sys/time.h>
-#include "testlib.h"
-
-#define MACROBLOCK_WIDTH 16
-#define MACROBLOCK_HEIGHT 16
-#define BLOCKS_PER_MACROBLOCK 6
-
-#define DEFAULT_INPUT_WIDTH 720
-#define DEFAULT_INPUT_HEIGHT 480
-#define DEFAULT_REPS 100
-
-#define PIPELINE_STEP_MC 1
-#define PIPELINE_STEP_CSC 2
-#define PIPELINE_STEP_SWAP 4
-
-#define MB_TYPE_I 1
-#define MB_TYPE_P 2
-#define MB_TYPE_B 4
-
-struct Config
-{
- unsigned int input_width;
- unsigned int input_height;
- unsigned int output_width;
- unsigned int output_height;
- unsigned int pipeline;
- unsigned int mb_types;
- unsigned int reps;
-};
-
-void ParseArgs(int argc, char **argv, struct Config *config);
-
-void ParseArgs(int argc, char **argv, struct Config *config)
-{
- int fail = 0;
- int i;
-
- config->input_width = DEFAULT_INPUT_WIDTH;
- config->input_height = DEFAULT_INPUT_HEIGHT;
- config->output_width = 0;
- config->output_height = 0;
- config->pipeline = 0;
- config->mb_types = 0;
- config->reps = DEFAULT_REPS;
-
- for (i = 1; i < argc && !fail; ++i)
- {
- if (!strcmp(argv[i], "-iw"))
- {
- if (sscanf(argv[++i], "%u", &config->input_width) != 1)
- fail = 1;
- }
- else if (!strcmp(argv[i], "-ih"))
- {
- if (sscanf(argv[++i], "%u", &config->input_height) != 1)
- fail = 1;
- }
- else if (!strcmp(argv[i], "-ow"))
- {
- if (sscanf(argv[++i], "%u", &config->output_width) != 1)
- fail = 1;
- }
- else if (!strcmp(argv[i], "-oh"))
- {
- if (sscanf(argv[++i], "%u", &config->output_height) != 1)
- fail = 1;
- }
- else if (!strcmp(argv[i], "-p"))
- {
- char *token = strtok(argv[++i], ",");
-
- while (token && !fail)
- {
- if (!strcmp(token, "mc"))
- config->pipeline |= PIPELINE_STEP_MC;
- else if (!strcmp(token, "csc"))
- config->pipeline |= PIPELINE_STEP_CSC;
- else if (!strcmp(token, "swp"))
- config->pipeline |= PIPELINE_STEP_SWAP;
- else
- fail = 1;
-
- if (!fail)
- token = strtok(NULL, ",");
- }
- }
- else if (!strcmp(argv[i], "-mb"))
- {
- char *token = strtok(argv[++i], ",");
-
- while (token && !fail)
- {
- if (strcmp(token, "i"))
- config->mb_types |= MB_TYPE_I;
- else if (strcmp(token, "p"))
- config->mb_types |= MB_TYPE_P;
- else if (strcmp(token, "b"))
- config->mb_types |= MB_TYPE_B;
- else
- fail = 1;
-
- if (!fail)
- token = strtok(NULL, ",");
- }
- }
- else if (!strcmp(argv[i], "-r"))
- {
- if (sscanf(argv[++i], "%u", &config->reps) != 1)
- fail = 1;
- }
- else
- fail = 1;
- }
-
- if (fail)
- error
- (
- 1, 0,
- "Bad argument.\n"
- "\n"
- "Usage: %s [options]\n"
- "\t-iw <width>\tInput width\n"
- "\t-ih <height>\tInput height\n"
- "\t-ow <width>\tOutput width\n"
- "\t-oh <height>\tOutput height\n"
- "\t-p <pipeline>\tPipeline to test\n"
- "\t-mb <mb type>\tMacroBlock types to use\n"
- "\t-r <reps>\tRepetitions\n\n"
- "\tPipeline steps: mc,csc,swap\n"
- "\tMB types: i,p,b\n",
- argv[0]
- );
-
- if (config->output_width == 0)
- config->output_width = config->input_width;
- if (config->output_height == 0)
- config->output_height = config->input_height;
- if (!config->pipeline)
- config->pipeline = PIPELINE_STEP_MC | PIPELINE_STEP_CSC | PIPELINE_STEP_SWAP;
- if (!config->mb_types)
- config->mb_types = MB_TYPE_I | MB_TYPE_P | MB_TYPE_B;
-}
-
-int main(int argc, char **argv)
-{
- struct Config config;
- Display *display;
- Window root, window;
- const unsigned int mc_types[2] = {XVMC_MOCOMP | XVMC_MPEG_2, XVMC_IDCT | XVMC_MPEG_2};
- XvPortID port_num;
- int surface_type_id;
- unsigned int is_overlay, intra_unsigned;
- int colorkey;
- XvMCContext context;
- XvMCSurface surface;
- XvMCBlockArray block_array;
- XvMCMacroBlockArray mb_array;
- unsigned int mbw, mbh;
- unsigned int mbx, mby;
- unsigned int reps;
- struct timeval start, stop, diff;
- double diff_secs;
-
- ParseArgs(argc, argv, &config);
-
- mbw = align(config.input_width, MACROBLOCK_WIDTH) / MACROBLOCK_WIDTH;
- mbh = align(config.input_height, MACROBLOCK_HEIGHT) / MACROBLOCK_HEIGHT;
-
- display = XOpenDisplay(NULL);
-
- if (!GetPort
- (
- display,
- config.input_width,
- config.input_height,
- XVMC_CHROMA_FORMAT_420,
- mc_types,
- 2,
- &port_num,
- &surface_type_id,
- &is_overlay,
- &intra_unsigned
- ))
- {
- XCloseDisplay(display);
- error(1, 0, "Error, unable to find a good port.\n");
- }
-
- if (is_overlay)
- {
- Atom xv_colorkey = XInternAtom(display, "XV_COLORKEY", 0);
- XvGetPortAttribute(display, port_num, xv_colorkey, &colorkey);
- }
-
- root = XDefaultRootWindow(display);
- window = XCreateSimpleWindow(display, root, 0, 0, config.output_width, config.output_height, 0, 0, colorkey);
-
- assert(XvMCCreateContext(display, port_num, surface_type_id, config.input_width, config.input_height, XVMC_DIRECT, &context) == Success);
- assert(XvMCCreateSurface(display, &context, &surface) == Success);
- assert(XvMCCreateBlocks(display, &context, mbw * mbh * BLOCKS_PER_MACROBLOCK, &block_array) == Success);
- assert(XvMCCreateMacroBlocks(display, &context, mbw * mbh, &mb_array) == Success);
-
- for (mby = 0; mby < mbh; ++mby)
- for (mbx = 0; mbx < mbw; ++mbx)
- {
- mb_array.macro_blocks[mby * mbw + mbx].x = mbx;
- mb_array.macro_blocks[mby * mbw + mbx].y = mby;
- mb_array.macro_blocks[mby * mbw + mbx].macroblock_type = XVMC_MB_TYPE_INTRA;
- /*mb->motion_type = ;*/
- /*mb->motion_vertical_field_select = ;*/
- mb_array.macro_blocks[mby * mbw + mbx].dct_type = XVMC_DCT_TYPE_FRAME;
- /*mb->PMV[0][0][0] = ;
- mb->PMV[0][0][1] = ;
- mb->PMV[0][1][0] = ;
- mb->PMV[0][1][1] = ;
- mb->PMV[1][0][0] = ;
- mb->PMV[1][0][1] = ;
- mb->PMV[1][1][0] = ;
- mb->PMV[1][1][1] = ;*/
- mb_array.macro_blocks[mby * mbw + mbx].index = (mby * mbw + mbx) * BLOCKS_PER_MACROBLOCK;
- mb_array.macro_blocks[mby * mbw + mbx].coded_block_pattern = 0x3F;
- }
-
- XSelectInput(display, window, ExposureMask | KeyPressMask);
- XMapWindow(display, window);
- XSync(display, 0);
-
- gettimeofday(&start, NULL);
-
- for (reps = 0; reps < config.reps; ++reps)
- {
- if (config.pipeline & PIPELINE_STEP_MC)
- {
- assert(XvMCRenderSurface(display, &context, XVMC_FRAME_PICTURE, &surface, NULL, NULL, 0, mbw * mbh, 0, &mb_array, &block_array) == Success);
- assert(XvMCFlushSurface(display, &surface) == Success);
- }
- if (config.pipeline & PIPELINE_STEP_CSC)
- assert(XvMCPutSurface(display, &surface, window, 0, 0, config.input_width, config.input_height, 0, 0, config.output_width, config.output_height, XVMC_FRAME_PICTURE) == Success);
- }
-
- gettimeofday(&stop, NULL);
-
- timeval_subtract(&diff, &stop, &start);
- diff_secs = (double)diff.tv_sec + (double)diff.tv_usec / 1000000.0;
-
- printf("XvMC Benchmark\n");
- printf("Input: %u,%u\nOutput: %u,%u\n", config.input_width, config.input_height, config.output_width, config.output_height);
- printf("Pipeline: ");
- if (config.pipeline & PIPELINE_STEP_MC)
- printf("|mc|");
- if (config.pipeline & PIPELINE_STEP_CSC)
- printf("|csc|");
- if (config.pipeline & PIPELINE_STEP_SWAP)
- printf("|swap|");
- printf("\n");
- printf("Reps: %u\n", config.reps);
- printf("Total time: %.2lf (%.2lf reps / sec)\n", diff_secs, config.reps / diff_secs);
-
- assert(XvMCDestroyBlocks(display, &block_array) == Success);
- assert(XvMCDestroyMacroBlocks(display, &mb_array) == Success);
- assert(XvMCDestroySurface(display, &surface) == Success);
- assert(XvMCDestroyContext(display, &context) == Success);
-
- XvUngrabPort(display, port_num, CurrentTime);
- XDestroyWindow(display, window);
- XCloseDisplay(display);
-
- return 0;
-}
diff --git a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h b/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
deleted file mode 100644
index 42337631ca..0000000000
--- a/src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef xvmc_private_h
-#define xvmc_private_h
-
-#include <X11/Xlib.h>
-#include <X11/extensions/XvMClib.h>
-
-#define BLOCK_SIZE_SAMPLES 64
-#define BLOCK_SIZE_BYTES (BLOCK_SIZE_SAMPLES * 2)
-
-struct pipe_video_context;
-struct pipe_surface;
-struct pipe_fence_handle;
-
-typedef struct
-{
- struct pipe_video_context *vpipe;
- struct pipe_surface *backbuffer;
-} XvMCContextPrivate;
-
-typedef struct
-{
- struct pipe_video_surface *pipe_vsfc;
- struct pipe_fence_handle *render_fence;
- struct pipe_fence_handle *disp_fence;
-
- /* Some XvMC functions take a surface but not a context,
- so we keep track of which context each surface belongs to. */
- XvMCContext *context;
-} XvMCSurfacePrivate;
-
-#endif /* xvmc_private_h */
diff --git a/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c
index 29316a1ce2..58c941a03b 100644
--- a/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c
+++ b/src/gallium/targets/libgl-gdi/gdi_llvmpipe_winsys.c
@@ -83,7 +83,7 @@ gdi_llvmpipe_present(struct pipe_screen *screen,
* other structs such as this stw_winsys as well...
*/
gdi_sw_display(llvmpipe_screen(screen)->winsys,
- llvmpipe_texture(surface->texture)->dt,
+ llvmpipe_resource(surface->texture)->dt,
hDC);
}
diff --git a/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c b/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c
index dfe60195d9..4ac507ff9c 100644
--- a/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c
+++ b/src/gallium/targets/libgl-gdi/gdi_softpipe_winsys.c
@@ -83,7 +83,7 @@ gdi_softpipe_present(struct pipe_screen *screen,
* other structs such as this stw_winsys as well...
*/
gdi_sw_display(softpipe_screen(screen)->winsys,
- softpipe_texture(surface->texture)->dt,
+ softpipe_resource(surface->texture)->dt,
hDC);
}
diff --git a/src/gallium/winsys/g3dvl/Makefile b/src/gallium/winsys/g3dvl/Makefile
deleted file mode 100644
index 424ddea87a..0000000000
--- a/src/gallium/winsys/g3dvl/Makefile
+++ /dev/null
@@ -1,11 +0,0 @@
-TOP = ../../../..
-include $(TOP)/configs/current
-
-SUBDIRS = $(GALLIUM_WINSYS_DIRS)
-
-default install clean:
- @for dir in $(SUBDIRS) ; do \
- if [ -d $$dir ] ; then \
- (cd $$dir && $(MAKE) $@) || exit 1; \
- fi \
- done
diff --git a/src/gallium/winsys/g3dvl/nouveau/Makefile b/src/gallium/winsys/g3dvl/nouveau/Makefile
deleted file mode 100644
index f07a7926d6..0000000000
--- a/src/gallium/winsys/g3dvl/nouveau/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-TARGET = libnouveau_dri.so
-GALLIUMDIR = ../../..
-DRMDIR ?= /usr
-DRIDIR = ../../../../driclient
-
-OBJECTS = nouveau_screen_vl.o nouveau_context_vl.o nouveau_swapbuffers.o
-
-CFLAGS += -g -Wall -Werror=implicit-function-declaration -fPIC \
- -I${GALLIUMDIR}/include \
- -I${GALLIUMDIR}/winsys/g3dvl \
- -I${GALLIUMDIR}/winsys/drm/nouveau \
- -I${DRMDIR}/include \
- -I${DRMDIR}/include/drm \
- -I${DRMDIR}/include/nouveau \
- -I${GALLIUMDIR}/drivers \
- -I${GALLIUMDIR}/auxiliary \
- -I${DRIDIR}/include
-
-LDFLAGS += -L${DRMDIR}/lib \
- -L${DRIDIR}/lib \
- -L${GALLIUMDIR}/winsys/drm/nouveau/common \
- -L${GALLIUMDIR}/auxiliary \
- -L${GALLIUMDIR}/drivers/nv30 \
- -L${GALLIUMDIR}/drivers/nv40 \
- -L${GALLIUMDIR}/drivers/nv50
-
-LIBS += -lnouveaudrm -ldriclient -ldrm_nouveau -ldrm -lnv30 -lnv40 -lnv50 -lgallium -lm
-
-#############################################
-
-.PHONY = all clean libdriclient
-
-all: ${TARGET}
-
-${TARGET}: ${OBJECTS} libdriclient
- $(CC) ${LDFLAGS} -shared -o $@ ${OBJECTS} ${LIBS}
-
-libdriclient:
- cd ${DRIDIR}/src; ${MAKE}
-
-clean:
- cd ${DRIDIR}/src; ${MAKE} clean
- rm -rf ${OBJECTS} ${TARGET}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.c
deleted file mode 100644
index dfc4905bc0..0000000000
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.c
+++ /dev/null
@@ -1,172 +0,0 @@
-#include "nouveau_context_vl.h"
-#include <pipe/p_defines.h>
-#include <pipe/p_context.h>
-#include <pipe/p_screen.h>
-#include <util/u_memory.h>
-#include <common/nouveau_dri.h>
-#include <common/nouveau_local.h>
-#include <common/nouveau_winsys_pipe.h>
-#include "nouveau_screen_vl.h"
-
-/*
-#ifdef DEBUG
-static const struct dri_debug_control debug_control[] = {
- { "bo", DEBUG_BO },
- { NULL, 0 }
-};
-int __nouveau_debug = 0;
-#endif
-*/
-
-int
-nouveau_context_create(dri_context_t *dri_context)
-{
- dri_screen_t *dri_screen;
- struct nouveau_screen_vl *nv_screen;
- struct nouveau_context_vl *nv;
-
- assert (dri_context);
-
- dri_screen = dri_context->dri_screen;
- nv_screen = dri_screen->private;
- nv = CALLOC_STRUCT(nouveau_context_vl);
-
- if (!nv)
- return 1;
-
- if (nouveau_context_init(&nv_screen->base, dri_context->drm_context,
- (drmLock*)&dri_screen->sarea->lock, NULL, &nv->base))
- {
- FREE(nv);
- return 1;
- }
-
- dri_context->private = (void*)nv;
- nv->dri_context = dri_context;
- nv->nv_screen = nv_screen;
-
- /*
- driParseConfigFiles(&nv->dri_option_cache, &nv_screen->option_cache,
- nv->dri_screen->myNum, "nouveau");
-#ifdef DEBUG
- __nouveau_debug = driParseDebugString(getenv("NOUVEAU_DEBUG"),
- debug_control);
-#endif
- */
-
- nv->base.nvc->pctx[nv->base.pctx_id]->priv = nv;
-
- return 0;
-}
-
-void
-nouveau_context_destroy(dri_context_t *dri_context)
-{
- struct nouveau_context_vl *nv = dri_context->private;
-
- assert(dri_context);
-
- nouveau_context_cleanup(&nv->base);
-
- FREE(nv);
-}
-
-int
-nouveau_context_bind(struct nouveau_context_vl *nv, dri_drawable_t *dri_drawable)
-{
- assert(nv);
- assert(dri_drawable);
-
- if (nv->dri_drawable != dri_drawable)
- {
- nv->dri_drawable = dri_drawable;
- dri_drawable->private = nv;
- }
-
- return 0;
-}
-
-int
-nouveau_context_unbind(struct nouveau_context_vl *nv)
-{
- assert(nv);
-
- nv->dri_drawable = NULL;
-
- return 0;
-}
-
-/* Show starts here */
-
-int bind_pipe_drawable(struct pipe_context *pipe, Drawable drawable)
-{
- struct nouveau_context_vl *nv;
- dri_drawable_t *dri_drawable;
-
- assert(pipe);
-
- nv = pipe->priv;
-
- driCreateDrawable(nv->nv_screen->dri_screen, drawable, &dri_drawable);
-
- nouveau_context_bind(nv, dri_drawable);
-
- return 0;
-}
-
-int unbind_pipe_drawable(struct pipe_context *pipe)
-{
- assert (pipe);
-
- nouveau_context_unbind(pipe->priv);
-
- return 0;
-}
-
-struct pipe_context* create_pipe_context(Display *display, int screen)
-{
- dri_screen_t *dri_screen;
- dri_framebuffer_t dri_framebuf;
- dri_context_t *dri_context;
- struct nouveau_context_vl *nv;
-
- assert(display);
-
- driCreateScreen(display, screen, &dri_screen, &dri_framebuf);
- driCreateContext(dri_screen, XDefaultVisual(display, screen), &dri_context);
-
- nouveau_screen_create(dri_screen, &dri_framebuf);
- nouveau_context_create(dri_context);
-
- nv = dri_context->private;
-
- return nv->base.nvc->pctx[nv->base.pctx_id];
-}
-
-int destroy_pipe_context(struct pipe_context *pipe)
-{
- struct pipe_screen *screen;
- struct pipe_winsys *winsys;
- struct nouveau_context_vl *nv;
- dri_screen_t *dri_screen;
- dri_context_t *dri_context;
-
- assert(pipe);
-
- screen = pipe->screen;
- winsys = pipe->winsys;
- nv = pipe->priv;
- dri_context = nv->dri_context;
- dri_screen = dri_context->dri_screen;
-
- pipe->destroy(pipe);
- screen->destroy(screen);
- FREE(winsys);
-
- nouveau_context_destroy(dri_context);
- nouveau_screen_destroy(dri_screen);
- driDestroyContext(dri_context);
- driDestroyScreen(dri_screen);
-
- return 0;
-}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.h
deleted file mode 100644
index 1115c3130c..0000000000
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_context_vl.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#ifndef __NOUVEAU_CONTEXT_VL_H__
-#define __NOUVEAU_CONTEXT_VL_H__
-
-#include <driclient.h>
-#include <nouveau/nouveau_winsys.h>
-#include <common/nouveau_context.h>
-
-/*#include "xmlconfig.h"*/
-
-struct nouveau_context_vl {
- struct nouveau_context base;
- struct nouveau_screen_vl *nv_screen;
- dri_context_t *dri_context;
- dri_drawable_t *dri_drawable;
- unsigned int last_stamp;
- /*driOptionCache dri_option_cache;*/
- drm_context_t drm_context;
- drmLock drm_lock;
-};
-
-extern int nouveau_context_create(dri_context_t *);
-extern void nouveau_context_destroy(dri_context_t *);
-extern int nouveau_context_bind(struct nouveau_context_vl *, dri_drawable_t *);
-extern int nouveau_context_unbind(struct nouveau_context_vl *);
-
-#ifdef DEBUG
-extern int __nouveau_debug;
-
-#define DEBUG_BO (1 << 0)
-
-#define DBG(flag, ...) do { \
- if (__nouveau_debug & (DEBUG_##flag)) \
- NOUVEAU_ERR(__VA_ARGS__); \
-} while(0)
-#else
-#define DBG(flag, ...)
-#endif
-
-#endif
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.c
deleted file mode 100644
index b7c74f8299..0000000000
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "nouveau_screen_vl.h"
-#include <util/u_memory.h>
-#include <nouveau_drm.h>
-#include <common/nouveau_dri.h>
-#include <common/nouveau_local.h>
-
-#if NOUVEAU_DRM_HEADER_PATCHLEVEL != 12
-#error nouveau_drm.h version does not match expected version
-#endif
-
-/*
-PUBLIC const char __driConfigOptions[] =
-DRI_CONF_BEGIN
-DRI_CONF_END;
-static const GLuint __driNConfigOptions = 0;
-*/
-
-int nouveau_check_dri_drm_ddx(dri_version_t *dri, dri_version_t *drm, dri_version_t *ddx)
-{
- static const dri_version_t ddx_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
- static const dri_version_t dri_expected = {4, 0, 0};
- static const dri_version_t drm_expected = {0, 0, NOUVEAU_DRM_HEADER_PATCHLEVEL};
-
- assert(dri);
- assert(drm);
- assert(ddx);
-
- if (dri->major != dri_expected.major || dri->minor < dri_expected.minor)
- {
- NOUVEAU_ERR("Unexpected DRI version.\n");
- return 1;
- }
- if (drm->major != drm_expected.major || drm->minor < drm_expected.minor)
- {
- NOUVEAU_ERR("Unexpected DRM version.\n");
- return 1;
- }
- if (ddx->major != ddx_expected.major || ddx->minor < ddx_expected.minor)
- {
- NOUVEAU_ERR("Unexpected DDX version.\n");
- return 1;
- }
-
- return 0;
-}
-
-int
-nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf)
-{
- struct nouveau_dri *nv_dri = dri_framebuf->private;
- struct nouveau_screen_vl *nv_screen;
-
- assert(dri_screen);
- assert(dri_framebuf);
-
- if (nouveau_check_dri_drm_ddx(&dri_screen->dri, &dri_screen->drm, &dri_screen->ddx))
- return 1;
-
- nv_screen = CALLOC_STRUCT(nouveau_screen_vl);
-
- if (!nv_screen)
- return 1;
-
- if (nouveau_screen_init(nv_dri, dri_screen->fd, &nv_screen->base))
- {
- FREE(nv_screen);
- return 1;
- }
-
- /*
- driParseOptionInfo(&nv_screen->option_cache,
- __driConfigOptions, __driNConfigOptions);
- */
-
- nv_screen->dri_screen = dri_screen;
- dri_screen->private = (void*)nv_screen;
-
- return 0;
-}
-
-void
-nouveau_screen_destroy(dri_screen_t *dri_screen)
-{
- struct nouveau_screen_vl *nv_screen = dri_screen->private;
-
- nouveau_screen_cleanup(&nv_screen->base);
- FREE(nv_screen);
-}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.h
deleted file mode 100644
index 0c1ceca6de..0000000000
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_screen_vl.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __NOUVEAU_SCREEN_VL_H__
-#define __NOUVEAU_SCREEN_VL_H__
-
-#include <driclient.h>
-#include <common/nouveau_screen.h>
-
-/* TODO: Investigate using DRI options for interesting things */
-/*#include "xmlconfig.h"*/
-
-struct nouveau_screen_vl
-{
- struct nouveau_screen base;
- dri_screen_t *dri_screen;
- /*driOptionCache option_cache;*/
-};
-
-int nouveau_screen_create(dri_screen_t *dri_screen, dri_framebuffer_t *dri_framebuf);
-void nouveau_screen_destroy(dri_screen_t *dri_screen);
-
-#endif
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c b/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c
deleted file mode 100644
index 77e46a2054..0000000000
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.c
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <driclient.h>
-#include <common/nouveau_local.h>
-#include <common/nouveau_screen.h>
-#include "nouveau_context_vl.h"
-#include "nouveau_swapbuffers.h"
-
-void
-nouveau_copy_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf,
- const drm_clip_rect_t *rect)
-{
- struct nouveau_context_vl *nv = dri_drawable->private;
- struct pipe_context *pipe = nv->base.nvc->pctx[nv->base.pctx_id];
- drm_clip_rect_t *pbox;
- int nbox, i;
-
- LOCK_HARDWARE(&nv->base);
- if (!dri_drawable->num_cliprects) {
- UNLOCK_HARDWARE(&nv->base);
- return;
- }
- pbox = dri_drawable->cliprects;
- nbox = dri_drawable->num_cliprects;
-
- for (i = 0; i < nbox; i++, pbox++) {
- int sx, sy, dx, dy, w, h;
-
- sx = pbox->x1 - dri_drawable->x;
- sy = pbox->y1 - dri_drawable->y;
- dx = pbox->x1;
- dy = pbox->y1;
- w = pbox->x2 - pbox->x1;
- h = pbox->y2 - pbox->y1;
-
- pipe->surface_copy(pipe, nv->base.frontbuffer,
- dx, dy, surf, sx, sy, w, h);
- }
-
- FIRE_RING(nv->base.nvc->channel);
- UNLOCK_HARDWARE(&nv->base);
-}
-
-void
-nouveau_copy_sub_buffer(dri_drawable_t *dri_drawable, struct pipe_surface *surf, int x, int y, int w, int h)
-{
- if (surf) {
- drm_clip_rect_t rect;
- rect.x1 = x;
- rect.y1 = y;
- rect.x2 = x + w;
- rect.y2 = y + h;
-
- nouveau_copy_buffer(dri_drawable, surf, &rect);
- }
-}
-
-void
-nouveau_swap_buffers(dri_drawable_t *dri_drawable, struct pipe_surface *surf)
-{
- if (surf)
- nouveau_copy_buffer(dri_drawable, surf, NULL);
-}
-
-void
-nouveau_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surf,
- void *context_private)
-{
- struct nouveau_context_vl *nv;
- dri_drawable_t *dri_drawable;
-
- assert(pws);
- assert(surf);
- assert(context_private);
-
- nv = context_private;
- dri_drawable = nv->dri_drawable;
-
- nouveau_copy_buffer(dri_drawable, surf, NULL);
-}
-
-void
-nouveau_contended_lock(struct nouveau_context *nv)
-{
- struct nouveau_context_vl *nv_vl = (struct nouveau_context_vl*)nv;
- dri_drawable_t *dri_drawable = nv_vl->dri_drawable;
- dri_screen_t *dri_screen = nv_vl->dri_context->dri_screen;
-
- /* If the window moved, may need to set a new cliprect now.
- *
- * NOTE: This releases and regains the hw lock, so all state
- * checking must be done *after* this call:
- */
- if (dri_drawable)
- DRI_VALIDATE_DRAWABLE_INFO(dri_screen, dri_drawable);
-}
diff --git a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.h b/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.h
deleted file mode 100644
index 35e934adba..0000000000
--- a/src/gallium/winsys/g3dvl/nouveau/nouveau_swapbuffers.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __NOUVEAU_SWAPBUFFERS_H__
-#define __NOUVEAU_SWAPBUFFERS_H__
-
-extern void nouveau_copy_buffer(dri_drawable_t *, struct pipe_surface *,
- const drm_clip_rect_t *);
-extern void nouveau_copy_sub_buffer(dri_drawable_t *, struct pipe_surface *,
- int x, int y, int w, int h);
-extern void nouveau_swap_buffers(dri_drawable_t *, struct pipe_surface *);
-
-#endif
diff --git a/src/gallium/winsys/g3dvl/vl_winsys.h b/src/gallium/winsys/g3dvl/vl_winsys.h
deleted file mode 100644
index b4fa0d67a1..0000000000
--- a/src/gallium/winsys/g3dvl/vl_winsys.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#ifndef vl_winsys_h
-#define vl_winsys_h
-
-#include <X11/Xlib.h>
-#include <pipe/p_defines.h>
-#include <pipe/p_format.h>
-
-struct pipe_screen;
-struct pipe_video_context;
-
-struct pipe_screen*
-vl_screen_create(Display *display, int screen);
-
-struct pipe_video_context*
-vl_video_create(Display *display, int screen,
- struct pipe_screen *p_screen,
- enum pipe_video_profile profile,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height);
-
-Drawable
-vl_video_bind_drawable(struct pipe_video_context *vpipe, Drawable drawable);
-
-#endif
diff --git a/src/gallium/winsys/g3dvl/xlib/Makefile b/src/gallium/winsys/g3dvl/xlib/Makefile
deleted file mode 100644
index 9877660a27..0000000000
--- a/src/gallium/winsys/g3dvl/xlib/Makefile
+++ /dev/null
@@ -1,68 +0,0 @@
-# This makefile produces a "stand-alone" libXvMCg3dvl.so which is
-# based on Xlib (no DRI HW acceleration)
-
-TOP = ../../../../..
-include $(TOP)/configs/current
-
-XVMC_MAJOR = 1
-XVMC_MINOR = 0
-XVMC_LIB = XvMCg3dvl
-XVMC_LIB_NAME = lib$(XVMC_LIB).so
-XVMC_LIB_DEPS = $(EXTRA_LIB_PATH) -lXvMC -lXv -lX11 -lm
-
-INCLUDES = -I$(TOP)/src/gallium/include \
- -I$(TOP)/src/gallium/auxiliary \
- -I$(TOP)/src/gallium/drivers \
- -I$(TOP)/src/gallium/winsys/g3dvl
-
-DEFINES += -DGALLIUM_SOFTPIPE \
- -DGALLIUM_TRACE
-
-SOURCES = xsp_winsys.c
-
-# XXX: Hack, if we include libxvmctracker.a in LIBS none of the symbols are
-# pulled in by the linker because xsp_winsys.c doesn't refer to them
-OBJECTS = $(SOURCES:.c=.o) $(TOP)/src/gallium/state_trackers/xorg/xvmc/*.o
-
-LIBS = $(TOP)/src/gallium/drivers/softpipe/libsoftpipe.a \
- $(TOP)/src/gallium/auxiliary/libgallium.a
-
-.c.o:
- $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@
-
-.S.o:
- $(CC) -c $(INCLUDES) $(DEFINES) $(CFLAGS) $< -o $@
-
-.PHONY: default $(TOP)/$(LIB_DIR)/gallium clean
-
-default: depend $(TOP)/$(LIB_DIR)/gallium $(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME)
-
-$(TOP)/$(LIB_DIR)/gallium:
- @mkdir -p $(TOP)/$(LIB_DIR)/gallium
-
-# Make the libXvMCg3dvl.so library
-$(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME): $(OBJECTS) $(LIBS) Makefile
- $(MKLIB) -o $(XVMC_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
- -major $(XVMC_MAJOR) -minor $(XVMC_MINOR) $(MKLIB_OPTIONS) \
- -install $(TOP)/$(LIB_DIR)/gallium -id $(INSTALL_LIB_DIR)/lib$(XVMC_LIB).1.dylib \
- $(XVMC_LIB_DEPS) $(OBJECTS) $(LIBS)
-
-depend: $(SOURCES) Makefile
- $(RM) depend
- touch depend
- $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(SOURCES)
-
-#install: default
-# $(INSTALL) -d $(INSTALL_DIR)/include/GL
-# $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR)
-# $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL
-# @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \
-# $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \
-# fi
-
-clean: Makefile
- $(RM) $(TOP)/$(LIB_DIR)/gallium/$(XVMC_LIB_NAME)
- $(RM) *.o *~
- $(RM) depend depend.bak
-
--include depend
diff --git a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c b/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
deleted file mode 100644
index 048af62ed3..0000000000
--- a/src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2009 Younes Manton.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include <vl_winsys.h>
-#include <X11/Xutil.h>
-#include <util/u_simple_screen.h>
-#include <pipe/p_state.h>
-#include <util/u_inlines.h>
-#include <util/u_format.h>
-#include <util/u_memory.h>
-#include <util/u_math.h>
-#include <softpipe/sp_winsys.h>
-#include <softpipe/sp_video_context.h>
-#include <softpipe/sp_texture.h>
-
-/* pipe_winsys implementation */
-
-struct xsp_pipe_winsys
-{
- struct pipe_winsys base;
- Display *display;
- int screen;
- XImage *fbimage;
-};
-
-struct xsp_context
-{
- Drawable drawable;
-
- void (*pipe_destroy)(struct pipe_video_context *vpipe);
-};
-
-struct xsp_buffer
-{
- struct pipe_buffer base;
- boolean is_user_buffer;
- void *data;
- void *mapped_data;
-};
-
-static struct pipe_buffer* xsp_buffer_create(struct pipe_winsys *pws, unsigned alignment, unsigned usage, unsigned size)
-{
- struct xsp_buffer *buffer;
-
- assert(pws);
-
- buffer = calloc(1, sizeof(struct xsp_buffer));
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.alignment = alignment;
- buffer->base.usage = usage;
- buffer->base.size = size;
- buffer->data = align_malloc(size, alignment);
-
- return (struct pipe_buffer*)buffer;
-}
-
-static struct pipe_buffer* xsp_user_buffer_create(struct pipe_winsys *pws, void *data, unsigned size)
-{
- struct xsp_buffer *buffer;
-
- assert(pws);
-
- buffer = calloc(1, sizeof(struct xsp_buffer));
- pipe_reference_init(&buffer->base.reference, 1);
- buffer->base.size = size;
- buffer->is_user_buffer = TRUE;
- buffer->data = data;
-
- return (struct pipe_buffer*)buffer;
-}
-
-static void* xsp_buffer_map(struct pipe_winsys *pws, struct pipe_buffer *buffer, unsigned flags)
-{
- struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
-
- assert(pws);
- assert(buffer);
-
- xsp_buf->mapped_data = xsp_buf->data;
-
- return xsp_buf->mapped_data;
-}
-
-static void xsp_buffer_unmap(struct pipe_winsys *pws, struct pipe_buffer *buffer)
-{
- struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
-
- assert(pws);
- assert(buffer);
-
- xsp_buf->mapped_data = NULL;
-}
-
-static void xsp_buffer_destroy(struct pipe_buffer *buffer)
-{
- struct xsp_buffer *xsp_buf = (struct xsp_buffer*)buffer;
-
- assert(buffer);
-
- if (!xsp_buf->is_user_buffer)
- align_free(xsp_buf->data);
-
- free(xsp_buf);
-}
-
-static struct pipe_buffer* xsp_surface_buffer_create
-(
- struct pipe_winsys *pws,
- unsigned width,
- unsigned height,
- enum pipe_format format,
- unsigned usage,
- unsigned tex_usage,
- unsigned *stride
-)
-{
- const unsigned int ALIGNMENT = 1;
- unsigned nblocksy;
-
- nblocksy = util_format_get_nblocksy(format, height);
- *stride = align(util_format_get_stride(format, width), ALIGNMENT);
-
- return pws->buffer_create(pws, ALIGNMENT, usage,
- *stride * nblocksy);
-}
-
-static void xsp_fence_reference(struct pipe_winsys *pws, struct pipe_fence_handle **ptr, struct pipe_fence_handle *fence)
-{
- assert(pws);
- assert(ptr);
- assert(fence);
-}
-
-static int xsp_fence_signalled(struct pipe_winsys *pws, struct pipe_fence_handle *fence, unsigned flag)
-{
- assert(pws);
- assert(fence);
-
- return 0;
-}
-
-static int xsp_fence_finish(struct pipe_winsys *pws, struct pipe_fence_handle *fence, unsigned flag)
-{
- assert(pws);
- assert(fence);
-
- return 0;
-}
-
-static void xsp_flush_frontbuffer(struct pipe_winsys *pws, struct pipe_surface *surface, void *context_private)
-{
- struct xsp_pipe_winsys *xsp_winsys;
- struct xsp_context *xsp_context;
-
- assert(pws);
- assert(surface);
- assert(context_private);
-
- xsp_winsys = (struct xsp_pipe_winsys*)pws;
- xsp_context = (struct xsp_context*)context_private;
- xsp_winsys->fbimage->width = surface->width;
- xsp_winsys->fbimage->height = surface->height;
- xsp_winsys->fbimage->bytes_per_line = surface->width * (xsp_winsys->fbimage->bits_per_pixel >> 3);
- xsp_winsys->fbimage->data = (char*)((struct xsp_buffer *)softpipe_texture(surface->texture)->buffer)->data + surface->offset;
-
- XPutImage
- (
- xsp_winsys->display, xsp_context->drawable,
- XDefaultGC(xsp_winsys->display, xsp_winsys->screen),
- xsp_winsys->fbimage, 0, 0, 0, 0,
- surface->width, surface->height
- );
- XFlush(xsp_winsys->display);
-}
-
-static const char* xsp_get_name(struct pipe_winsys *pws)
-{
- assert(pws);
- return "X11 SoftPipe";
-}
-
-static void xsp_destroy(struct pipe_winsys *pws)
-{
- struct xsp_pipe_winsys *xsp_winsys = (struct xsp_pipe_winsys*)pws;
-
- assert(pws);
-
- /* XDestroyImage() wants to free the data as well */
- xsp_winsys->fbimage->data = NULL;
-
- XDestroyImage(xsp_winsys->fbimage);
- FREE(xsp_winsys);
-}
-
-/* Called through pipe_video_context::destroy() */
-static void xsp_pipe_destroy(struct pipe_video_context *vpipe)
-{
- struct xsp_context *xsp_context;
-
- assert(vpipe);
-
- xsp_context = vpipe->priv;
-
- /* Call the original destroy */
- xsp_context->pipe_destroy(vpipe);
-
- FREE(xsp_context);
-}
-
-/* Show starts here */
-
-Drawable
-vl_video_bind_drawable(struct pipe_video_context *vpipe, Drawable drawable)
-{
- struct xsp_context *xsp_context;
- Drawable old_drawable;
-
- assert(vpipe);
-
- xsp_context = vpipe->priv;
- old_drawable = xsp_context->drawable;
- xsp_context->drawable = drawable;
-
- return old_drawable;
-}
-
-struct pipe_screen*
-vl_screen_create(Display *display, int screen)
-{
- struct xsp_pipe_winsys *xsp_winsys;
-
- assert(display);
-
- xsp_winsys = CALLOC_STRUCT(xsp_pipe_winsys);
- if (!xsp_winsys)
- return NULL;
-
- xsp_winsys->base.buffer_create = xsp_buffer_create;
- xsp_winsys->base.user_buffer_create = xsp_user_buffer_create;
- xsp_winsys->base.buffer_map = xsp_buffer_map;
- xsp_winsys->base.buffer_unmap = xsp_buffer_unmap;
- xsp_winsys->base.buffer_destroy = xsp_buffer_destroy;
- xsp_winsys->base.surface_buffer_create = xsp_surface_buffer_create;
- xsp_winsys->base.fence_reference = xsp_fence_reference;
- xsp_winsys->base.fence_signalled = xsp_fence_signalled;
- xsp_winsys->base.fence_finish = xsp_fence_finish;
- xsp_winsys->base.flush_frontbuffer = xsp_flush_frontbuffer;
- xsp_winsys->base.get_name = xsp_get_name;
- xsp_winsys->base.destroy = xsp_destroy;
- xsp_winsys->display = display;
- xsp_winsys->screen = screen;
- xsp_winsys->fbimage = XCreateImage
- (
- display,
- XDefaultVisual(display, screen),
- XDefaultDepth(display, screen),
- ZPixmap,
- 0,
- NULL,
- 0, /* Don't know the width and height until flush_frontbuffer */
- 0,
- 32,
- 0
- );
-
- if (!xsp_winsys->fbimage) {
- FREE(xsp_winsys);
- return NULL;
- }
-
- XInitImage(xsp_winsys->fbimage);
-
- return softpipe_create_screen(&xsp_winsys->base);
-}
-
-struct pipe_video_context*
-vl_video_create(Display *display, int screen,
- struct pipe_screen *p_screen,
- enum pipe_video_profile profile,
- enum pipe_video_chroma_format chroma_format,
- unsigned width, unsigned height)
-{
- struct pipe_video_context *vpipe;
- struct xsp_context *xsp_context;
-
- assert(p_screen);
- assert(width && height);
-
- vpipe = sp_video_create(p_screen, profile, chroma_format, width, height);
- if (!vpipe)
- return NULL;
-
- xsp_context = CALLOC_STRUCT(xsp_context);
- if (!xsp_context) {
- vpipe->destroy(vpipe);
- return NULL;
- }
-
- /* Override this so we can free our xsp_context when the pipe is freed */
- xsp_context->pipe_destroy = vpipe->destroy;
- vpipe->destroy = xsp_pipe_destroy;
-
- vpipe->priv = xsp_context;
-
- return vpipe;
-}
diff --git a/src/gallium/winsys/nouveau/drm/nouveau_drm_api.c b/src/gallium/winsys/nouveau/drm/nouveau_drm_api.c
index 716d4bacd3..6fd6009d3a 100644
--- a/src/gallium/winsys/nouveau/drm/nouveau_drm_api.c
+++ b/src/gallium/winsys/nouveau/drm/nouveau_drm_api.c
@@ -19,12 +19,16 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
unsigned width, unsigned height, unsigned pitch)
{
struct pipe_surface *ps = NULL;
- struct pipe_texture *pt = NULL;
- struct pipe_texture tmpl;
+ struct pipe_resource *pt = NULL;
+ struct pipe_resource tmpl;
struct winsys_handle whandle;
+ unsigned bind = (PIPE_BIND_SCANOUT |
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_DESTINATION |
+ PIPE_BIND_BLIT_SOURCE);
memset(&tmpl, 0, sizeof(tmpl));
- tmpl.tex_usage = PIPE_TEXTURE_USAGE_SCANOUT;
+ tmpl.bind = bind;
tmpl.target = PIPE_TEXTURE_2D;
tmpl.last_level = 0;
tmpl.depth0 = 1;
@@ -36,16 +40,14 @@ dri_surface_from_handle(struct drm_api *api, struct pipe_screen *pscreen,
whandle.stride = pitch;
whandle.handle = handle;
- pt = pscreen->texture_from_handle(pscreen, &tmpl, &whandle);
+ pt = pscreen->resource_from_handle(pscreen, &tmpl, &whandle);
if (!pt)
return NULL;
- ps = pscreen->get_tex_surface(pscreen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ ps = pscreen->get_tex_surface(pscreen, pt, 0, 0, 0, bind);
/* we don't need the texture from this point on */
- pipe_texture_reference(&pt, NULL);
+ pipe_resource_reference(&pt, NULL);
return ps;
}
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm.h b/src/gallium/winsys/radeon/drm/radeon_drm.h
index 2dc077c052..78451b6f01 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm.h
+++ b/src/gallium/winsys/radeon/drm/radeon_drm.h
@@ -37,22 +37,6 @@ struct pipe_screen* radeon_create_screen(struct drm_api* api,
int drmFB,
struct drm_create_screen_arg *arg);
-boolean radeon_buffer_from_texture(struct drm_api* api,
- struct pipe_screen* screen,
- struct pipe_texture* texture,
- struct pipe_buffer** buffer,
- unsigned* stride);
-
-boolean radeon_handle_from_buffer(struct drm_api* api,
- struct pipe_screen* screen,
- struct pipe_buffer* buffer,
- unsigned* handle);
-
-boolean radeon_global_handle_from_buffer(struct drm_api* api,
- struct pipe_screen* screen,
- struct pipe_buffer* buffer,
- unsigned* handle);
-
void radeon_destroy_drm_api(struct drm_api* api);
/* Guess at whether this chipset should use r300g.
diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
index 5fd20cc775..c9179a3620 100644
--- a/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
+++ b/src/gallium/winsys/radeon/drm/radeon_drm_buffer.c
@@ -72,9 +72,9 @@ radeon_drm_buffer_map(struct pb_buffer *_buf,
struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
int write = 0;
- if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
- if ((_buf->base.usage & PIPE_BUFFER_USAGE_VERTEX) ||
- (_buf->base.usage & PIPE_BUFFER_USAGE_INDEX))
+ if (flags & PIPE_TRANSFER_DONTBLOCK) {
+ if ((_buf->base.usage & PIPE_BIND_VERTEX_BUFFER) ||
+ (_buf->base.usage & PIPE_BIND_INDEX_BUFFER))
if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs))
return NULL;
}
@@ -82,7 +82,7 @@ radeon_drm_buffer_map(struct pb_buffer *_buf,
if (buf->bo->ptr != NULL)
return buf->bo->ptr;
- if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ if (flags & PIPE_TRANSFER_DONTBLOCK) {
uint32_t domain;
if (radeon_bo_is_busy(buf->bo, &domain))
return NULL;
@@ -92,7 +92,7 @@ radeon_drm_buffer_map(struct pb_buffer *_buf,
buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
}
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
+ if (flags & PIPE_TRANSFER_WRITE) {
write = 1;
}
@@ -148,16 +148,20 @@ static uint32_t radeon_domain_from_usage(unsigned usage)
{
uint32_t domain = 0;
- if (usage & PIPE_BUFFER_USAGE_GPU_WRITE) {
+ if (usage & PIPE_BIND_RENDER_TARGET) {
domain |= RADEON_GEM_DOMAIN_VRAM;
}
- if (usage & PIPE_BUFFER_USAGE_PIXEL) {
+ if (usage & PIPE_BIND_DEPTH_STENCIL) {
domain |= RADEON_GEM_DOMAIN_VRAM;
}
- if (usage & PIPE_BUFFER_USAGE_VERTEX) {
+ if (usage & PIPE_BIND_SAMPLER_VIEW) {
+ domain |= RADEON_GEM_DOMAIN_VRAM;
+ }
+ /* also need BIND_BLIT_SOURCE/DESTINATION ? */
+ if (usage & PIPE_BIND_VERTEX_BUFFER) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
- if (usage & PIPE_BUFFER_USAGE_INDEX) {
+ if (usage & PIPE_BIND_INDEX_BUFFER) {
domain |= RADEON_GEM_DOMAIN_GTT;
}
@@ -187,7 +191,7 @@ struct pb_buffer *radeon_drm_bufmgr_create_buffer_from_handle(struct pb_manager
pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = 0;
- buf->base.base.usage = PIPE_BUFFER_USAGE_PIXEL;
+ buf->base.base.usage = PIPE_BIND_SAMPLER_VIEW;
buf->base.base.size = 0;
buf->base.vtbl = &radeon_drm_buffer_vtbl;
buf->mgr = mgr;
diff --git a/src/gallium/winsys/radeon/drm/radeon_r300.c b/src/gallium/winsys/radeon/drm/radeon_r300.c
index 935c1d84d0..735b93bc77 100644
--- a/src/gallium/winsys/radeon/drm/radeon_r300.c
+++ b/src/gallium/winsys/radeon/drm/radeon_r300.c
@@ -42,10 +42,10 @@ radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
desc.alignment = alignment;
desc.usage = usage;
- if (usage & PIPE_BUFFER_USAGE_CONSTANT)
+ if (usage & PIPE_BIND_CONSTANT_BUFFER)
provider = ws->mman;
- else if ((usage & PIPE_BUFFER_USAGE_VERTEX) ||
- (usage & PIPE_BUFFER_USAGE_INDEX))
+ else if ((usage & PIPE_BIND_VERTEX_BUFFER) ||
+ (usage & PIPE_BIND_INDEX_BUFFER))
provider = ws->cman;
else
provider = ws->kman;
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index 870c6afc12..1bca827bd6 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -148,7 +148,7 @@ dri_sw_displaytarget_unmap(struct sw_winsys *ws,
static struct sw_displaytarget *
dri_sw_displaytarget_from_handle(struct sw_winsys *winsys,
- const struct pipe_texture *templ,
+ const struct pipe_resource *templ,
struct winsys_handle *whandle,
unsigned *stride)
{
diff --git a/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c
index 4dba4b577b..2e12f6e6cc 100644
--- a/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c
+++ b/src/gallium/winsys/sw/gdi/gdi_sw_winsys.c
@@ -172,7 +172,7 @@ no_gdt:
static struct sw_displaytarget *
gdi_sw_displaytarget_from_handle(struct sw_winsys *winsys,
- const struct pipe_texture *templet,
+ const struct pipe_resource *templet,
struct winsys_handle *whandle,
unsigned *stride)
{
diff --git a/src/gallium/winsys/sw/null/null_sw_winsys.c b/src/gallium/winsys/sw/null/null_sw_winsys.c
index 5027e57b30..157efa9973 100644
--- a/src/gallium/winsys/sw/null/null_sw_winsys.c
+++ b/src/gallium/winsys/sw/null/null_sw_winsys.c
@@ -91,7 +91,7 @@ null_sw_displaytarget_create(struct sw_winsys *winsys,
static struct sw_displaytarget *
null_sw_displaytarget_from_handle(struct sw_winsys *winsys,
- const struct pipe_texture *templet,
+ const struct pipe_resource *templet,
struct winsys_handle *whandle,
unsigned *stride)
{
diff --git a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
index 459b1c1e2a..9a68d9faff 100644
--- a/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
+++ b/src/gallium/winsys/sw/wrapper/wrapper_sw_winsys.c
@@ -57,7 +57,7 @@ struct wrapper_sw_winsys
struct wrapper_sw_displaytarget
{
struct wrapper_sw_winsys *winsys;
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
struct pipe_transfer *transfer;
unsigned width;
@@ -89,26 +89,26 @@ static boolean
wsw_dt_get_stride(struct wrapper_sw_displaytarget *wdt, unsigned *stride)
{
struct pipe_context *pipe = wdt->winsys->pipe;
- struct pipe_texture *tex = wdt->tex;
+ struct pipe_resource *tex = wdt->tex;
struct pipe_transfer *tr;
- tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
- 0, 0, wdt->width, wdt->height);
+ tr = pipe_get_transfer(pipe, tex, 0, 0, 0,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, wdt->width, wdt->height);
if (!tr)
return FALSE;
*stride = tr->stride;
wdt->stride = tr->stride;
- pipe->tex_transfer_destroy(pipe, tr);
+ pipe->transfer_destroy(pipe, tr);
return TRUE;
}
static struct sw_displaytarget *
wsw_dt_wrap_texture(struct wrapper_sw_winsys *wsw,
- struct pipe_texture *tex, unsigned *stride)
+ struct pipe_resource *tex, unsigned *stride)
{
struct wrapper_sw_displaytarget *wdt = CALLOC_STRUCT(wrapper_sw_displaytarget);
if (!wdt)
@@ -125,21 +125,21 @@ wsw_dt_wrap_texture(struct wrapper_sw_winsys *wsw,
err_free:
FREE(wdt);
err_unref:
- pipe_texture_reference(&tex, NULL);
+ pipe_resource_reference(&tex, NULL);
return NULL;
}
static struct sw_displaytarget *
wsw_dt_create(struct sw_winsys *ws,
- unsigned tex_usage,
+ unsigned bind,
enum pipe_format format,
unsigned width, unsigned height,
unsigned alignment,
unsigned *stride)
{
struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
- struct pipe_texture templ;
- struct pipe_texture *tex;
+ struct pipe_resource templ;
+ struct pipe_resource *tex;
/*
* XXX Why don't we just get the template.
@@ -148,11 +148,11 @@ wsw_dt_create(struct sw_winsys *ws,
templ.width0 = width;
templ.height0 = height;
templ.format = format;
- templ.tex_usage = tex_usage;
+ templ.bind = bind;
/* XXX alignment: we can't do anything about this */
- tex = wsw->screen->texture_create(wsw->screen, &templ);
+ tex = wsw->screen->resource_create(wsw->screen, &templ);
if (!tex)
return NULL;
@@ -161,14 +161,14 @@ wsw_dt_create(struct sw_winsys *ws,
static struct sw_displaytarget *
wsw_dt_from_handle(struct sw_winsys *ws,
- const struct pipe_texture *templ,
+ const struct pipe_resource *templ,
struct winsys_handle *whandle,
unsigned *stride)
{
struct wrapper_sw_winsys *wsw = wrapper_sw_winsys(ws);
- struct pipe_texture *tex;
+ struct pipe_resource *tex;
- tex = wsw->screen->texture_from_handle(wsw->screen, templ, whandle);
+ tex = wsw->screen->resource_from_handle(wsw->screen, templ, whandle);
if (!tex)
return NULL;
@@ -182,7 +182,7 @@ wsw_dt_map(struct sw_winsys *ws,
{
struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
struct pipe_context *pipe = wdt->winsys->pipe;
- struct pipe_texture *tex = wdt->tex;
+ struct pipe_resource *tex = wdt->tex;
struct pipe_transfer *tr;
void *ptr;
@@ -190,9 +190,9 @@ wsw_dt_map(struct sw_winsys *ws,
assert(!wdt->transfer);
- tr = pipe->get_tex_transfer(pipe, tex, 0, 0, 0,
- PIPE_TRANSFER_READ_WRITE,
- 0, 0, wdt->width, wdt->height);
+ tr = pipe_get_transfer(pipe, tex, 0, 0, 0,
+ PIPE_TRANSFER_READ_WRITE,
+ 0, 0, wdt->width, wdt->height);
if (!tr)
return NULL;
@@ -212,7 +212,7 @@ wsw_dt_map(struct sw_winsys *ws,
return wdt->ptr;
err:
- pipe->tex_transfer_destroy(pipe, tr);
+ pipe->transfer_destroy(pipe, tr);
return NULL;
}
@@ -231,7 +231,7 @@ wsw_dt_unmap(struct sw_winsys *ws,
return;
pipe->transfer_unmap(pipe, wdt->transfer);
- pipe->tex_transfer_destroy(pipe, wdt->transfer);
+ pipe->transfer_destroy(pipe, wdt->transfer);
wdt->transfer = NULL;
}
@@ -241,7 +241,7 @@ wsw_dt_destroy(struct sw_winsys *ws,
{
struct wrapper_sw_displaytarget *wdt = wrapper_sw_displaytarget(dt);
- pipe_texture_reference(&wdt->tex, NULL);
+ pipe_resource_reference(&wdt->tex, NULL);
FREE(wdt);
}
diff --git a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
index ad843b7def..ec4f919d08 100644
--- a/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
+++ b/src/gallium/winsys/sw/xlib/xlib_sw_winsys.c
@@ -49,7 +49,7 @@
#include <X11/extensions/XShm.h>
/**
- * Subclass of pipe_buffer for Xlib winsys.
+ * Display target for Xlib winsys.
* Low-level OS/window system memory buffer
*/
struct xm_displaytarget
@@ -412,7 +412,7 @@ no_xm_dt:
static struct sw_displaytarget *
xm_displaytarget_from_handle(struct sw_winsys *winsys,
- const struct pipe_texture *templet,
+ const struct pipe_resource *templet,
struct winsys_handle *whandle,
unsigned *stride)
{
diff --git a/src/mesa/es/state_tracker/st_cb_drawtex.c b/src/mesa/es/state_tracker/st_cb_drawtex.c
index f75f4861a2..6d387d5ccf 100644
--- a/src/mesa/es/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/es/state_tracker/st_cb_drawtex.c
@@ -115,7 +115,8 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
struct st_context *st = ctx->st;
struct pipe_context *pipe = st->pipe;
struct cso_context *cso = ctx->st->cso_context;
- struct pipe_buffer *vbuffer;
+ struct pipe_resource *vbuffer;
+ struct pipe_transfer *vbuffer_transfer;
GLuint i, numTexCoords, numAttribs;
GLboolean emitColor;
uint semantic_names[2 + MAX_TEXTURE_UNITS];
@@ -145,7 +146,7 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
/* create the vertex buffer */
- vbuffer = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
+ vbuffer = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER,
numAttribs * 4 * 4 * sizeof(GLfloat));
/* load vertex buffer */
@@ -161,8 +162,9 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
} while (0)
const GLfloat x0 = x, y0 = y, x1 = x + width, y1 = y + height;
- GLfloat *vbuf = (GLfloat *) pipe_buffer_map(pipe->screen, vbuffer,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ GLfloat *vbuf = (GLfloat *) pipe_buffer_map(pipe, vbuffer,
+ PIPE_TRANSFER_WRITE,
+ &vbuffer_transfer);
GLuint attr;
z = CLAMP(z, 0.0f, 1.0f);
@@ -227,7 +229,7 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
}
}
- pipe_buffer_unmap(pipe->screen, vbuffer);
+ pipe_buffer_unmap(pipe, vbuffer, vbuffer_transfer);
#undef SET_ATTRIB
}
@@ -277,7 +279,7 @@ st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
numAttribs); /* attribs/vert */
- pipe_buffer_reference(&vbuffer, NULL);
+ pipe_resource_reference(&vbuffer, NULL);
/* restore state */
cso_restore_viewport(cso);
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index d975cd66f7..5ac81bd4ee 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -57,7 +57,7 @@ void st_upload_constants( struct st_context *st,
unsigned shader_type)
{
struct pipe_context *pipe = st->pipe;
- struct pipe_buffer **cbuf = &st->state.constants[shader_type];
+ struct pipe_resource **cbuf = &st->state.constants[shader_type];
assert(shader_type == PIPE_SHADER_VERTEX ||
shader_type == PIPE_SHADER_FRAGMENT);
@@ -71,10 +71,10 @@ void st_upload_constants( struct st_context *st,
/* We always need to get a new buffer, to keep the drivers simple and
* avoid gratuitous rendering synchronization.
*/
- pipe_buffer_reference(cbuf, NULL );
- *cbuf = pipe_buffer_create(pipe->screen, 16,
- PIPE_BUFFER_USAGE_CONSTANT,
- paramBytes );
+ pipe_resource_reference(cbuf, NULL );
+ *cbuf = pipe_buffer_create(pipe->screen,
+ PIPE_BIND_CONSTANT_BUFFER,
+ paramBytes );
if (ST_DEBUG & DEBUG_CONSTANTS) {
debug_printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n",
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 79ad70909a..d33ddc83f6 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -45,7 +45,7 @@
/**
* When doing GL render to texture, we have to be sure that finalize_texture()
- * didn't yank out the pipe_texture that we earlier created a surface for.
+ * didn't yank out the pipe_resource that we earlier created a surface for.
* Check for that here and create a new surface if needed.
*/
static void
@@ -53,29 +53,30 @@ update_renderbuffer_surface(struct st_context *st,
struct st_renderbuffer *strb)
{
struct pipe_screen *screen = st->pipe->screen;
- struct pipe_texture *texture = strb->rtt->pt;
+ struct pipe_resource *resource = strb->rtt->pt;
int rtt_width = strb->Base.Width;
int rtt_height = strb->Base.Height;
if (!strb->surface ||
- strb->surface->texture != texture ||
+ strb->surface->texture != resource ||
strb->surface->width != rtt_width ||
strb->surface->height != rtt_height) {
GLuint level;
/* find matching mipmap level size */
- for (level = 0; level <= texture->last_level; level++) {
- if (u_minify(texture->width0, level) == rtt_width &&
- u_minify(texture->height0, level) == rtt_height) {
+ for (level = 0; level <= resource->last_level; level++) {
+ if (u_minify(resource->width0, level) == rtt_width &&
+ u_minify(resource->height0, level) == rtt_height) {
pipe_surface_reference(&strb->surface, NULL);
strb->surface = screen->get_tex_surface(screen,
- texture,
- strb->rtt_face,
- level,
- strb->rtt_slice,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ resource,
+ strb->rtt_face,
+ level,
+ strb->rtt_slice,
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION );
#if 0
printf("-- alloc new surface %d x %d into tex %p\n",
strb->surface->width, strb->surface->height,
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 03e3336144..4aac5bd97f 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -112,21 +112,21 @@ make_state_key(GLcontext *ctx, struct state_key *key)
}
-static struct pipe_texture *
+static struct pipe_resource *
create_color_map_texture(GLcontext *ctx)
{
struct pipe_context *pipe = ctx->st->pipe;
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
enum pipe_format format;
const uint texSize = 256; /* simple, and usually perfect */
/* find an RGBA texture format */
format = st_choose_format(pipe->screen, GL_RGBA,
- PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER);
+ PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
/* create texture for color map/table */
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0,
- texSize, texSize, 1, PIPE_TEXTURE_USAGE_SAMPLER);
+ texSize, texSize, 1, PIPE_BIND_SAMPLER_VIEW);
return pt;
}
@@ -135,7 +135,7 @@ create_color_map_texture(GLcontext *ctx)
* Update the pixelmap texture with the contents of the R/G/B/A pixel maps.
*/
static void
-load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
+load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt)
{
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_transfer *transfer;
@@ -150,7 +150,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
transfer = st_cond_flush_get_tex_transfer(st_context(ctx),
pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
0, 0, texSize, texSize);
- dest = (uint *) pipe->transfer_map(pipe, transfer);
+ dest = (uint *) pipe_transfer_map(pipe, transfer);
/* Pack four 1D maps into a 2D texture:
* R map is placed horizontally, indexed by S, in channel 0
@@ -171,8 +171,8 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
}
}
- pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe_transfer_unmap(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
}
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 01aba3e3dd..a693141921 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -137,7 +137,8 @@ accum_accum(struct st_context *st, GLfloat value,
if (ST_DEBUG & DEBUG_FALLBACK)
debug_printf("%s: fallback processing\n", __FUNCTION__);
- color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture,
+ color_trans = st_cond_flush_get_tex_transfer(st,
+ color_strb->texture,
0, 0, 0,
PIPE_TRANSFER_READ, xpos, ypos,
width, height);
@@ -165,7 +166,7 @@ accum_accum(struct st_context *st, GLfloat value,
}
free(buf);
- pipe->tex_transfer_destroy(pipe, color_trans);
+ pipe->transfer_destroy(pipe, color_trans);
}
@@ -213,7 +214,7 @@ accum_load(struct st_context *st, GLfloat value,
}
free(buf);
- pipe->tex_transfer_destroy(pipe, color_trans);
+ pipe->transfer_destroy(pipe, color_trans);
}
@@ -280,7 +281,7 @@ accum_return(GLcontext *ctx, GLfloat value,
pipe_put_tile_rgba(pipe, color_trans, 0, 0, width, height, buf);
free(buf);
- pipe->tex_transfer_destroy(pipe, color_trans);
+ pipe->transfer_destroy(pipe, color_trans);
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 9a0446bb71..074fc27711 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -92,7 +92,7 @@ struct bitmap_cache
/** Bitmap's Z position */
GLfloat zpos;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_transfer *trans;
GLboolean empty;
@@ -253,7 +253,7 @@ unpack_bitmap(struct st_context *st,
/**
* Create a texture which represents a bitmap image.
*/
-static struct pipe_texture *
+static struct pipe_resource *
make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap)
@@ -261,7 +261,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_transfer *transfer;
ubyte *dest;
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
/* PBO source... */
bitmap = _mesa_map_pbo_source(ctx, unpack, bitmap);
@@ -274,7 +274,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
*/
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, ctx->st->bitmap.tex_format,
0, width, height, 1,
- PIPE_TEXTURE_USAGE_SAMPLER);
+ PIPE_BIND_SAMPLER_VIEW);
if (!pt) {
_mesa_unmap_pbo_source(ctx, unpack);
return NULL;
@@ -284,7 +284,7 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
PIPE_TRANSFER_WRITE,
0, 0, width, height);
- dest = pipe->transfer_map(pipe, transfer);
+ dest = pipe_transfer_map(pipe, transfer);
/* Put image into texture transfer */
memset(dest, 0xff, height * transfer->stride);
@@ -294,8 +294,8 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
_mesa_unmap_pbo_source(ctx, unpack);
/* Release transfer */
- pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe_transfer_unmap(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
return pt;
}
@@ -334,13 +334,13 @@ setup_bitmap_vertex_data(struct st_context *st,
GLuint i;
if (st->bitmap.vbuf_slot >= max_slots) {
- pipe_buffer_reference(&st->bitmap.vbuf, NULL);
+ pipe_resource_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf_slot = 0;
}
if (!st->bitmap.vbuf) {
- st->bitmap.vbuf = pipe_buffer_create(pipe->screen, 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ st->bitmap.vbuf = pipe_buffer_create(pipe->screen,
+ PIPE_BIND_VERTEX_BUFFER,
max_slots * sizeof(st->bitmap.vertices));
}
@@ -530,7 +530,7 @@ reset_cache(struct st_context *st)
cache->ymax = -1000000;
if (cache->trans) {
- pipe->tex_transfer_destroy(pipe, cache->trans);
+ pipe->transfer_destroy(pipe, cache->trans);
cache->trans = NULL;
}
@@ -540,7 +540,8 @@ reset_cache(struct st_context *st)
cache->texture = st_texture_create(st, PIPE_TEXTURE_2D,
st->bitmap.tex_format, 0,
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
- 1, PIPE_TEXTURE_USAGE_SAMPLER);
+ 1,
+ PIPE_BIND_SAMPLER_VIEW);
}
@@ -580,7 +581,7 @@ create_cache_trans(struct st_context *st)
PIPE_TRANSFER_WRITE, 0, 0,
BITMAP_CACHE_WIDTH,
BITMAP_CACHE_HEIGHT);
- cache->buffer = pipe->transfer_map(pipe, cache->trans);
+ cache->buffer = pipe_transfer_map(pipe, cache->trans);
/* init image to all 0xff */
memset(cache->buffer, 0xff, cache->trans->stride * BITMAP_CACHE_HEIGHT);
@@ -614,10 +615,10 @@ st_flush_bitmap_cache(struct st_context *st)
if (cache->trans) {
if (0)
print_cache(cache);
- pipe->transfer_unmap(pipe, cache->trans);
+ pipe_transfer_unmap(pipe, cache->trans);
cache->buffer = NULL;
- pipe->tex_transfer_destroy(pipe, cache->trans);
+ pipe->transfer_destroy(pipe, cache->trans);
cache->trans = NULL;
}
@@ -636,7 +637,7 @@ st_flush_bitmap_cache(struct st_context *st)
}
/* release/free the texture */
- pipe_texture_reference(&cache->texture, NULL);
+ pipe_resource_reference(&cache->texture, NULL);
reset_cache(st);
}
@@ -652,7 +653,7 @@ st_flush_bitmap( struct st_context *st )
/* Release vertex buffer to avoid synchronous rendering if we were
* to map it in the next frame.
*/
- pipe_buffer_reference(&st->bitmap.vbuf, NULL);
+ pipe_resource_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf_slot = 0;
}
@@ -732,7 +733,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap )
{
struct st_context *st = ctx->st;
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
if (width == 0 || height == 0)
return;
@@ -768,7 +769,7 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
/* release/free the texture */
- pipe_texture_reference(&pt, NULL);
+ pipe_resource_reference(&pt, NULL);
}
}
@@ -805,15 +806,15 @@ st_init_bitmap(struct st_context *st)
/* find a usable texture format */
if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
}
else if (screen->is_format_supported(screen, PIPE_FORMAT_A8_UNORM, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_A8_UNORM;
}
else if (screen->is_format_supported(screen, PIPE_FORMAT_L8_UNORM, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_L8_UNORM;
}
else {
@@ -843,16 +844,16 @@ st_destroy_bitmap(struct st_context *st)
}
if (st->bitmap.vbuf) {
- pipe_buffer_reference(&st->bitmap.vbuf, NULL);
+ pipe_resource_reference(&st->bitmap.vbuf, NULL);
st->bitmap.vbuf = NULL;
}
if (cache) {
if (cache->trans) {
- pipe->transfer_unmap(pipe, cache->trans);
- pipe->tex_transfer_destroy(pipe, cache->trans);
+ pipe_transfer_unmap(pipe, cache->trans);
+ pipe->transfer_destroy(pipe, cache->trans);
}
- pipe_texture_reference(&st->bitmap.cache->texture, NULL);
+ pipe_resource_reference(&st->bitmap.cache->texture, NULL);
free(st->bitmap.cache);
st->bitmap.cache = NULL;
}
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 06b0a18fd2..0498080ccf 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -128,7 +128,7 @@ st_BlitFramebuffer(GLcontext *ctx,
srcAtt->CubeMapFace,
srcAtt->TextureLevel,
srcAtt->Zoffset,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BIND_BLIT_SOURCE);
if(!srcSurf)
return;
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index b55a085cc7..f24145844b 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -76,9 +76,10 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
struct st_buffer_object *st_obj = st_buffer_object(obj);
assert(obj->RefCount == 0);
+ assert(st_obj->transfer == NULL);
if (st_obj->buffer)
- pipe_buffer_reference(&st_obj->buffer, NULL);
+ pipe_resource_reference(&st_obj->buffer, NULL);
free(st_obj);
}
@@ -116,8 +117,15 @@ st_bufferobj_subdata(GLcontext *ctx,
if (!data)
return;
- st_cond_flush_pipe_buffer_write(st_context(ctx), st_obj->buffer,
- offset, size, data);
+ /* Now that transfers are per-context, we don't have to figure out
+ * flushing here. Usually drivers won't need to flush in this case
+ * even if the buffer is currently referenced by hardware - they
+ * just queue the upload as dma rather than mapping the underlying
+ * buffer directly.
+ */
+ pipe_buffer_write(st_context(ctx)->pipe,
+ st_obj->buffer,
+ offset, size, data);
}
@@ -141,8 +149,8 @@ st_bufferobj_get_subdata(GLcontext *ctx,
if (!size)
return;
- st_cond_flush_pipe_buffer_read(st_context(ctx), st_obj->buffer,
- offset, size, data);
+ pipe_buffer_read(st_context(ctx)->pipe, st_obj->buffer,
+ offset, size, data);
}
@@ -172,22 +180,24 @@ st_bufferobj_data(GLcontext *ctx,
switch(target) {
case GL_PIXEL_PACK_BUFFER_ARB:
case GL_PIXEL_UNPACK_BUFFER_ARB:
- buffer_usage = PIPE_BUFFER_USAGE_PIXEL;
+ buffer_usage = (PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION);
break;
case GL_ARRAY_BUFFER_ARB:
- buffer_usage = PIPE_BUFFER_USAGE_VERTEX;
+ buffer_usage = PIPE_BIND_VERTEX_BUFFER;
break;
case GL_ELEMENT_ARRAY_BUFFER_ARB:
- buffer_usage = PIPE_BUFFER_USAGE_INDEX;
+ buffer_usage = PIPE_BIND_INDEX_BUFFER;
break;
default:
buffer_usage = 0;
}
- pipe_buffer_reference( &st_obj->buffer, NULL );
+ pipe_resource_reference( &st_obj->buffer, NULL );
if (size != 0) {
- st_obj->buffer = pipe_buffer_create(pipe->screen, 32, buffer_usage, size);
+ st_obj->buffer = pipe_buffer_create(pipe->screen, buffer_usage, size);
if (!st_obj->buffer) {
return GL_FALSE;
@@ -215,21 +225,22 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
switch (access) {
case GL_WRITE_ONLY:
- flags = PIPE_BUFFER_USAGE_CPU_WRITE;
+ flags = PIPE_TRANSFER_WRITE;
break;
case GL_READ_ONLY:
- flags = PIPE_BUFFER_USAGE_CPU_READ;
+ flags = PIPE_TRANSFER_READ;
break;
case GL_READ_WRITE:
- /* fall-through */
default:
- flags = PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE;
+ flags = PIPE_TRANSFER_READ_WRITE;
break;
}
- obj->Pointer = st_cond_flush_pipe_buffer_map(st_context(ctx),
- st_obj->buffer,
- flags);
+ obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe,
+ st_obj->buffer,
+ flags,
+ &st_obj->transfer);
+
if (obj->Pointer) {
obj->Offset = 0;
obj->Length = obj->Size;
@@ -255,25 +266,25 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
- uint flags = 0x0;
+ enum pipe_transfer_usage flags = 0x0;
if (access & GL_MAP_WRITE_BIT)
- flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+ flags |= PIPE_TRANSFER_WRITE;
if (access & GL_MAP_READ_BIT)
- flags |= PIPE_BUFFER_USAGE_CPU_READ;
+ flags |= PIPE_TRANSFER_READ;
if (access & GL_MAP_FLUSH_EXPLICIT_BIT)
- flags |= PIPE_BUFFER_USAGE_FLUSH_EXPLICIT;
+ flags |= PIPE_TRANSFER_FLUSH_EXPLICIT;
if (access & GL_MAP_UNSYNCHRONIZED_BIT)
- flags |= PIPE_BUFFER_USAGE_UNSYNCHRONIZED;
+ flags |= PIPE_TRANSFER_UNSYNCHRONIZED;
/* ... other flags ...
*/
if (access & MESA_MAP_NOWAIT_BIT)
- flags |= PIPE_BUFFER_USAGE_DONTBLOCK;
+ flags |= PIPE_TRANSFER_DONTBLOCK;
assert(offset >= 0);
assert(length >= 0);
@@ -288,7 +299,11 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
obj->Pointer = &st_bufferobj_zero_length_range;
}
else {
- obj->Pointer = pipe_buffer_map_range(pipe->screen, st_obj->buffer, offset, length, flags);
+ obj->Pointer = pipe_buffer_map_range(pipe,
+ st_obj->buffer,
+ offset, length,
+ flags,
+ &st_obj->transfer);
if (obj->Pointer) {
obj->Pointer = (ubyte *) obj->Pointer + offset;
}
@@ -316,11 +331,12 @@ st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target,
assert(offset >= 0);
assert(length >= 0);
assert(offset + length <= obj->Length);
+ assert(obj->Pointer);
if (!length)
return;
- pipe_buffer_flush_mapped_range(pipe->screen, st_obj->buffer,
+ pipe_buffer_flush_mapped_range(pipe, st_obj->transfer,
obj->Offset + offset, length);
}
@@ -334,9 +350,10 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
- if(obj->Length)
- pipe_buffer_unmap(pipe->screen, st_obj->buffer);
+ if (obj->Length)
+ pipe_buffer_unmap(pipe, st_obj->buffer, st_obj->transfer);
+ st_obj->transfer = NULL;
obj->Pointer = NULL;
obj->Offset = 0;
obj->Length = 0;
@@ -357,6 +374,8 @@ st_copy_buffer_subdata(GLcontext *ctx,
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *srcObj = st_buffer_object(src);
struct st_buffer_object *dstObj = st_buffer_object(dst);
+ struct pipe_transfer *src_transfer;
+ struct pipe_transfer *dst_transfer;
ubyte *srcPtr, *dstPtr;
if(!size)
@@ -366,21 +385,36 @@ st_copy_buffer_subdata(GLcontext *ctx,
assert(!src->Pointer);
assert(!dst->Pointer);
- srcPtr = (ubyte *) pipe_buffer_map_range(pipe->screen,
+ srcPtr = (ubyte *) pipe_buffer_map_range(pipe,
srcObj->buffer,
readOffset, size,
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &src_transfer);
- dstPtr = (ubyte *) pipe_buffer_map_range(pipe->screen,
+ dstPtr = (ubyte *) pipe_buffer_map_range(pipe,
dstObj->buffer,
writeOffset, size,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ PIPE_TRANSFER_WRITE,
+ &dst_transfer);
if (srcPtr && dstPtr)
memcpy(dstPtr + writeOffset, srcPtr + readOffset, size);
- pipe_buffer_unmap(pipe->screen, srcObj->buffer);
- pipe_buffer_unmap(pipe->screen, dstObj->buffer);
+ pipe_buffer_unmap(pipe, srcObj->buffer, src_transfer);
+ pipe_buffer_unmap(pipe, dstObj->buffer, dst_transfer);
+}
+
+
+/* TODO: if buffer wasn't created with appropriate usage flags, need
+ * to recreate it now and copy contents -- or possibly create a
+ * gallium entrypoint to extend the usage flags and let the driver
+ * decide if a copy is necessary.
+ */
+void
+st_bufferobj_validate_usage(struct st_context *st,
+ struct st_buffer_object *obj,
+ unsigned usage)
+{
}
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.h b/src/mesa/state_tracker/st_cb_bufferobjects.h
index fda6d05dd3..955673ceb6 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.h
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.h
@@ -30,7 +30,7 @@
struct st_context;
struct gl_buffer_object;
-struct pipe_buffer;
+struct pipe_resource;
/**
* State_tracker vertex/pixel buffer object, derived from Mesa's
@@ -39,7 +39,8 @@ struct pipe_buffer;
struct st_buffer_object
{
struct gl_buffer_object Base;
- struct pipe_buffer *buffer;
+ struct pipe_resource *buffer; /* GPU storage */
+ struct pipe_transfer *transfer; /* In-progress map information */
};
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 6007c76718..eb9ba0557d 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -99,7 +99,7 @@ st_destroy_clear(struct st_context *st)
st->clear.vs = NULL;
}
if (st->clear.vbuf) {
- pipe_buffer_reference(&st->clear.vbuf, NULL);
+ pipe_resource_reference(&st->clear.vbuf, NULL);
st->clear.vbuf = NULL;
}
}
@@ -131,13 +131,13 @@ draw_quad(GLcontext *ctx,
GLuint i;
if (st->clear.vbuf_slot >= max_slots) {
- pipe_buffer_reference(&st->clear.vbuf, NULL);
+ pipe_resource_reference(&st->clear.vbuf, NULL);
st->clear.vbuf_slot = 0;
}
if (!st->clear.vbuf) {
- st->clear.vbuf = pipe_buffer_create(pipe->screen, 32,
- PIPE_BUFFER_USAGE_VERTEX,
+ st->clear.vbuf = pipe_buffer_create(pipe->screen,
+ PIPE_BIND_VERTEX_BUFFER,
max_slots * sizeof(st->clear.vertices));
}
@@ -435,7 +435,7 @@ st_flush_clear(struct st_context *st)
/* Release vertex buffer to avoid synchronous rendering if we were
* to map it in the next frame.
*/
- pipe_buffer_reference(&st->clear.vbuf, NULL);
+ pipe_resource_reference(&st->clear.vbuf, NULL);
st->clear.vbuf_slot = 0;
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 93b95a534c..955e371398 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -296,13 +296,13 @@ base_format(GLenum format)
* If width, height are not POT and the driver only handles POT textures,
* allocate the next larger size of texture that is POT.
*/
-static struct pipe_texture *
+static struct pipe_resource *
alloc_texture(struct st_context *st, GLsizei width, GLsizei height,
enum pipe_format texFormat)
{
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
int ptw, pth;
ptw = width;
@@ -330,7 +330,7 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height,
}
pt = st_texture_create(st, PIPE_TEXTURE_2D, texFormat, 0,
- ptw, pth, 1, PIPE_TEXTURE_USAGE_SAMPLER);
+ ptw, pth, 1, PIPE_BIND_SAMPLER_VIEW);
return pt;
}
@@ -340,7 +340,7 @@ alloc_texture(struct st_context *st, GLsizei width, GLsizei height,
* Make texture containing an image for glDrawPixels image.
* If 'pixels' is NULL, leave the texture image data undefined.
*/
-static struct pipe_texture *
+static struct pipe_resource *
make_texture(struct st_context *st,
GLsizei width, GLsizei height, GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
@@ -349,7 +349,7 @@ make_texture(struct st_context *st,
GLcontext *ctx = st->ctx;
struct pipe_context *pipe = st->pipe;
gl_format mformat;
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
enum pipe_format pipeFormat;
GLuint cpp;
GLenum baseFormat;
@@ -389,7 +389,7 @@ make_texture(struct st_context *st,
width, height);
/* map texture transfer */
- dest = pipe->transfer_map(pipe, transfer);
+ dest = pipe_transfer_map(pipe, transfer);
/* Put image into texture transfer.
@@ -409,8 +409,8 @@ make_texture(struct st_context *st,
unpack);
/* unmap */
- pipe->transfer_unmap(pipe, transfer);
- pipe->tex_transfer_destroy(pipe, transfer);
+ pipe_transfer_unmap(pipe, transfer);
+ pipe->transfer_destroy(pipe, transfer);
assert(success);
@@ -502,10 +502,11 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
}
{
- struct pipe_buffer *buf;
+ struct pipe_resource *buf;
/* allocate/load buffer object with vertex data */
- buf = pipe_buffer_create(pipe->screen, 32, PIPE_BUFFER_USAGE_VERTEX,
+ buf = pipe_buffer_create(pipe->screen,
+ PIPE_BIND_VERTEX_BUFFER,
sizeof(verts));
st_no_flush_pipe_buffer_write(st, buf, 0, sizeof(verts), verts);
@@ -513,7 +514,7 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
PIPE_PRIM_QUADS,
4, /* verts */
3); /* attribs/vert */
- pipe_buffer_reference(&buf, NULL);
+ pipe_resource_reference(&buf, NULL);
}
}
@@ -688,7 +689,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
usage, x, y,
width, height);
- stmap = pipe->transfer_map(pipe, pt);
+ stmap = pipe_transfer_map(pipe, pt);
pixels = _mesa_map_pbo_source(ctx, &clippedUnpack, pixels);
assert(pixels);
@@ -733,7 +734,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
/* now pack the stencil (and Z) values in the dest format */
- switch (pt->texture->format) {
+ switch (pt->resource->format) {
case PIPE_FORMAT_S8_USCALED:
{
ubyte *dest = stmap + spanY * pt->stride + spanX;
@@ -788,8 +789,8 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
_mesa_unmap_pbo_source(ctx, &clippedUnpack);
/* unmap the stencil buffer */
- pipe->transfer_unmap(pipe, pt);
- pipe->tex_transfer_destroy(pipe, pt);
+ pipe_transfer_unmap(pipe, pt);
+ pipe->transfer_destroy(pipe, pt);
}
@@ -830,7 +831,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
/* draw with textured quad */
{
- struct pipe_texture *pt
+ struct pipe_resource *pt
= make_texture(st, width, height, format, type, unpack, pixels);
if (pt) {
struct pipe_sampler_view *sv = st_sampler_view_from_texture(st->pipe, pt);
@@ -844,7 +845,7 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
color, GL_FALSE);
pipe_sampler_view_reference(&sv, NULL);
}
- pipe_texture_reference(&pt, NULL);
+ pipe_resource_reference(&pt, NULL);
}
}
}
@@ -889,11 +890,11 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
usage, dstx, dsty,
width, height);
- assert(util_format_get_blockwidth(ptDraw->texture->format) == 1);
- assert(util_format_get_blockheight(ptDraw->texture->format) == 1);
+ assert(util_format_get_blockwidth(ptDraw->resource->format) == 1);
+ assert(util_format_get_blockheight(ptDraw->resource->format) == 1);
/* map the stencil buffer */
- drawMap = pipe->transfer_map(pipe, ptDraw);
+ drawMap = pipe_transfer_map(pipe, ptDraw);
/* draw */
/* XXX PixelZoom not handled yet */
@@ -911,7 +912,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
dst = drawMap + y * ptDraw->stride;
src = buffer + i * width;
- switch (ptDraw->texture->format) {
+ switch (ptDraw->resource->format) {
case PIPE_FORMAT_Z24_UNORM_S8_USCALED:
{
uint *dst4 = (uint *) dst;
@@ -946,8 +947,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
free(buffer);
/* unmap the stencil buffer */
- pipe->transfer_unmap(pipe, ptDraw);
- pipe->tex_transfer_destroy(pipe, ptDraw);
+ pipe_transfer_unmap(pipe, ptDraw);
+ pipe->transfer_destroy(pipe, ptDraw);
}
@@ -961,7 +962,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
struct pipe_screen *screen = pipe->screen;
struct st_renderbuffer *rbRead;
void *driver_vp, *driver_fp;
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
struct pipe_sampler_view *sv;
GLfloat *color;
enum pipe_format srcFormat, texFormat;
@@ -996,7 +997,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
srcFormat = rbRead->texture->format;
if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
texFormat = srcFormat;
}
else {
@@ -1004,13 +1005,13 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (type == GL_DEPTH) {
texFormat = st_choose_format(screen, GL_DEPTH_COMPONENT,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL);
+ PIPE_BIND_DEPTH_STENCIL);
assert(texFormat != PIPE_FORMAT_NONE);
}
else {
/* default color format */
texFormat = st_choose_format(screen, GL_RGBA, PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER);
+ PIPE_BIND_SAMPLER_VIEW);
assert(texFormat != PIPE_FORMAT_NONE);
}
}
@@ -1042,7 +1043,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
sv = st_sampler_view_from_texture(st->pipe, pt);
if (!sv) {
- pipe_texture_reference(&pt, NULL);
+ pipe_resource_reference(&pt, NULL);
return;
}
@@ -1052,10 +1053,10 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
/* copy source framebuffer surface into mipmap/texture */
struct pipe_surface *psRead = screen->get_tex_surface(screen,
rbRead->texture, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BIND_BLIT_SOURCE);
struct pipe_surface *psTex = screen->get_tex_surface(screen, pt, 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE );
-
+ PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_DESTINATION);
pipe->surface_copy(pipe,
psTex, /* dest surf */
pack.SkipPixels, pack.SkipRows, /* dest pos */
@@ -1109,8 +1110,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
free(buf);
}
- pipe->tex_transfer_destroy(pipe, ptRead);
- pipe->tex_transfer_destroy(pipe, ptTex);
+ pipe->transfer_destroy(pipe, ptRead);
+ pipe->transfer_destroy(pipe, ptTex);
}
/* OK, the texture 'pt' contains the src image/pixels. Now draw a
@@ -1123,7 +1124,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
driver_fp,
color, invertTex);
- pipe_texture_reference(&pt, NULL);
+ pipe_resource_reference(&pt, NULL);
pipe_sampler_view_reference(&sv, NULL);
}
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index 934b70dc1a..3c4fe32090 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -79,7 +79,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx,
struct pipe_surface *ps;
unsigned usage;
- usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
+ usage = PIPE_BIND_RENDER_TARGET | PIPE_BIND_BLIT_SOURCE | PIPE_BIND_BLIT_DESTINATION;
ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
if (ps) {
strb->Base.Width = ps->width;
@@ -90,7 +90,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx,
strb->Base.InternalFormat = strb->Base._BaseFormat;
pipe_surface_reference(&strb->surface, ps);
- pipe_texture_reference(&strb->texture, ps->texture);
+ pipe_resource_reference(&strb->texture, ps->texture);
pipe_surface_reference(&ps, NULL);
}
@@ -128,7 +128,7 @@ st_bind_surface(GLcontext *ctx, GLenum target,
stObj->pipe = ctx->st->pipe;
/* FIXME create a non-default sampler view from the pipe_surface? */
- pipe_texture_reference(&stImage->pt, ps->texture);
+ pipe_resource_reference(&stImage->pt, ps->texture);
_mesa_dirty_texobj(ctx, texObj, GL_TRUE);
}
@@ -143,7 +143,7 @@ st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target,
struct pipe_surface *ps;
unsigned usage;
- usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
+ usage = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_BLIT_DESTINATION | PIPE_BIND_BLIT_SOURCE;
ps = st_manager_get_egl_image_surface(st, (void *) image_handle, usage);
if (ps) {
st_bind_surface(ctx, target, texObj, texImage, ps);
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 542ab38a50..d50970f7e4 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -96,13 +96,12 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
return strb->data != NULL;
}
else {
- struct pipe_texture template;
- unsigned surface_usage;
+ struct pipe_resource template;
/* Free the old surface and texture
*/
pipe_surface_reference( &strb->surface, NULL );
- pipe_texture_reference( &strb->texture, NULL );
+ pipe_resource_reference( &strb->texture, NULL );
pipe_sampler_view_reference(&strb->sampler_view, NULL);
/* Setup new texture template.
@@ -116,23 +115,14 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
template.last_level = 0;
template.nr_samples = rb->NumSamples;
if (util_format_is_depth_or_stencil(format)) {
- template.tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ template.bind = PIPE_BIND_DEPTH_STENCIL;
}
else {
- template.tex_usage = (PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_RENDER_TARGET);
+ template.bind = (PIPE_BIND_DISPLAY_TARGET |
+ PIPE_BIND_RENDER_TARGET);
}
- /* Probably need dedicated flags for surface usage too:
- */
- surface_usage = (PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
-#if 0
- PIPE_BUFFER_USAGE_CPU_READ |
- PIPE_BUFFER_USAGE_CPU_WRITE);
-#endif
-
- strb->texture = screen->texture_create(screen, &template);
+ strb->texture = screen->resource_create(screen, &template);
if (!strb->texture)
return FALSE;
@@ -140,7 +130,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
strb->surface = screen->get_tex_surface(screen,
strb->texture,
0, 0, 0,
- surface_usage);
+ template.bind);
if (strb->surface) {
assert(strb->surface->texture);
assert(strb->surface->format);
@@ -162,7 +152,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
struct st_renderbuffer *strb = st_renderbuffer(rb);
ASSERT(strb);
pipe_surface_reference(&strb->surface, NULL);
- pipe_texture_reference(&strb->texture, NULL);
+ pipe_resource_reference(&strb->texture, NULL);
pipe_sampler_view_reference(&strb->sampler_view, NULL);
free(strb->data);
free(strb);
@@ -323,7 +313,7 @@ st_render_texture(GLcontext *ctx,
struct pipe_screen *screen = ctx->st->pipe->screen;
struct st_renderbuffer *strb;
struct gl_renderbuffer *rb;
- struct pipe_texture *pt = st_get_texobj_texture(att->Texture);
+ struct pipe_resource *pt = st_get_texobj_texture(att->Texture);
struct st_texture_object *stObj;
const struct gl_texture_image *texImage;
GLint pt_level;
@@ -366,7 +356,7 @@ st_render_texture(GLcontext *ctx,
/*printf("***** pipe texture %d x %d\n", pt->width0, pt->height0);*/
- pipe_texture_reference( &strb->texture, pt );
+ pipe_resource_reference( &strb->texture, pt );
pipe_surface_reference(&strb->surface, NULL);
@@ -380,8 +370,7 @@ st_render_texture(GLcontext *ctx,
strb->rtt_face,
strb->rtt_level,
strb->rtt_slice,
- PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
strb->format = pt->format;
@@ -479,20 +468,20 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
if (!st_validate_attachment(screen,
&fb->Attachment[BUFFER_DEPTH],
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) {
+ PIPE_BIND_DEPTH_STENCIL)) {
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
return;
}
if (!st_validate_attachment(screen,
&fb->Attachment[BUFFER_STENCIL],
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL)) {
+ PIPE_BIND_DEPTH_STENCIL)) {
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
return;
}
for (i = 0; i < ctx->Const.MaxColorAttachments; i++) {
if (!st_validate_attachment(screen,
&fb->Attachment[BUFFER_COLOR0 + i],
- PIPE_TEXTURE_USAGE_RENDER_TARGET)) {
+ PIPE_BIND_RENDER_TARGET)) {
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
return;
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h
index 7a45a608fe..5f11a7cd8a 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -37,7 +37,7 @@
struct st_renderbuffer
{
struct gl_renderbuffer Base;
- struct pipe_texture *texture;
+ struct pipe_resource *texture;
struct pipe_surface *surface; /* temporary view into texture */
struct pipe_sampler_view *sampler_view;
enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */
@@ -54,7 +54,7 @@ struct st_renderbuffer
int rtt_level, rtt_face, rtt_slice;
/** Render to texture state */
- struct pipe_texture *texture_save;
+ struct pipe_resource *texture_save;
struct pipe_surface *surface_save;
struct pipe_sampler_view *sampler_view_save;
};
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 10795ee9e4..3c06221c87 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -82,7 +82,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
width, height);
/* map the stencil buffer */
- stmap = pipe->transfer_map(pipe, pt);
+ stmap = pipe_transfer_map(pipe, pt);
/* width should never be > MAX_WIDTH since we did clipping earlier */
ASSERT(width <= MAX_WIDTH);
@@ -102,7 +102,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
/* get stencil (and Z) values */
- switch (pt->texture->format) {
+ switch (pt->resource->format) {
case PIPE_FORMAT_S8_USCALED:
{
const ubyte *src = stmap + srcY * pt->stride;
@@ -162,8 +162,8 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
/* unmap the stencil buffer */
- pipe->transfer_unmap(pipe, pt);
- pipe->tex_transfer_destroy(pipe, pt);
+ pipe_transfer_unmap(pipe, pt);
+ pipe->transfer_destroy(pipe, pt);
}
@@ -253,9 +253,9 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
return GL_FALSE;
}
- map = pipe->transfer_map(pipe, trans);
+ map = pipe_transfer_map(pipe, trans);
if (!map) {
- pipe->tex_transfer_destroy(pipe, trans);
+ pipe->transfer_destroy(pipe, trans);
return GL_FALSE;
}
@@ -317,8 +317,8 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
; /* nothing */
}
- pipe->transfer_unmap(pipe, trans);
- pipe->tex_transfer_destroy(pipe, trans);
+ pipe_transfer_unmap(pipe, trans);
+ pipe->transfer_destroy(pipe, trans);
}
return GL_TRUE;
@@ -437,8 +437,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width,
format, type);
- if (trans->texture->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
- trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) {
+ if (trans->resource->format == PIPE_FORMAT_Z24_UNORM_S8_USCALED ||
+ trans->resource->format == PIPE_FORMAT_Z24X8_UNORM) {
if (format == GL_DEPTH_COMPONENT) {
for (i = 0; i < height; i++) {
GLuint ztemp[MAX_WIDTH];
@@ -469,8 +469,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
}
- else if (trans->texture->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
- trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) {
+ else if (trans->resource->format == PIPE_FORMAT_S8_USCALED_Z24_UNORM ||
+ trans->resource->format == PIPE_FORMAT_X8Z24_UNORM) {
if (format == GL_DEPTH_COMPONENT) {
for (i = 0; i < height; i++) {
GLuint ztemp[MAX_WIDTH];
@@ -496,7 +496,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
}
- else if (trans->texture->format == PIPE_FORMAT_Z16_UNORM) {
+ else if (trans->resource->format == PIPE_FORMAT_Z16_UNORM) {
for (i = 0; i < height; i++) {
GLushort ztemp[MAX_WIDTH];
GLfloat zfloat[MAX_WIDTH];
@@ -511,7 +511,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
dst += dstStride;
}
}
- else if (trans->texture->format == PIPE_FORMAT_Z32_UNORM) {
+ else if (trans->resource->format == PIPE_FORMAT_Z32_UNORM) {
for (i = 0; i < height; i++) {
GLuint ztemp[MAX_WIDTH];
GLfloat zfloat[MAX_WIDTH];
@@ -542,7 +542,7 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
}
}
- pipe->tex_transfer_destroy(pipe, trans);
+ pipe->transfer_destroy(pipe, trans);
_mesa_unmap_pbo_dest(ctx, &clippedPacking);
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 390ada5489..ce112f6795 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -123,7 +123,7 @@ st_DeleteTextureObject(GLcontext *ctx,
{
struct st_texture_object *stObj = st_texture_object(texObj);
if (stObj->pt)
- pipe_texture_reference(&stObj->pt, NULL);
+ pipe_resource_reference(&stObj->pt, NULL);
if (stObj->sampler_view) {
if (stObj->sampler_view->context != ctx->st->pipe) {
/* Take "ownership" of this texture sampler view by setting
@@ -148,7 +148,7 @@ st_FreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage)
DBG("%s\n", __FUNCTION__);
if (stImage->pt) {
- pipe_texture_reference(&stImage->pt, NULL);
+ pipe_resource_reference(&stImage->pt, NULL);
}
if (texImage->Data) {
@@ -214,17 +214,17 @@ do_memcpy(void *dest, const void *src, size_t n)
static GLuint
default_usage(enum pipe_format fmt)
{
- GLuint usage = PIPE_TEXTURE_USAGE_SAMPLER;
+ GLuint usage = PIPE_BIND_SAMPLER_VIEW;
if (util_format_is_depth_or_stencil(fmt))
- usage |= PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ usage |= PIPE_BIND_DEPTH_STENCIL;
else
- usage |= PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ usage |= PIPE_BIND_RENDER_TARGET;
return usage;
}
/**
- * Allocate a pipe_texture object for the given st_texture_object using
+ * Allocate a pipe_resource object for the given st_texture_object using
* the given st_texture_image to guess the mipmap size/levels.
*
* [comments...]
@@ -387,8 +387,8 @@ compress_with_blit(GLcontext * ctx,
struct pipe_context *pipe = ctx->st->pipe;
struct pipe_screen *screen = pipe->screen;
gl_format mesa_format;
- struct pipe_texture templ;
- struct pipe_texture *src_tex;
+ struct pipe_resource templ;
+ struct pipe_resource *src_tex;
struct pipe_sampler_view view_templ;
struct pipe_sampler_view *src_view;
struct pipe_surface *dst_surface;
@@ -403,7 +403,7 @@ compress_with_blit(GLcontext * ctx,
/* get destination surface (in the compressed texture) */
dst_surface = screen->get_tex_surface(screen, stImage->pt,
stImage->face, stImage->level, 0,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION);
if (!dst_surface) {
/* can't render into this format (or other problem) */
return GL_FALSE;
@@ -425,8 +425,9 @@ compress_with_blit(GLcontext * ctx,
templ.height0 = height;
templ.depth0 = 1;
templ.last_level = 0;
- templ.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER;
- src_tex = screen->texture_create(screen, &templ);
+ templ._usage = PIPE_USAGE_DEFAULT;
+ templ.bind = PIPE_BIND_SAMPLER_VIEW;
+ src_tex = screen->resource_create(screen, &templ);
if (!src_tex)
return GL_FALSE;
@@ -437,7 +438,7 @@ compress_with_blit(GLcontext * ctx,
0, 0, 0, /* face, level are zero */
PIPE_TRANSFER_WRITE,
0, 0, width, height); /* x, y, w, h */
- map = pipe->transfer_map(pipe, tex_xfer);
+ map = pipe_transfer_map(pipe, tex_xfer);
_mesa_texstore(ctx, 2, GL_RGBA, mesa_format,
map, /* dest ptr */
@@ -449,8 +450,8 @@ compress_with_blit(GLcontext * ctx,
pixels, /* source data */
unpack); /* source data packing */
- pipe->transfer_unmap(pipe, tex_xfer);
- pipe->tex_transfer_destroy(pipe, tex_xfer);
+ pipe_transfer_unmap(pipe, tex_xfer);
+ pipe->transfer_destroy(pipe, tex_xfer);
/* Create temporary sampler view */
u_sampler_view_default_template(&view_templ,
@@ -472,7 +473,7 @@ compress_with_blit(GLcontext * ctx,
PIPE_TEX_MIPFILTER_NEAREST);
pipe_surface_reference(&dst_surface, NULL);
- pipe_texture_reference(&src_tex, NULL);
+ pipe_resource_reference(&src_tex, NULL);
pipe_sampler_view_reference(&src_view, NULL);
return GL_TRUE;
@@ -560,7 +561,7 @@ st_TexImage(GLcontext * ctx,
* Release any old malloced memory.
*/
if (stImage->pt) {
- pipe_texture_reference(&stImage->pt, NULL);
+ pipe_resource_reference(&stImage->pt, NULL);
assert(!texImage->Data);
}
else if (texImage->Data) {
@@ -577,7 +578,7 @@ st_TexImage(GLcontext * ctx,
!st_texture_match_image(stObj->pt, &stImage->base,
stImage->face, stImage->level)) {
DBG("release it\n");
- pipe_texture_reference(&stObj->pt, NULL);
+ pipe_resource_reference(&stObj->pt, NULL);
assert(!stObj->pt);
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
stObj->teximage_realloc = FALSE;
@@ -610,7 +611,7 @@ st_TexImage(GLcontext * ctx,
st_texture_match_image(stObj->pt, &stImage->base,
stImage->face, stImage->level)) {
- pipe_texture_reference(&stImage->pt, stObj->pt);
+ pipe_resource_reference(&stImage->pt, stObj->pt);
assert(stImage->pt);
}
@@ -644,7 +645,7 @@ st_TexImage(GLcontext * ctx,
screen->is_format_supported(screen,
stImage->pt->format,
stImage->pt->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
if (!pixels)
goto done;
@@ -842,11 +843,14 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
const GLuint width = texImage->Width;
const GLuint height = texImage->Height;
struct pipe_surface *dst_surface;
- struct pipe_texture *dst_texture;
+ struct pipe_resource *dst_texture;
struct pipe_transfer *tex_xfer;
+ unsigned bind = (PIPE_BIND_BLIT_DESTINATION |
+ PIPE_BIND_RENDER_TARGET | /* util_blit may choose to render */
+ PIPE_BIND_TRANSFER_READ);
/* create temp / dest surface */
- if (!util_create_rgba_surface(screen, width, height,
+ if (!util_create_rgba_surface(screen, width, height, bind,
&dst_texture, &dst_surface)) {
_mesa_problem(ctx, "util_create_rgba_surface() failed "
"in decompress_with_blit()");
@@ -855,7 +859,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
/* blit/render/decompress */
util_blit_pixels_tex(ctx->st->blit,
- src_view, /* pipe_texture (src) */
+ src_view, /* pipe_resource (src) */
0, 0, /* src x0, y0 */
width, height, /* src x1, y1 */
dst_surface, /* pipe_surface (dst) */
@@ -876,7 +880,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
if (st_equal_formats(stImage->pt->format, format, type)) {
/* memcpy */
const uint bytesPerRow = width * util_format_get_blocksize(stImage->pt->format);
- ubyte *map = pipe->transfer_map(pipe, tex_xfer);
+ ubyte *map = pipe_transfer_map(pipe, tex_xfer);
GLuint row;
for (row = 0; row < height; row++) {
GLvoid *dest = _mesa_image_address2d(&ctx->Pack, pixels, width,
@@ -884,7 +888,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
memcpy(dest, map, bytesPerRow);
map += tex_xfer->stride;
}
- pipe->transfer_unmap(pipe, tex_xfer);
+ pipe_transfer_unmap(pipe, tex_xfer);
}
else {
/* format translation via floats */
@@ -908,7 +912,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
_mesa_unmap_pbo_dest(ctx, &ctx->Pack);
- pipe->tex_transfer_destroy(pipe, tex_xfer);
+ pipe->transfer_destroy(pipe, tex_xfer);
/* destroy the temp / dest surface */
util_destroy_rgba_surface(dst_texture, dst_surface);
@@ -1069,7 +1073,7 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
screen->is_format_supported(screen,
stImage->pt->format,
stImage->pt->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
if (compress_with_blit(ctx, target, level,
xoffset, yoffset, zoffset,
width, height, depth,
@@ -1392,7 +1396,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
}
st_texture_image_unmap(ctx->st, stImage);
- pipe->tex_transfer_destroy(pipe, src_trans);
+ pipe->transfer_destroy(pipe, src_trans);
}
@@ -1577,7 +1581,7 @@ st_copy_texsubimage(GLcontext *ctx,
dest_surface = screen->get_tex_surface(screen, stImage->pt,
stImage->face, stImage->level,
destZ,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION);
/* for surface_copy(), y=0=top, always */
pipe->surface_copy(pipe,
@@ -1596,11 +1600,11 @@ st_copy_texsubimage(GLcontext *ctx,
texBaseFormat != GL_DEPTH_STENCIL &&
screen->is_format_supported(screen, src_format,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER,
+ PIPE_BIND_SAMPLER_VIEW,
0) &&
screen->is_format_supported(screen, dest_format,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ PIPE_BIND_RENDER_TARGET,
0)) {
/* draw textured quad to do the copy */
GLint srcY0, srcY1;
@@ -1608,7 +1612,7 @@ st_copy_texsubimage(GLcontext *ctx,
dest_surface = screen->get_tex_surface(screen, stImage->pt,
stImage->face, stImage->level,
destZ,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION);
if (do_flip) {
srcY1 = strb->Base.Height - srcY - height;
@@ -1748,7 +1752,7 @@ copy_image_data_to_texture(struct st_context *st,
stImage->pt, /* src texture */
stImage->face);
- pipe_texture_reference(&stImage->pt, NULL);
+ pipe_resource_reference(&stImage->pt, NULL);
}
else if (stImage->base.Data) {
/* More straightforward upload.
@@ -1770,7 +1774,7 @@ copy_image_data_to_texture(struct st_context *st,
stImage->base.Data = NULL;
}
- pipe_texture_reference(&stImage->pt, stObj->pt);
+ pipe_resource_reference(&stImage->pt, stObj->pt);
}
@@ -1816,7 +1820,7 @@ st_finalize_texture(GLcontext *ctx,
if (firstImage->pt &&
firstImage->pt != stObj->pt &&
firstImage->pt->last_level >= stObj->lastLevel) {
- pipe_texture_reference(&stObj->pt, firstImage->pt);
+ pipe_resource_reference(&stObj->pt, firstImage->pt);
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
}
@@ -1836,7 +1840,7 @@ st_finalize_texture(GLcontext *ctx,
stObj->pt->height0 != firstImage->base.Height2 ||
stObj->pt->depth0 != firstImage->base.Depth2)
{
- pipe_texture_reference(&stObj->pt, NULL);
+ pipe_resource_reference(&stObj->pt, NULL);
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
}
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 83580591fc..0a1503fc69 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -240,7 +240,7 @@ static void st_destroy_context_priv( struct st_context *st )
for (i = 0; i < Elements(st->state.constants); i++) {
if (st->state.constants[i]) {
- pipe_buffer_reference(&st->state.constants[i], NULL);
+ pipe_resource_reference(&st->state.constants[i], NULL);
}
}
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 786beaec08..f28d5aa3ed 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -95,7 +95,7 @@ struct st_context
struct pipe_sampler_state samplers[PIPE_MAX_SAMPLERS];
struct pipe_sampler_state *sampler_list[PIPE_MAX_SAMPLERS];
struct pipe_clip_state clip;
- struct pipe_buffer *constants[2];
+ struct pipe_resource *constants[2];
struct pipe_framebuffer_state framebuffer;
struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS];
struct pipe_scissor_state scissor;
@@ -143,7 +143,7 @@ struct st_context
GLuint user_prog_sn; /**< user fragment program serial no. */
struct st_fragment_program *combined_prog;
GLuint combined_prog_sn;
- struct pipe_texture *pixelmap_texture;
+ struct pipe_resource *pixelmap_texture;
struct pipe_sampler_view *pixelmap_sampler_view;
boolean pixelmap_enabled; /**< use the pixelmap texture? */
} pixel_xfer;
@@ -155,7 +155,7 @@ struct st_context
enum pipe_format tex_format;
void *vs;
float vertices[4][3][4]; /**< vertex pos + color + texcoord */
- struct pipe_buffer *vbuf;
+ struct pipe_resource *vbuf;
unsigned vbuf_slot; /* next free slot in vbuf */
struct bitmap_cache *cache;
} bitmap;
@@ -174,7 +174,7 @@ struct st_context
void *vs;
void *fs;
float vertices[4][2][4]; /**< vertex pos + color */
- struct pipe_buffer *vbuf;
+ struct pipe_resource *vbuf;
unsigned vbuf_slot;
} clear;
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index e0bb1a0af5..0ebc462ced 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -360,12 +360,13 @@ setup_interleaved_attribs(GLcontext *ctx,
offset0 = low;
if (userSpace) {
vbuffer->buffer =
- pipe_user_buffer_create(pipe->screen, (void *) low, high - low);
+ pipe_user_buffer_create(pipe->screen, (void *) low, high - low,
+ PIPE_BIND_VERTEX_BUFFER);
vbuffer->buffer_offset = 0;
}
else {
vbuffer->buffer = NULL;
- pipe_buffer_reference(&vbuffer->buffer, stobj->buffer);
+ pipe_resource_reference(&vbuffer->buffer, stobj->buffer);
vbuffer->buffer_offset = pointer_to_offset(low);
}
vbuffer->stride = stride; /* in bytes */
@@ -422,7 +423,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
/*printf("stobj %u = %p\n", attr, (void*) stobj);*/
vbuffer[attr].buffer = NULL;
- pipe_buffer_reference(&vbuffer[attr].buffer, stobj->buffer);
+ pipe_resource_reference(&vbuffer[attr].buffer, stobj->buffer);
vbuffer[attr].buffer_offset = pointer_to_offset(arrays[mesaAttr]->Ptr);
velements[attr].src_offset = 0;
}
@@ -443,14 +444,19 @@ setup_non_interleaved_attribs(GLcontext *ctx,
bytes = arrays[mesaAttr]->Size
* _mesa_sizeof_type(arrays[mesaAttr]->Type);
}
- vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen,
- (void *) arrays[mesaAttr]->Ptr, bytes);
+ vbuffer[attr].buffer =
+ pipe_user_buffer_create(pipe->screen,
+ (void *) arrays[mesaAttr]->Ptr, bytes,
+ PIPE_BIND_VERTEX_BUFFER);
}
else {
/* no array, use ctx->Current.Attrib[] value */
bytes = sizeof(ctx->Current.Attrib[0]);
- vbuffer[attr].buffer = pipe_user_buffer_create(pipe->screen,
- (void *) ctx->Current.Attrib[mesaAttr], bytes);
+ vbuffer[attr].buffer =
+ pipe_user_buffer_create(pipe->screen,
+ (void *) ctx->Current.Attrib[mesaAttr],
+ bytes,
+ PIPE_BIND_VERTEX_BUFFER);
stride = 0;
}
@@ -618,7 +624,7 @@ st_draw_vbo(GLcontext *ctx,
if (ib) {
/* indexed primitive */
struct gl_buffer_object *bufobj = ib->obj;
- struct pipe_buffer *indexBuf = NULL;
+ struct pipe_resource *indexBuf = NULL;
unsigned indexSize, indexOffset, i;
unsigned prim;
@@ -641,13 +647,14 @@ st_draw_vbo(GLcontext *ctx,
if (bufobj && bufobj->Name) {
/* elements/indexes are in a real VBO */
struct st_buffer_object *stobj = st_buffer_object(bufobj);
- pipe_buffer_reference(&indexBuf, stobj->buffer);
+ pipe_resource_reference(&indexBuf, stobj->buffer);
indexOffset = pointer_to_offset(ib->ptr) / indexSize;
}
else {
/* element/indicies are in user space memory */
indexBuf = pipe_user_buffer_create(pipe->screen, (void *) ib->ptr,
- ib->count * indexSize);
+ ib->count * indexSize,
+ PIPE_BIND_INDEX_BUFFER);
indexOffset = 0;
}
@@ -683,7 +690,7 @@ st_draw_vbo(GLcontext *ctx,
}
}
- pipe_buffer_reference(&indexBuf, NULL);
+ pipe_resource_reference(&indexBuf, NULL);
}
else {
/* non-indexed */
@@ -706,7 +713,7 @@ st_draw_vbo(GLcontext *ctx,
/* unreference buffers (frees wrapped user-space buffer objects) */
for (attr = 0; attr < num_vbuffers; attr++) {
- pipe_buffer_reference(&vbuffer[attr].buffer, NULL);
+ pipe_resource_reference(&vbuffer[attr].buffer, NULL);
assert(!vbuffer[attr].buffer);
}
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index 26a5b3fcd6..b717bd4e3f 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -104,9 +104,12 @@ st_feedback_draw_vbo(GLcontext *ctx,
struct draw_context *draw = st->draw;
const struct st_vertex_program *vp;
const struct pipe_shader_state *vs;
- struct pipe_buffer *index_buffer_handle = 0;
+ struct pipe_resource *index_buffer_handle = 0;
struct pipe_vertex_buffer vbuffers[PIPE_MAX_SHADER_INPUTS];
struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
+ struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS];
+ struct pipe_transfer *ib_transfer;
+ struct pipe_transfer *cb_transfer;
GLuint attr, i;
ubyte *mapped_constants;
@@ -155,7 +158,7 @@ st_feedback_draw_vbo(GLcontext *ctx,
assert(stobj->buffer);
vbuffers[attr].buffer = NULL;
- pipe_buffer_reference(&vbuffers[attr].buffer, stobj->buffer);
+ pipe_resource_reference(&vbuffers[attr].buffer, stobj->buffer);
vbuffers[attr].buffer_offset = pointer_to_offset(arrays[0]->Ptr);
velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr;
}
@@ -168,7 +171,8 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* wrap user data */
vbuffers[attr].buffer
= pipe_user_buffer_create(pipe->screen, (void *) arrays[mesaAttr]->Ptr,
- bytes);
+ bytes,
+ PIPE_BIND_VERTEX_BUFFER);
vbuffers[attr].buffer_offset = 0;
velements[attr].src_offset = 0;
}
@@ -191,8 +195,9 @@ st_feedback_draw_vbo(GLcontext *ctx,
#endif
/* map the attrib buffer */
- map = pipe_buffer_map(pipe->screen, vbuffers[attr].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, vbuffers[attr].buffer,
+ PIPE_TRANSFER_READ,
+ &vb_transfer[attr]);
draw_set_mapped_vertex_buffer(draw, attr, map);
}
@@ -221,13 +226,14 @@ st_feedback_draw_vbo(GLcontext *ctx,
index_buffer_handle = stobj->buffer;
- map = pipe_buffer_map(pipe->screen, index_buffer_handle,
- PIPE_BUFFER_USAGE_CPU_READ);
+ map = pipe_buffer_map(pipe, index_buffer_handle,
+ PIPE_TRANSFER_READ, &ib_transfer);
draw_set_mapped_element_buffer(draw, indexSize, map);
}
else {
draw_set_mapped_element_buffer(draw, indexSize, (void *) ib->ptr);
+ ib_transfer = NULL;
}
}
else {
@@ -237,12 +243,13 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* map constant buffers */
- mapped_constants = pipe_buffer_map(pipe->screen,
+ mapped_constants = pipe_buffer_map(pipe,
st->state.constants[PIPE_SHADER_VERTEX],
- PIPE_BUFFER_USAGE_CPU_READ);
+ PIPE_TRANSFER_READ,
+ &cb_transfer);
draw_set_mapped_constant_buffer(st->draw, PIPE_SHADER_VERTEX, 0,
mapped_constants,
- st->state.constants[PIPE_SHADER_VERTEX]->size);
+ st->state.constants[PIPE_SHADER_VERTEX]->width0);
/* draw here */
@@ -252,20 +259,22 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* unmap constant buffers */
- pipe_buffer_unmap(pipe->screen, st->state.constants[PIPE_SHADER_VERTEX]);
+ pipe_buffer_unmap(pipe, st->state.constants[PIPE_SHADER_VERTEX],
+ cb_transfer);
/*
* unmap vertex/index buffers
*/
for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
if (draw->pt.vertex_buffer[i].buffer) {
- pipe_buffer_unmap(pipe->screen, draw->pt.vertex_buffer[i].buffer);
- pipe_buffer_reference(&draw->pt.vertex_buffer[i].buffer, NULL);
+ pipe_buffer_unmap(pipe, draw->pt.vertex_buffer[i].buffer,
+ vb_transfer[i]);
+ pipe_resource_reference(&draw->pt.vertex_buffer[i].buffer, NULL);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
}
if (index_buffer_handle) {
- pipe_buffer_unmap(pipe->screen, index_buffer_handle);
+ pipe_buffer_unmap(pipe, index_buffer_handle, ib_transfer);
draw_set_mapped_element_buffer(draw, 0, NULL);
}
}
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index affb054866..1e4b7b8840 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -287,39 +287,39 @@ void st_init_extensions(struct st_context *st)
*/
if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
+ PIPE_BIND_DEPTH_STENCIL, 0) &&
screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
}
else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) &&
+ PIPE_BIND_DEPTH_STENCIL, 0) &&
screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE;
}
/* sRGB support */
if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
+ PIPE_BIND_SAMPLER_VIEW, 0) ||
screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
}
/* s3tc support */
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0) &&
+ PIPE_BIND_SAMPLER_VIEW, 0) &&
(ctx->Mesa_DXTn ||
screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))) {
+ PIPE_BIND_RENDER_TARGET, 0))) {
ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
ctx->Extensions.S3_s3tc = GL_TRUE;
}
@@ -327,10 +327,10 @@ void st_init_extensions(struct st_context *st)
/* ycbcr support */
if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
+ PIPE_BIND_SAMPLER_VIEW, 0) ||
screen->is_format_supported(screen, PIPE_FORMAT_YUYV,
PIPE_TEXTURE_2D,
- PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
}
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index ecc08762bb..731ec64c13 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -374,7 +374,7 @@ default_deep_rgba_format(struct pipe_screen *screen,
if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) {
return PIPE_FORMAT_R16G16B16A16_SNORM;
}
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ if (tex_usage & PIPE_BIND_RENDER_TARGET)
return default_rgba_format(screen, target, tex_usage, geom_flags);
else
return PIPE_FORMAT_NONE;
@@ -410,8 +410,8 @@ default_depth_format(struct pipe_screen *screen,
* Given an OpenGL internalFormat value for a texture or surface, return
* the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match.
* \param target one of PIPE_TEXTURE_x
- * \param tex_usage either PIPE_TEXTURE_USAGE_RENDER_TARGET
- * or PIPE_TEXTURE_USAGE_SAMPLER
+ * \param tex_usage either PIPE_BIND_RENDER_TARGET
+ * or PIPE_BIND_SAMPLER_VIEW
*/
enum pipe_format
st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
@@ -432,7 +432,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
case GL_COMPRESSED_RGB:
return default_rgb_format( screen, target, tex_usage, geom_flags );
case GL_RGBA16:
- if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ if (tex_usage & PIPE_BIND_RENDER_TARGET)
return default_deep_rgba_format( screen, target, tex_usage, geom_flags );
else
return default_rgba_format( screen, target, tex_usage, geom_flags );
@@ -645,9 +645,9 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
{
uint usage;
if (is_depth_or_stencil_format(internalFormat))
- usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL;
+ usage = PIPE_BIND_DEPTH_STENCIL;
else
- usage = PIPE_TEXTURE_USAGE_RENDER_TARGET;
+ usage = PIPE_BIND_RENDER_TARGET;
return st_choose_format(screen, internalFormat, PIPE_TEXTURE_2D, usage);
}
@@ -665,7 +665,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
(void) type;
pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
- PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER);
+ PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW);
if (pFormat == PIPE_FORMAT_NONE)
return MESA_FORMAT_NONE;
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index d3c43bbc68..819b4487ac 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -196,7 +196,7 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb,
/* replace the renderbuffer's surface/texture pointers */
pipe_surface_reference( &strb->surface, surf );
- pipe_texture_reference( &strb->texture, surf->texture );
+ pipe_resource_reference( &strb->texture, surf->texture );
pipe_sampler_view_reference(&strb->sampler_view, NULL);
if (ctx) {
@@ -243,7 +243,7 @@ st_get_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex, struct p
}
int
-st_get_framebuffer_texture(struct st_framebuffer *stfb, uint surfIndex, struct pipe_texture **texture)
+st_get_framebuffer_texture(struct st_framebuffer *stfb, uint surfIndex, struct pipe_resource **texture)
{
struct st_renderbuffer *strb;
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 030b0a0f06..f0fe31967c 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -91,7 +91,7 @@ st_render_mipmap(struct st_context *st,
/* check if we can render in the texture's format */
if (!screen->is_format_supported(screen, psv->format, psv->texture->target,
- PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
+ PIPE_BIND_RENDER_TARGET, 0)) {
return FALSE;
}
@@ -107,7 +107,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj)
{
struct pipe_context *pipe = ctx->st->pipe;
- struct pipe_texture *pt = st_get_texobj_texture(texObj);
+ struct pipe_resource *pt = st_get_texobj_texture(texObj);
const uint baseLevel = texObj->BaseLevel;
const uint lastLevel = pt->last_level;
const uint face = _mesa_tex_target_to_face(target), zslice = 0;
@@ -142,11 +142,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
u_minify(pt->width0, dstLevel),
u_minify(pt->height0, dstLevel));
- srcData = (ubyte *) pipe->transfer_map(pipe, srcTrans);
- dstData = (ubyte *) pipe->transfer_map(pipe, dstTrans);
+ srcData = (ubyte *) pipe_transfer_map(pipe, srcTrans);
+ dstData = (ubyte *) pipe_transfer_map(pipe, dstTrans);
- srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->texture->format);
- dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->texture->format);
+ srcStride = srcTrans->stride / util_format_get_blocksize(srcTrans->resource->format);
+ dstStride = dstTrans->stride / util_format_get_blocksize(dstTrans->resource->format);
_mesa_generate_mipmap_level(target, datatype, comps,
0 /*border*/,
@@ -161,11 +161,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
dstData,
dstStride); /* stride in texels */
- pipe->transfer_unmap(pipe, srcTrans);
- pipe->transfer_unmap(pipe, dstTrans);
+ pipe_transfer_unmap(pipe, srcTrans);
+ pipe_transfer_unmap(pipe, dstTrans);
- pipe->tex_transfer_destroy(pipe, srcTrans);
- pipe->tex_transfer_destroy(pipe, dstTrans);
+ pipe->transfer_destroy(pipe, srcTrans);
+ pipe->transfer_destroy(pipe, dstTrans);
}
}
@@ -213,7 +213,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
{
struct st_context *st = ctx->st;
struct st_texture_object *stObj = st_texture_object(texObj);
- struct pipe_texture *pt = st_get_texobj_texture(texObj);
+ struct pipe_resource *pt = st_get_texobj_texture(texObj);
const uint baseLevel = texObj->BaseLevel;
uint lastLevel;
uint dstLevel;
@@ -231,7 +231,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
/* The current gallium texture doesn't have space for all the
* mipmap levels we need to generate. So allocate a new texture.
*/
- struct pipe_texture *oldTex = stObj->pt;
+ struct pipe_resource *oldTex = stObj->pt;
GLboolean needFlush;
/* create new texture with space for more levels */
@@ -242,7 +242,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
oldTex->width0,
oldTex->height0,
oldTex->depth0,
- oldTex->tex_usage);
+ oldTex->bind);
/* The texture isn't in a "complete" state yet so set the expected
* lastLevel here, since it won't get done in st_finalize_texture().
@@ -255,7 +255,7 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
st_finalize_texture(ctx, st->pipe, texObj, &needFlush);
/* release the old tex (will likely be freed too) */
- pipe_texture_reference(&oldTex, NULL);
+ pipe_resource_reference(&oldTex, NULL);
pipe_sampler_view_reference(&stObj->sampler_view, NULL);
pt = stObj->pt;
@@ -299,6 +299,6 @@ st_generate_mipmap(GLcontext *ctx, GLenum target,
dstImage->TexFormat = srcImage->TexFormat;
stImage = (struct st_texture_image *) dstImage;
- pipe_texture_reference(&stImage->pt, pt);
+ pipe_resource_reference(&stImage->pt, pt);
}
}
diff --git a/src/mesa/state_tracker/st_inlines.h b/src/mesa/state_tracker/st_inlines.h
index 7fcde7b1a9..32584b25c2 100644
--- a/src/mesa/state_tracker/st_inlines.h
+++ b/src/mesa/state_tracker/st_inlines.h
@@ -37,6 +37,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
+#include "util/u_box.h"
#include "pipe/p_state.h"
#include "st_context.h"
@@ -45,7 +46,7 @@
static INLINE struct pipe_transfer *
st_cond_flush_get_tex_transfer(struct st_context *st,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned int face,
unsigned int level,
unsigned int zslice,
@@ -54,15 +55,26 @@ st_cond_flush_get_tex_transfer(struct st_context *st,
unsigned int w, unsigned int h)
{
struct pipe_context *context = st->pipe;
+ struct pipe_subresource subresource;
+ struct pipe_box box;
+
+ subresource.face = face;
+ subresource.level = level;
+
+ u_box_2d_zslice(x, y, zslice, w, h, &box);
st_teximage_flush_before_map(st, pt, face, level, usage);
- return context->get_tex_transfer(context, pt, face, level, zslice, usage,
- x, y, w, h);
+
+ return context->get_transfer(context,
+ pt,
+ subresource,
+ usage,
+ &box);
}
static INLINE struct pipe_transfer *
st_no_flush_get_tex_transfer(struct st_context *st,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned int face,
unsigned int level,
unsigned int zslice,
@@ -71,93 +83,76 @@ st_no_flush_get_tex_transfer(struct st_context *st,
unsigned int w, unsigned int h)
{
struct pipe_context *context = st->pipe;
-
- return context->get_tex_transfer(context, pt, face, level,
- zslice, usage, x, y, w, h);
-}
-
-static INLINE void *
-st_cond_flush_pipe_buffer_map(struct st_context *st,
- struct pipe_buffer *buf,
- unsigned int map_flags)
-{
- struct pipe_context *pipe = st->pipe;
- unsigned int referenced = pipe->is_buffer_referenced(pipe, buf);
-
- if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
- (map_flags & PIPE_BUFFER_USAGE_CPU_WRITE)))
- st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
-
- return pipe_buffer_map(pipe->screen, buf, map_flags);
-}
-
-static INLINE void *
-st_no_flush_pipe_buffer_map(struct st_context *st,
- struct pipe_buffer *buf,
- unsigned int map_flags)
-{
- return pipe_buffer_map(st->pipe->screen, buf, map_flags);
+ struct pipe_box box;
+ struct pipe_subresource subresource = u_subresource( face, level );
+
+ u_box_2d_zslice( x, y, zslice,
+ w, h,
+ &box );
+
+ return context->get_transfer(context,
+ pt,
+ subresource,
+ usage,
+ &box);
}
static INLINE void
st_cond_flush_pipe_buffer_write(struct st_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
const void * data)
{
struct pipe_context *pipe = st->pipe;
- if (pipe->is_buffer_referenced(pipe, buf))
- st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
-
- pipe_buffer_write(pipe->screen, buf, offset, size, data);
+ pipe_buffer_write(pipe, buf, offset, size, data);
}
static INLINE void
st_no_flush_pipe_buffer_write(struct st_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
const void * data)
{
- pipe_buffer_write(st->pipe->screen, buf, offset, size, data);
+ pipe_buffer_write(st->pipe, buf, offset, size, data);
}
static INLINE void
st_no_flush_pipe_buffer_write_nooverlap(struct st_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
const void * data)
{
- pipe_buffer_write_nooverlap(st->pipe->screen, buf, offset, size, data);
+ pipe_buffer_write_nooverlap(st->pipe, buf, offset, size, data);
}
static INLINE void
st_cond_flush_pipe_buffer_read(struct st_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
void * data)
{
struct pipe_context *pipe = st->pipe;
- if (pipe->is_buffer_referenced(pipe, buf) & PIPE_REFERENCED_FOR_WRITE)
+ if (pipe->is_resource_referenced(pipe, buf, 0, 0) & PIPE_REFERENCED_FOR_WRITE)
st_flush(st, PIPE_FLUSH_RENDER_CACHE, NULL);
- pipe_buffer_read(pipe->screen, buf, offset, size, data);
+ pipe_buffer_read(pipe, buf, offset, size, data);
}
static INLINE void
st_no_flush_pipe_buffer_read(struct st_context *st,
- struct pipe_buffer *buf,
+ struct pipe_resource *buf,
unsigned int offset,
unsigned int size,
void * data)
{
- pipe_buffer_read(st->pipe->screen, buf, offset, size, data);
+ pipe_buffer_read(st->pipe, buf, offset, size, data);
}
#endif
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 4b4c17ca8b..8a6c8256ff 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -150,7 +150,7 @@ static void
st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
{
struct pipe_screen *screen = st->pipe->screen;
- struct pipe_texture *textures[ST_ATTACHMENT_COUNT];
+ struct pipe_resource *textures[ST_ATTACHMENT_COUNT];
uint width, height;
unsigned i;
boolean changed = FALSE;
@@ -175,22 +175,22 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
idx = attachment_to_buffer_index(stfb->statts[i]);
if (idx >= BUFFER_COUNT) {
- pipe_texture_reference(&textures[i], NULL);
+ pipe_resource_reference(&textures[i], NULL);
continue;
}
strb = st_renderbuffer(stfb->Base.Attachment[idx].Renderbuffer);
assert(strb);
if (strb->texture == textures[i]) {
- pipe_texture_reference(&textures[i], NULL);
+ pipe_resource_reference(&textures[i], NULL);
continue;
}
ps = screen->get_tex_surface(screen, textures[i], 0, 0, 0,
- PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_RENDER_TARGET);
if (ps) {
pipe_surface_reference(&strb->surface, ps);
- pipe_texture_reference(&strb->texture, ps->texture);
+ pipe_resource_reference(&strb->texture, ps->texture);
/* ownership transfered */
pipe_surface_reference(&ps, NULL);
@@ -203,7 +203,7 @@ st_framebuffer_validate(struct st_framebuffer *stfb, struct st_context *st)
height = strb->Base.Height;
}
- pipe_texture_reference(&textures[i], NULL);
+ pipe_resource_reference(&textures[i], NULL);
}
if (changed) {
@@ -498,7 +498,7 @@ st_context_flush(struct st_context_iface *stctxi, unsigned flags,
static boolean
st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target,
int level, enum pipe_format internal_format,
- struct pipe_texture *tex, boolean mipmap)
+ struct pipe_resource *tex, boolean mipmap)
{
struct st_context *st = (struct st_context *) stctxi;
GLcontext *ctx = st->ctx;
@@ -557,7 +557,7 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
}
stObj->pipe = st->pipe;
- pipe_texture_reference(&stImage->pt, tex);
+ pipe_resource_reference(&stImage->pt, tex);
_mesa_dirty_texobj(ctx, texObj, GL_TRUE);
_mesa_unlock_texture(ctx, texObj);
@@ -744,7 +744,7 @@ st_manager_get_egl_image_surface(struct st_context *st,
ps = smapi->screen->get_tex_surface(smapi->screen,
stimg.texture, stimg.face, stimg.level, stimg.zslice, usage);
- pipe_texture_reference(&stimg.texture, NULL);
+ pipe_resource_reference(&stimg.texture, NULL);
return ps;
}
diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h
index 4b40d6d044..18f82132b9 100644
--- a/src/mesa/state_tracker/st_public.h
+++ b/src/mesa/state_tracker/st_public.h
@@ -53,7 +53,7 @@ struct st_framebuffer;
struct pipe_context;
struct pipe_fence_handle;
struct pipe_surface;
-struct pipe_texture;
+struct pipe_resource;
PUBLIC
@@ -94,7 +94,7 @@ int st_get_framebuffer_surface(struct st_framebuffer *stfb,
PUBLIC
int st_get_framebuffer_texture(struct st_framebuffer *stfb,
- uint surfIndex, struct pipe_texture **texture);
+ uint surfIndex, struct pipe_resource **texture);
PUBLIC
void *st_framebuffer_private( struct st_framebuffer *stfb );
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 5809927852..a623eed50a 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -69,12 +69,12 @@ target_to_target(GLenum target)
/**
- * Allocate a new pipe_texture object
+ * Allocate a new pipe_resource object
* width0, height0, depth0 are the dimensions of the level 0 image
* (the highest resolution). last_level indicates how many mipmap levels
* to allocate storage for. For non-mipmapped textures, this will be zero.
*/
-struct pipe_texture *
+struct pipe_resource *
st_texture_create(struct st_context *st,
enum pipe_texture_target target,
enum pipe_format format,
@@ -82,9 +82,9 @@ st_texture_create(struct st_context *st,
GLuint width0,
GLuint height0,
GLuint depth0,
- GLuint usage )
+ GLuint bind )
{
- struct pipe_texture pt, *newtex;
+ struct pipe_resource pt, *newtex;
struct pipe_screen *screen = st->pipe->screen;
assert(target <= PIPE_TEXTURE_CUBE);
@@ -95,7 +95,7 @@ st_texture_create(struct st_context *st,
assert(format);
assert(screen->is_format_supported(screen, format, target,
- PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ PIPE_BIND_SAMPLER_VIEW, 0));
memset(&pt, 0, sizeof(pt));
pt.target = target;
@@ -104,9 +104,11 @@ st_texture_create(struct st_context *st,
pt.width0 = width0;
pt.height0 = height0;
pt.depth0 = depth0;
- pt.tex_usage = usage;
+ pt._usage = PIPE_USAGE_DEFAULT;
+ pt.bind = bind;
+ pt.flags = 0;
- newtex = screen->texture_create(screen, &pt);
+ newtex = screen->resource_create(screen, &pt);
assert(!newtex || pipe_is_referenced(&newtex->reference));
@@ -118,7 +120,7 @@ st_texture_create(struct st_context *st,
* Check if a texture image can be pulled into a unified mipmap texture.
*/
GLboolean
-st_texture_match_image(const struct pipe_texture *pt,
+st_texture_match_image(const struct pipe_resource *pt,
const struct gl_texture_image *image,
GLuint face, GLuint level)
{
@@ -152,7 +154,7 @@ st_texture_match_image(const struct pipe_texture *pt,
* These functions present that view to mesa:
*/
const GLuint *
-st_texture_depth_offsets(struct pipe_texture *pt, GLuint level)
+st_texture_depth_offsets(struct pipe_resource *pt, GLuint level)
{
static const GLuint zero = 0;
@@ -168,7 +170,7 @@ st_texture_depth_offsets(struct pipe_texture *pt, GLuint level)
* texture memory buffer, in bytes.
*/
GLuint
-st_texture_image_offset(const struct pipe_texture * pt,
+st_texture_image_offset(const struct pipe_resource * pt,
GLuint face, GLuint level)
{
if (pt->target == PIPE_TEXTURE_CUBE)
@@ -192,7 +194,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
GLuint x, GLuint y, GLuint w, GLuint h)
{
struct pipe_context *pipe = st->pipe;
- struct pipe_texture *pt = stImage->pt;
+ struct pipe_resource *pt = stImage->pt;
DBG("%s \n", __FUNCTION__);
@@ -201,7 +203,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
usage, x, y, w, h);
if (stImage->transfer)
- return pipe->transfer_map(pipe, stImage->transfer);
+ return pipe_transfer_map(pipe, stImage->transfer);
else
return NULL;
}
@@ -215,9 +217,9 @@ st_texture_image_unmap(struct st_context *st,
DBG("%s\n", __FUNCTION__);
- pipe->transfer_unmap(pipe, stImage->transfer);
+ pipe_transfer_unmap(pipe, stImage->transfer);
- pipe->tex_transfer_destroy(pipe, stImage->transfer);
+ pipe->transfer_destroy(pipe, stImage->transfer);
}
@@ -237,18 +239,18 @@ st_surface_data(struct pipe_context *pipe,
const void *src, unsigned src_stride,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- void *map = pipe->transfer_map(pipe, dst);
+ void *map = pipe_transfer_map(pipe, dst);
- assert(dst->texture);
+ assert(dst->resource);
util_copy_rect(map,
- dst->texture->format,
+ dst->resource->format,
dst->stride,
dstx, dsty,
width, height,
src, src_stride,
srcx, srcy);
- pipe->transfer_unmap(pipe, dst);
+ pipe_transfer_unmap(pipe, dst);
}
@@ -256,7 +258,7 @@ st_surface_data(struct pipe_context *pipe,
*/
void
st_texture_image_data(struct st_context *st,
- struct pipe_texture *dst,
+ struct pipe_resource *dst,
GLuint face,
GLuint level,
void *src,
@@ -284,7 +286,7 @@ st_texture_image_data(struct st_context *st,
u_minify(dst->width0, level),
u_minify(dst->height0, level)); /* width, height */
- pipe->tex_transfer_destroy(pipe, dst_transfer);
+ pipe->transfer_destroy(pipe, dst_transfer);
srcUB += src_image_stride;
}
@@ -295,8 +297,8 @@ st_texture_image_data(struct st_context *st,
*/
void
st_texture_image_copy(struct pipe_context *pipe,
- struct pipe_texture *dst, GLuint dstLevel,
- struct pipe_texture *src,
+ struct pipe_resource *dst, GLuint dstLevel,
+ struct pipe_resource *src,
GLuint face)
{
struct pipe_screen *screen = pipe->screen;
@@ -337,10 +339,10 @@ st_texture_image_copy(struct pipe_context *pipe,
#endif
dst_surface = screen->get_tex_surface(screen, dst, face, dstLevel, i,
- PIPE_BUFFER_USAGE_GPU_WRITE);
+ PIPE_BIND_BLIT_DESTINATION);
src_surface = screen->get_tex_surface(screen, src, face, srcLevel, i,
- PIPE_BUFFER_USAGE_GPU_READ);
+ PIPE_BIND_BLIT_SOURCE);
pipe->surface_copy(pipe,
dst_surface,
@@ -416,7 +418,7 @@ st_bind_texture_surface(struct pipe_surface *ps, int target, int level,
texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
GL_RGBA, GL_UNSIGNED_BYTE);
_mesa_set_fetch_functions(texImage, 2);
- pipe_texture_reference(&stImage->pt, ps->texture);
+ pipe_resource_reference(&stImage->pt, ps->texture);
_mesa_dirty_texobj(ctx, texObj, GL_TRUE);
_mesa_unlock_texture(ctx, texObj);
@@ -466,7 +468,7 @@ st_unbind_texture_surface(struct pipe_surface *ps, int target, int level)
/* Make sure the pipe surface is still bound. The texture object is still
* considered surface based even if this is the last bound surface. */
if (stImage->pt == ps->texture) {
- pipe_texture_reference(&stImage->pt, NULL);
+ pipe_resource_reference(&stImage->pt, NULL);
_mesa_clear_texture_image(ctx, texImage);
_mesa_dirty_texobj(ctx, texObj, GL_TRUE);
@@ -517,20 +519,21 @@ st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex,
st_flush(ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL);
/* save the renderbuffer's surface/texture info */
- pipe_texture_reference(&strb->texture_save, strb->texture);
+ pipe_resource_reference(&strb->texture_save, strb->texture);
pipe_surface_reference(&strb->surface_save, strb->surface);
pipe_sampler_view_reference(&strb->sampler_view_save, strb->sampler_view);
/* plug in new surface/texture info */
- pipe_texture_reference(&strb->texture, stImage->pt);
+ pipe_resource_reference(&strb->texture, stImage->pt);
/* XXX: Shouldn't we release reference to old surface here?
*/
strb->surface = screen->get_tex_surface(screen, strb->texture,
face, level, slice,
- (PIPE_BUFFER_USAGE_GPU_READ |
- PIPE_BUFFER_USAGE_GPU_WRITE));
+ (PIPE_BIND_RENDER_TARGET |
+ PIPE_BIND_BLIT_SOURCE |
+ PIPE_BIND_BLIT_DESTINATION));
pipe_sampler_view_reference(&strb->sampler_view, NULL);
@@ -562,11 +565,11 @@ st_release_teximage(struct st_framebuffer *stfb, uint surfIndex,
/* free tex surface, restore original */
pipe_surface_reference(&strb->surface, strb->surface_save);
- pipe_texture_reference(&strb->texture, strb->texture_save);
+ pipe_resource_reference(&strb->texture, strb->texture_save);
pipe_sampler_view_reference(&strb->sampler_view, strb->sampler_view_save);
pipe_surface_reference(&strb->surface_save, NULL);
- pipe_texture_reference(&strb->texture_save, NULL);
+ pipe_resource_reference(&strb->texture_save, NULL);
pipe_sampler_view_reference(&strb->sampler_view, NULL);
st->dirty.st |= ST_NEW_FRAMEBUFFER;
@@ -576,14 +579,14 @@ st_release_teximage(struct st_framebuffer *stfb, uint surfIndex,
void
st_teximage_flush_before_map(struct st_context *st,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned int face,
unsigned int level,
enum pipe_transfer_usage usage)
{
struct pipe_context *pipe = st->pipe;
unsigned referenced =
- pipe->is_texture_referenced(pipe, pt, face, level);
+ pipe->is_resource_referenced(pipe, pt, face, level);
if (referenced && ((referenced & PIPE_REFERENCED_FOR_WRITE) ||
(usage & PIPE_TRANSFER_WRITE)))
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index c62f7f2cc0..76ea7e6950 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -35,7 +35,7 @@
#include "main/mtypes.h"
struct pipe_context;
-struct pipe_texture;
+struct pipe_resource;
struct st_texture_image
@@ -51,7 +51,7 @@ struct st_texture_image
* Else if stImage->base.Data != NULL, image is stored there.
* Else there is no image data.
*/
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
struct pipe_transfer *transfer;
};
@@ -69,7 +69,7 @@ struct st_texture_object
/* On validation any active images held in main memory or in other
* textures will be copied to this texture and the old storage freed.
*/
- struct pipe_texture *pt;
+ struct pipe_resource *pt;
/* Default sampler view attached to this texture object. Created lazily
* on first binding.
@@ -100,7 +100,7 @@ st_texture_object(struct gl_texture_object *obj)
}
-static INLINE struct pipe_texture *
+static INLINE struct pipe_resource *
st_get_texobj_texture(struct gl_texture_object *texObj)
{
struct st_texture_object *stObj = st_texture_object(texObj);
@@ -108,7 +108,7 @@ st_get_texobj_texture(struct gl_texture_object *texObj)
}
-static INLINE struct pipe_texture *
+static INLINE struct pipe_resource *
st_get_stobj_texture(struct st_texture_object *stObj)
{
return stObj ? stObj->pt : NULL;
@@ -117,7 +117,7 @@ st_get_stobj_texture(struct st_texture_object *stObj)
static INLINE struct pipe_sampler_view *
st_sampler_view_from_texture(struct pipe_context *pipe,
- struct pipe_texture *texture)
+ struct pipe_resource *texture)
{
struct pipe_sampler_view templ;
@@ -144,7 +144,7 @@ st_get_stobj_sampler_view(struct st_texture_object *stObj)
}
-extern struct pipe_texture *
+extern struct pipe_resource *
st_texture_create(struct st_context *st,
enum pipe_texture_target target,
enum pipe_format format,
@@ -158,7 +158,7 @@ st_texture_create(struct st_context *st,
/* Check if an image fits into an existing texture object.
*/
extern GLboolean
-st_texture_match_image(const struct pipe_texture *pt,
+st_texture_match_image(const struct pipe_resource *pt,
const struct gl_texture_image *image,
GLuint face, GLuint level);
@@ -182,17 +182,17 @@ st_texture_image_unmap(struct st_context *st,
* value.
*/
extern const GLuint *
-st_texture_depth_offsets(struct pipe_texture *pt, GLuint level);
+st_texture_depth_offsets(struct pipe_resource *pt, GLuint level);
/* Return the linear offset of an image relative to the start of its region.
*/
extern GLuint
-st_texture_image_offset(const struct pipe_texture *pt,
+st_texture_image_offset(const struct pipe_resource *pt,
GLuint face, GLuint level);
extern GLuint
-st_texture_texel_offset(const struct pipe_texture * pt,
+st_texture_texel_offset(const struct pipe_resource * pt,
GLuint face, GLuint level,
GLuint col, GLuint row, GLuint img);
@@ -201,7 +201,7 @@ st_texture_texel_offset(const struct pipe_texture * pt,
*/
extern void
st_texture_image_data(struct st_context *st,
- struct pipe_texture *dst,
+ struct pipe_resource *dst,
GLuint face, GLuint level, void *src,
GLuint src_row_pitch, GLuint src_image_pitch);
@@ -210,13 +210,13 @@ st_texture_image_data(struct st_context *st,
*/
extern void
st_texture_image_copy(struct pipe_context *pipe,
- struct pipe_texture *dst, GLuint dstLevel,
- struct pipe_texture *src,
+ struct pipe_resource *dst, GLuint dstLevel,
+ struct pipe_resource *src,
GLuint face);
extern void
st_teximage_flush_before_map(struct st_context *st,
- struct pipe_texture *pt,
+ struct pipe_resource *pt,
unsigned int face,
unsigned int level,
enum pipe_transfer_usage usage);