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
This commit is contained in:
Keith Whitwell 2010-04-10 16:05:54 +01:00
parent e7f1e5ca64
commit 287c94ea49
430 changed files with 9264 additions and 16109 deletions

View file

@ -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

View file

@ -5,5 +5,5 @@ include $(TOP)/configs/linux
CONFIG_NAME = linux-debug
OPT_FLAGS = -g
CFLAGS += -pedantic
#CFLAGS += -pedantic
DEFINES += -DDEBUG -DDEBUG_MATH

View file

@ -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

View file

@ -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',

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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:
*/

View file

@ -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) {

View file

@ -59,7 +59,6 @@ extern "C" {
#endif
struct pipe_buffer;
struct pipe_fence_handle;

View file

@ -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);

View file

@ -60,7 +60,6 @@ extern "C" {
struct pb_desc;
struct pipe_buffer;
/**

View file

@ -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;
}

View file

@ -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,

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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

View file

@ -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) */

View file

@ -37,7 +37,7 @@ extern "C" {
struct pipe_context;
struct pipe_surface;
struct pipe_texture;
struct pipe_resource;
struct cso_context;

View file

@ -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;
}

View file

@ -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

View file

@ -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:

View file

@ -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);

View file

@ -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;
uint numAttribs = 2, i, j;
uint vertexBytes = 4 * (4 * numAttribs * sizeof(float));
struct pipe_resource *vbuf = NULL;
uint *v = NULL;
vertexBytes = 4 * (4 * numAttribs * sizeof(float));
v = MALLOC(vertexBytes);
if (v == NULL)
goto out;
/* 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);
/*
* 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);
}

View file

@ -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);

View file

@ -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,

View file

@ -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);
}

View file

@ -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

View file

@ -37,7 +37,7 @@ extern "C" {
struct pipe_context;
struct pipe_texture;
struct pipe_resource;
struct cso_context;
struct gen_mipmap_state;

View file

@ -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);
}
else
return screen->buffer_map(screen, buf, usage);
}
struct pipe_box box;
void *map;
static INLINE void
pipe_buffer_unmap(struct pipe_screen *screen,
struct pipe_buffer *buf)
{
screen->buffer_unmap(screen, buf);
}
static INLINE void *
pipe_buffer_map_range(struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned offset,
unsigned length,
unsigned usage)
{
assert(offset < buf->size);
assert(offset + length <= buf->size);
assert(offset < buffer->width0);
assert(offset + length <= buffer->width0);
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);
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;
}
/* 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_map(struct pipe_context *pipe,
struct pipe_resource *buffer,
unsigned usage,
struct pipe_transfer **transfer)
{
return pipe_buffer_map_range(pipe, buffer, 0, buffer->width0, usage, transfer);
}
static INLINE void
pipe_buffer_unmap(struct pipe_context *pipe,
struct pipe_resource *buf,
struct pipe_transfer *transfer)
{
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);
struct pipe_box box;
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);
}
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;
struct pipe_box box;
assert(offset < buf->size);
assert(offset + size <= buf->size);
assert(size);
u_box_1d(offset, size, &box);
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);
}
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);
struct pipe_transfer *src_transfer;
ubyte *map;
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);
}
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
}

View file

@ -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);
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_tex_transfer(pipe,
dst->texture,
dst->face,
dst->level,
dst->zslice,
PIPE_TRANSFER_WRITE,
dst_x, dst_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);
}

View file

@ -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);
}

View file

@ -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) */

View file

@ -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);

View file

@ -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);
}

View file

@ -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 */

View file

@ -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);
}

View file

@ -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);

View file

@ -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 */

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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

View file

@ -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);
}

View file

@ -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

View file

@ -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;
}

View file

@ -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 );

View file

@ -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;
}

View file

@ -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 */

View file

@ -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);
}

View file

@ -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 */

View file

@ -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));
}

View file

@ -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 */

File diff suppressed because it is too large Load diff

View file

@ -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 */

View file

@ -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;
}

View file

@ -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

View file

@ -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``.

View file

@ -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.
.. _resource_create:
.. _texture_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.
Destroy a resource. A resource is destroyed if it has no more references.
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.
Any pointers into the map should be considered invalid and discarded.

View file

@ -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 \

View file

@ -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;
}

View file

@ -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 */

View file

@ -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;

View file

@ -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;

View file

@ -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)
{

View file

@ -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",

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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 +

View file

@ -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,

View file

@ -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(texture);
assert(level <= texture->last_level);
assert(resource);
assert(level <= resource->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));
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;
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
/*
* 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;
}

View file

@ -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;
}

View file

@ -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],

View file

@ -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;

View file

@ -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 */

View file

@ -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);
}

View file

@ -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

View file

@ -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')

View file

@ -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;
}

View file

@ -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

View file

@ -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);

View file

@ -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 );
/***********************************************************************

View file

@ -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;
}

View file

@ -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 */

View file

@ -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;
}

View file

@ -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;
return &tex->b.b;
}
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;
}
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;
}

View file

@ -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;
}

View file

@ -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);
}

View file

@ -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);

View file

@ -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,

View file

@ -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;
}

View file

@ -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 */

View file

@ -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,

View file

@ -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 \

View file

@ -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',

View file

@ -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 );

View file

@ -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:

View file

@ -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]);
}
}

Some files were not shown because too many files have changed in this diff Show more