Compare commits

..

38 Commits

Author SHA1 Message Date
Emil Velikov
09e4f1a50f Increment version to 10.4.0-rc4
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-12-05 18:52:11 +00:00
Axel Davy
c7b9a2e38a st/nine: Fix vertex declarations for non-standard (usage/index)
Nine code to match vertex declaration to vs inputs was limiting
the number of possible combinations.

Some sm3 games have issues with that, because arbitrary (usage/index)
can be used.

This patch does the following changes to fix the problem:
. Change the numbers given to (usage/index) combinations to uint16
. Do not put limits on the indices when it doesn't make sense
. change the conversion rule (usage/index) -> number to fit all combinations
. Instead of having a table usage_map mapping a (usage/index) number to
an input index, usage_map maps input indices to their (usage/index)

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: Yaroslav Andrusyak <pontostroy@gmail.com>
Acked-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit 712a4c5438)
2014-12-03 23:20:56 +00:00
Axel Davy
6fcbf9aee3 st/nine: sm1_declusage_to_tgsi, do not restrict indices with TGSI_SEMANTIC_GENERIC
With sm3, you can declare an input/output with an usage and an usage index.

Nine code hardcodes the translation usage/index to a corresponding TGSI code.
The translation was limited to a few usage/index combinations that were corresponding
to most of the needs of games, but some games did not work.

This patch rewrites that Nine code to map all possible usage/index combination
to TGSI code. The index associated to TGSI_SEMANTIC_GENERIC doesn't need to be low
for good performance, as the old code was supposing, and is not particularly bounded
(it's UINT16). Given the index is BYTE, we can map all combinations.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: Yaroslav Andrusyak <pontostroy@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit 5d6d260833)
2014-12-03 23:20:01 +00:00
Axel Davy
fd2852fe5b st/nine: Queries: Fix D3DISSUE_END behaviour.
Issuing D3DISSUE_END should:
. reset previous queries if possible
. end the query

Previous behaviour wasn't calling end_query for
queries not needing D3DISSUE_BEGIN, nor resetting
previous queries.

This fixes several applications not launching properly.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit eac0b9b68a)

Conflicts:
	src/gallium/state_trackers/nine/query9.c
2014-12-03 23:18:48 +00:00
Brian Paul
57057c439e mesa: fix height error check for 1D array textures
height=0 is legal for 1D array textures (as depth=0 is legal for
2D arrays).  Fixes new piglit ext_texture_array-errors test.

Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
(cherry picked from commit 4e6244e80f)
2014-12-03 23:16:36 +00:00
Dave Airlie
b5cc04b6ad r600g/sb: fix issues cause by GLSL switching to loops for switch
Since 73dd50acf6
glsl: implement switch flow control using a loop

The SB backend was falling over in an assert or crashing.

Tracked this down to the loops having no repeats, but requiring
a working break, initial code just called the loop handler for
all non-if statements, but this caused a regression in
tests/shaders/dead-code-break-interaction.shader_test.
So I had to add further code to detect if all the departure
nodes are empty and avoid generating an empty loop for that case.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86089
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-By: Glenn Kennard <glenn.kennard@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 7b0067d23a)
2014-12-03 23:15:27 +00:00
Brian Paul
d2e9fd5b6d mesa: fix arithmetic error in _mesa_compute_compressed_pixelstore()
We need parenthesis around the expression which computes the number of
blocks per row.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 991d5cf8ce)
2014-12-03 23:15:12 +00:00
Ilia Mirkin
b61192f2ae freedreno/ir3: fix UMAD
Looks like none of the mad variants do u16 * u16 + u32, so just add in
the extra value "by hand".

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit de83ef677f)
2014-12-03 23:15:05 +00:00
Ilia Mirkin
75c4824d2f freedreno/a3xx: only enable blend clamp for non-float formats
This fixes arb_color_buffer_float-render GL_RGBA16F.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
(cherry picked from commit 3de9fa8ff4)
2014-12-03 23:14:48 +00:00
Christoph Bumiller
f30fbbdbdd nv50/ir/tgsi: handle TGSI_OPCODE_ARR
This instruction is used by st/nine.

Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit f3b4b263c2)
2014-12-03 23:14:34 +00:00
Emil Velikov
b247956c77 cherry-ignore: drop whitespace commit
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-12-03 23:13:53 +00:00
Axel Davy
72a802a9c2 st/nine: Fix setting of the shift modifier in nine_shader
It is an sint_4, but it was stored in a uint_8...
The code using it was acting as if it was signed.

Problem found thanks to Coverity

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit d52328fc39)
2014-12-03 22:59:28 +00:00
David Heidelberg
cfbc474d80 st/nine: remove unused pipe_viewport_state::translate[3] and scale[3]
2efabd9f5a removed them as unused.

This caused random memory overwrites (reported by Coverity).

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: David Heidelberg <david@ixit.cz>
(cherry picked from commit 90fea6b3e0)
2014-12-03 22:59:21 +00:00
Axel Davy
360872a45e st/nine: fix wrong variable reset
Error detected by Coverity (COPY_PASTE_ERROR)

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: David Heidelberg <david@ixit.cz>
(cherry picked from commit 614d9387c7)
2014-12-03 22:59:12 +00:00
David Heidelberg
42839ea5ba st/nine: return GetAvailableTextureMem in bytes as expected (v2)
PIPE_CAP_VIDEO_MEMORY returns the amount of video memory in megabytes,
so need to converted it to bytes.

Fixed Warframe memory detection.

v2: also prepare for cards with more than 4GB memory

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: Yaroslav Andrusyak <pontostroy@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: David Heidelberg <david@ixit.cz>
(cherry picked from commit a99f31bced)
2014-12-03 22:59:07 +00:00
Axel Davy
8dc03bd575 st/nine: Add pool check to SetTexture (v2)
D3DPOOL_SCRATCH is disallowed according to spec.
D3DPOOL_SYSTEMMEM should be allowed but we don't handle it right for now.

v2: Fixes segfault in SetTexture when unsetting the texture

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit 4eea2496bc)
2014-12-03 22:58:54 +00:00
Axel Davy
41906e9764 st/nine: propertly declare constants (v2)
Fixes "Error : CONST[20]: Undeclared source register" when running
dx9_alpha_blending_material. Also artifacts on ilo.

v2: also remove unused MISC_CONST

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit 890f963d64)
2014-12-03 22:58:49 +00:00
Stanislaw Halik
56572002fc st/nine: call DBG() at more external entry points
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: David Heidelberg <david@ixit.cz>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
Signed-off-by: Stanislaw Halik <sthalik@misaki.pl>
(cherry picked from commit 7f74b9d479)
2014-12-03 22:58:44 +00:00
Axel Davy
c0e0de45dc st/nine: rework the way D3DPOOL_SYSTEMMEM is handled
This patch moves the data field from Resource9 to Surface9 and cleans
D3DPOOL_SYSTEMMEM handling in Texture9. This fixes HL2 lost coast.

It also removes in Texture9 some code written to support importing
and exporting non D3DPOOL_SYSTEMMEM shared buffers. This code hadn't
the design required to support the feature and wasn't used.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit 6aeae7442d)
2014-12-03 22:58:39 +00:00
Axel Davy
b75a285633 st/nine: Rework Basetexture9 and Resource9.
Instead of having parts of the structures initialised by the parents,
have them initialised by the children.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Tested-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit 133b2087c5)
2014-12-03 22:58:35 +00:00
Axel Davy
1cf4dbdc81 st/nine: clean device9ex.
Pass ex specific parameters as arguments to device9 ctor instead
of passing them by filling the structure.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: David Heidelberg <david@ixit.cz>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
(cherry picked from commit 104b5a8193)
2014-12-03 22:58:29 +00:00
Emil Velikov
c29ddc923f Increment version to 10.4.0-rc3
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2014-11-28 17:58:26 +00:00
Ilia Mirkin
085de45812 freedreno/ir3: don't pass consts to madsh.m16 in MOD logic
madsh.m16 can't handle a const in src1, make sure to unconst it

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 37fe347542)
2014-11-28 17:29:29 +00:00
Dave Airlie
31c7e6c51d r600g: merge the TXQ and BUFFER constant buffers (v1.1)
We are using 1 more buffer than we have, although in the future the
driver should just end up using one buffer in total probably, this
is a good first step, it merges the txq cube array and buffer info
constants on r600 and evergreen.

This should in theory fix geom shader tests on r600.

v1.1: fix comments from Glenn.

Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 07ae69753c)

Squashed with commit

r600g: fix fallout from last patch

I accidentally rebased from the wrong machine and missed some
fixes that were on my r600 box.

doh.

this fixes a bunch of geom shader textureSize tests on rv635
from gpu reset to pass.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=86760
Reported-by: wolput@onsneteindhoven.nl
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit b10ddf962f)

Squashed with commit

r600g: make llvm code compile this time

Actually compiling the code helps make it compile.

Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 91a827624c)
2014-11-28 17:29:07 +00:00
José Fonseca
2a0290d5f5 st/wgl: Don't export wglGetExtensionsStringARB.
It's not exported by the official opengl32.dll neither.  Applications are
supposed to get it via wglGetProcAddress(), not GetProcAddress().

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
(cherry picked from commit cb009bdd44)
2014-11-28 17:28:28 +00:00
José Fonseca
f77a97f057 mapi/glapi: Fix dll linkage of GLES1 symbols.
This fixes several MSVC warnings like:

  warning C4273: 'glClearColorx' : inconsistent dll linkage

In fact, we should avoid using `declspec(dllexport)` altogether, and use
exclusively the .DEF instead, which gives more precise control of which
symbols must be exported, but all the public GL/GLES headers practically
force us to pick between `declspec(dllexport)` or
`declspec(dllimport)`.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
(cherry picked from commit 5fdb6d6839)
2014-11-28 17:28:20 +00:00
José Fonseca
d45c35c3d7 util/u_snprintf: Don't redefine HAVE_STDINT_H as 0.
We now always guarantee availability of stdint.h on MSVC -- if MSVC
doesn't supply one we use our own.

Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
(cherry picked from commit 4b6e93650c)
2014-11-28 17:28:13 +00:00
Emil Velikov
16eaf01a6a nine: the .pc file should not follow mesa version
The version provided by it should be the same as the one
provided/handled by the module. Add the missing tiny version.

Cc: <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: David Heidelberg <david@ixit.cz>
(cherry picked from commit 9b7037a369)
2014-11-26 21:23:59 +00:00
Chris Forbes
6316d415c4 i965/Gen6-7: Do not replace texcoords with point coord if not drawing points
Fixes broken rendering in Windows-based QtQuick2 apps run through Wine.
This library sets all texture units' GL_COORD_REPLACE, leaves point
sprite mode enabled, and then draws a triangle fan.

Will need a slightly different fix for Gen4-5, but I don't have my old
machines in a usable state currently.

V2: - Simplify patch -- the real changes are no longer duplicated across
      the Gen6 and Gen7 atoms.
    - Also don't clobber attr overrides -- which matters on Haswell too,
      and fixes the other half of the problem
    - Fix newly-introduced warnings
V3: - Use BRW_NEW_GEOMETRY_PROGRAM and brw->geometry_program rather than
      core flag and state; keep the state flags in order.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=84651
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 0008d0e59e)
2014-11-26 21:23:23 +00:00
Kenneth Graunke
dca88397ca glsl: Make lower_constant_arrays_to_uniforms require dereferences.
Ilia noticed that my lowering pass was converting the constant array
used by textureGatherOffsets' offsets parameter to a uniform.  This
broke textureGather for Nouveau, and is generally a horrible plan,
since it violates the GLSL constraint that offsets must be an
immediate constant.

When I wrote this pass, I neglected to consider whole array assignment.
I figured opt_array_splitting would handle constant indexing, so this
pass was really about fixing variable indexing.

textureGatherOffsets is an example of whole array access that we really
don't want to touch.  Whole array copies don't appear to benefit from
this either - they're most likely initializers for temporary arrays
which are going to be mutated anyway.  Since you're copying, you may
as well copy from immediates, not uniforms.

This patch makes the pass look for ir_dereference_arrays of
ir_constants, rather than looking for any ir_constant directly.
This way, it ignores whole array assignment.

No shader-db changes or Piglit regressions on Haswell.  Some Piglit
tests generate different code (fixing textureGatherOffsets on Nouveau).

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Tested-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 60f011af1a)
2014-11-26 21:23:14 +00:00
Chris Forbes
6c383aaadd mesa: Fix Get(GL_TRANSPOSE_CURRENT_MATRIX_ARB) to transpose
This was just returning the same value as GL_CURRENT_MATRIX_ARB.
Spotted while investigating something else in apitrace.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 2b4fe85f0e)
2014-11-26 21:23:08 +00:00
Chris Forbes
7e47ae3185 glsl: Generate unique names for each const array lowered to uniforms
Uniform names (even for hidden uniforms) are required to be unique; some
parts of the compiler assume they can be looked up by name.

Fixes the piglit test: tests/spec/glsl-1.20/linker/array-initializers-1

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: "10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit 129178893b)
2014-11-26 21:20:33 +00:00
Chris Forbes
9e94c05936 i965: Handle nested uniform array indexing
When converting a uniform array reference to a pull constant load, the
`reladdr` expression itself may have its own `reladdr`, arbitrarily
deeply. This arises from expressions like:

   a[b[x]]     where a, b are uniform arrays (or lowered const arrays),
               and x is not a constant.

Just iterate the lowering to pull constants until we stop seeing these
nested. For most shaders, there will be only one pass through this loop.

Fixes the piglit test:
tests/spec/glsl-1.20/linker/double-indirect-1.shader_test

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Cc: "10.3 10.4" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
(cherry picked from commit adefccd12a)
2014-11-26 21:20:11 +00:00
Dave Airlie
4952c49f21 r600g: do all CUBE ALU operations before gradient texture operations (v2.1)
This moves all the CUBE section above the gradients section,
so that the gradient emission happens on one block which
is what sb/hardware expect.

v2: avoid changes to bytecode by using spare temps
v2.1: shame gcc, oh the shame. (uninit var warnings)

Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit c88385603a)
2014-11-26 21:20:05 +00:00
Dave Airlie
013eba0ec1 r600: fix texture gradients instruction emission (v2)
The piglit tests were failing, and it appeared to be SB
optimising out things, but Glenn pointed out the gradients
are meant to be clause local, so we should emit the texture
instructions in the same clause. This moves things around
to always copy to a temp and then emit the texture clauses
for H/V.

v2: Glenn pointed out we could get another ALU fetch in
the wrong place, so load the src gpr earlier as well.

Fixes at least:
./bin/tex-miplevel-selection textureGrad 2D

Reviewed-by: Glenn Kennard <glenn.kennard@gmail.com>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
(cherry picked from commit 38ec184419)
2014-11-26 21:19:56 +00:00
Ilia Mirkin
db9a6b96ab nv50,nvc0: buffer resources can be bound as other things down the line
res->bind is not an indicator of how the resource is currently bound.
buffers can be rebound across different binding points without changing
underlying storage.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit fecae4625c)
2014-11-24 00:55:28 +00:00
Ilia Mirkin
4d9c0445dd nv50,nvc0: actually check constbufs for invalidation
The number of vertex buffers has nothing to do with the number of bound
constbufs.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit e80a0a7d9a)
2014-11-24 00:55:22 +00:00
Ilia Mirkin
1a8f90dc70 nv50/ir: set neg modifiers on min/max args
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=86618
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Cc: "10.4 10.3" <mesa-stable@lists.freedesktop.org>
(cherry picked from commit 7d07083cfd)
2014-11-24 00:55:17 +00:00
58 changed files with 770 additions and 585 deletions

View File

@@ -1 +1 @@
10.4.0-rc2
10.4.0-rc4

2
bin/.cherry-ignore Normal file
View File

@@ -0,0 +1,2 @@
# No whitespace commits in stable.
a10bf5c10caf27232d4df8da74d5c35c23eb883d

View File

@@ -2085,6 +2085,8 @@ AM_CONDITIONAL(HAVE_SPARC_ASM, test "x$asm_arch" = xsparc)
AC_SUBST([NINE_MAJOR], 1)
AC_SUBST([NINE_MINOR], 0)
AC_SUBST([NINE_TINY], 0)
AC_SUBST([NINE_VERSION], "$NINE_MAJOR.$NINE_MINOR.$NINE_TINY")
AC_SUBST([VDPAU_MAJOR], 1)
AC_SUBST([VDPAU_MINOR], 0)

View File

@@ -176,7 +176,7 @@
#define HAVE_ASPRINTF 1 /* not needed */
#define HAVE_STDARG_H 1
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 0
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_INTTYPES_H 0
#define HAVE_LOCALE_H 0

View File

@@ -105,8 +105,7 @@ fd3_blend_state_create(struct pipe_context *pctx,
A3XX_RB_MRT_BLEND_CONTROL_RGB_DEST_FACTOR(fd_blend_factor(rt->rgb_dst_factor)) |
A3XX_RB_MRT_BLEND_CONTROL_ALPHA_SRC_FACTOR(fd_blend_factor(rt->alpha_src_factor)) |
A3XX_RB_MRT_BLEND_CONTROL_ALPHA_BLEND_OPCODE(blend_func(rt->alpha_func)) |
A3XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR(fd_blend_factor(rt->alpha_dst_factor)) |
A3XX_RB_MRT_BLEND_CONTROL_CLAMP_ENABLE;
A3XX_RB_MRT_BLEND_CONTROL_ALPHA_DEST_FACTOR(fd_blend_factor(rt->alpha_dst_factor));
so->rb_mrt[i].control =
A3XX_RB_MRT_CONTROL_ROP_CODE(rop) |

View File

@@ -566,16 +566,20 @@ fd3_emit_state(struct fd_context *ctx, struct fd_ringbuffer *ring,
}
}
if ((dirty & FD_DIRTY_BLEND) && ctx->blend) {
if ((dirty & (FD_DIRTY_BLEND | FD_DIRTY_FRAMEBUFFER)) && ctx->blend) {
struct fd3_blend_stateobj *blend = fd3_blend_stateobj(ctx->blend);
uint32_t i;
for (i = 0; i < ARRAY_SIZE(blend->rb_mrt); i++) {
bool is_float = util_format_is_float(
pipe_surface_format(ctx->framebuffer.cbufs[i]));
OUT_PKT0(ring, REG_A3XX_RB_MRT_CONTROL(i), 1);
OUT_RING(ring, blend->rb_mrt[i].control);
OUT_PKT0(ring, REG_A3XX_RB_MRT_BLEND_CONTROL(i), 1);
OUT_RING(ring, blend->rb_mrt[i].blend_control);
OUT_RING(ring, blend->rb_mrt[i].blend_control |
COND(!is_float, A3XX_RB_MRT_BLEND_CONTROL_CLAMP_ENABLE));
}
}

View File

@@ -2112,7 +2112,7 @@ trans_cov(const struct instr_translater *t,
* madsh.m16 tmp1, a, b, tmp0 (mul-add shift high mix, i.e. ah * bl << 16)
* madsh.m16 dst, b, a, tmp1 (i.e. al * bh << 16)
*
* For UMAD, replace first mull.u with mad.u16.
* For UMAD, add in the extra argument after mull.u.
*/
static void
trans_umul(const struct instr_translater *t,
@@ -2135,16 +2135,16 @@ trans_umul(const struct instr_translater *t,
if (is_rel_or_const(b))
b = get_unconst(ctx, b);
if (t->tgsi_opc == TGSI_OPCODE_UMUL) {
/* mull.u tmp0, a, b */
instr = instr_create(ctx, 2, OPC_MULL_U);
vectorize(ctx, instr, &tmp0_dst, 2, a, 0, b, 0);
} else {
/* mull.u tmp0, a, b */
instr = instr_create(ctx, 2, OPC_MULL_U);
vectorize(ctx, instr, &tmp0_dst, 2, a, 0, b, 0);
if (t->tgsi_opc == TGSI_OPCODE_UMAD) {
struct tgsi_src_register *c = &inst->Src[2].Register;
/* mad.u16 tmp0, a, b, c */
instr = instr_create(ctx, 3, OPC_MAD_U16);
vectorize(ctx, instr, &tmp0_dst, 3, a, 0, b, 0, c, 0);
/* add.u tmp0, tmp0, c */
instr = instr_create(ctx, 2, OPC_ADD_U);
vectorize(ctx, instr, &tmp0_dst, 2, tmp0_src, 0, c, 0);
}
/* madsh.m16 tmp1, a, b, tmp0 */
@@ -2350,6 +2350,9 @@ trans_idiv(const struct instr_translater *t,
if (t->tgsi_opc == TGSI_OPCODE_MOD || t->tgsi_opc == TGSI_OPCODE_UMOD) {
/* The division result will have ended up in q. */
if (is_rel_or_const(b))
b = get_unconst(ctx, b);
/* mull.u r, q, b */
instr = instr_create(ctx, 2, OPC_MULL_U);
vectorize(ctx, instr, &r_dst, 2, q_src, 0, b, 0);

View File

@@ -924,7 +924,9 @@ CodeEmitterNV50::emitMINMAX(const Instruction *i)
break;
}
code[1] |= i->src(0).mod.abs() << 20;
code[1] |= i->src(0).mod.neg() << 26;
code[1] |= i->src(1).mod.abs() << 19;
code[1] |= i->src(1).mod.neg() << 27;
}
emitForm_MAD(i);
}

View File

@@ -2343,9 +2343,12 @@ Converter::handleInstruction(const struct tgsi_full_instruction *insn)
mkMov(dst0[c], val0);
break;
case TGSI_OPCODE_ARL:
case TGSI_OPCODE_ARR:
FOR_EACH_DST_ENABLED_CHANNEL(0, c, tgsi) {
const RoundMode rnd =
tgsi.getOpcode() == TGSI_OPCODE_ARR ? ROUND_N : ROUND_M;
src0 = fetchSrc(0, c);
mkCvt(OP_CVT, TYPE_S32, dst0[c], TYPE_F32, src0)->rnd = ROUND_M;
mkCvt(OP_CVT, TYPE_S32, dst0[c], TYPE_F32, src0)->rnd = rnd;
}
break;
case TGSI_OPCODE_UARL:

View File

@@ -180,7 +180,12 @@ nv50_invalidate_resource_storage(struct nouveau_context *ctx,
}
}
if (res->bind & PIPE_BIND_VERTEX_BUFFER) {
if (res->bind & (PIPE_BIND_VERTEX_BUFFER |
PIPE_BIND_INDEX_BUFFER |
PIPE_BIND_CONSTANT_BUFFER |
PIPE_BIND_STREAM_OUTPUT |
PIPE_BIND_SAMPLER_VIEW)) {
assert(nv50->num_vtxbufs <= PIPE_MAX_ATTRIBS);
for (i = 0; i < nv50->num_vtxbufs; ++i) {
if (nv50->vtxbuf[i].buffer == res) {
@@ -190,14 +195,11 @@ nv50_invalidate_resource_storage(struct nouveau_context *ctx,
return ref;
}
}
}
if (res->bind & PIPE_BIND_INDEX_BUFFER) {
if (nv50->idxbuf.buffer == res)
if (!--ref)
return ref;
}
if (res->bind & PIPE_BIND_SAMPLER_VIEW) {
for (s = 0; s < 3; ++s) {
assert(nv50->num_textures[s] <= PIPE_MAX_SAMPLERS);
for (i = 0; i < nv50->num_textures[s]; ++i) {
@@ -210,12 +212,11 @@ nv50_invalidate_resource_storage(struct nouveau_context *ctx,
}
}
}
}
if (res->bind & PIPE_BIND_CONSTANT_BUFFER) {
for (s = 0; s < 3; ++s) {
assert(nv50->num_vtxbufs <= NV50_MAX_PIPE_CONSTBUFS);
for (i = 0; i < nv50->num_vtxbufs; ++i) {
for (i = 0; i < NV50_MAX_PIPE_CONSTBUFS; ++i) {
if (!(nv50->constbuf_valid[s] & (1 << i)))
continue;
if (!nv50->constbuf[s][i].user &&
nv50->constbuf[s][i].u.buf == res) {
nv50->dirty |= NV50_NEW_CONSTBUF;

View File

@@ -196,7 +196,12 @@ nvc0_invalidate_resource_storage(struct nouveau_context *ctx,
}
}
if (res->bind & PIPE_BIND_VERTEX_BUFFER) {
if (res->bind & (PIPE_BIND_VERTEX_BUFFER |
PIPE_BIND_INDEX_BUFFER |
PIPE_BIND_CONSTANT_BUFFER |
PIPE_BIND_STREAM_OUTPUT |
PIPE_BIND_COMMAND_ARGS_BUFFER |
PIPE_BIND_SAMPLER_VIEW)) {
for (i = 0; i < nvc0->num_vtxbufs; ++i) {
if (nvc0->vtxbuf[i].buffer == res) {
nvc0->dirty |= NVC0_NEW_ARRAYS;
@@ -205,17 +210,14 @@ nvc0_invalidate_resource_storage(struct nouveau_context *ctx,
return ref;
}
}
}
if (res->bind & PIPE_BIND_INDEX_BUFFER) {
if (nvc0->idxbuf.buffer == res) {
nvc0->dirty |= NVC0_NEW_IDXBUF;
nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_IDX);
if (!--ref)
return ref;
}
}
if (res->bind & PIPE_BIND_SAMPLER_VIEW) {
for (s = 0; s < 5; ++s) {
for (i = 0; i < nvc0->num_textures[s]; ++i) {
if (nvc0->textures[s][i] &&
@@ -228,11 +230,11 @@ nvc0_invalidate_resource_storage(struct nouveau_context *ctx,
}
}
}
}
if (res->bind & PIPE_BIND_CONSTANT_BUFFER) {
for (s = 0; s < 5; ++s) {
for (i = 0; i < nvc0->num_vtxbufs; ++i) {
for (i = 0; i < NVC0_MAX_PIPE_CONSTBUFS; ++i) {
if (!(nvc0->constbuf_valid[s] & (1 << i)))
continue;
if (!nvc0->constbuf[s][i].user &&
nvc0->constbuf[s][i].u.buf == res) {
nvc0->dirty |= NVC0_NEW_CONSTBUF;

View File

@@ -23,7 +23,6 @@
#define CONSTANT_BUFFER_0_ADDR_SPACE 8
#define CONSTANT_BUFFER_1_ADDR_SPACE (CONSTANT_BUFFER_0_ADDR_SPACE + R600_UCP_CONST_BUFFER)
#define CONSTANT_TXQ_BUFFER (CONSTANT_BUFFER_0_ADDR_SPACE + R600_TXQ_CONST_BUFFER)
#define LLVM_R600_BUFFER_INFO_CONST_BUFFER \
(CONSTANT_BUFFER_0_ADDR_SPACE + R600_BUFFER_INFO_CONST_BUFFER)
@@ -690,7 +689,7 @@ static void llvm_emit_tex(
if (emit_data->inst->Dst[0].Register.WriteMask & 4) {
LLVMValueRef offset = lp_build_const_int32(bld_base->base.gallivm, 0);
LLVMValueRef ZLayer = LLVMBuildExtractElement(gallivm->builder,
llvm_load_const_buffer(bld_base, offset, CONSTANT_TXQ_BUFFER),
llvm_load_const_buffer(bld_base, offset, LLVM_R600_BUFFER_INFO_CONST_BUFFER),
lp_build_const_int32(gallivm, 0), "");
emit_data->output[0] = LLVMBuildInsertElement(gallivm->builder, emit_data->output[0], ZLayer, lp_build_const_int32(gallivm, 2), "");

View File

@@ -44,20 +44,19 @@
#define R600_TRACE_CS_DWORDS 7
#define R600_MAX_USER_CONST_BUFFERS 13
#define R600_MAX_DRIVER_CONST_BUFFERS 4
#define R600_MAX_DRIVER_CONST_BUFFERS 3
#define R600_MAX_CONST_BUFFERS (R600_MAX_USER_CONST_BUFFERS + R600_MAX_DRIVER_CONST_BUFFERS)
/* start driver buffers after user buffers */
#define R600_UCP_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS)
#define R600_TXQ_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 1)
#define R600_BUFFER_INFO_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 2)
#define R600_GS_RING_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 3)
/* Currently R600_MAX_CONST_BUFFERS is too large, the hardware only has 16 buffers, but the driver is
* trying to use 17. Avoid accidentally aliasing with user UBOs for SAMPLE_POSITIONS by using an id<16.
#define R600_BUFFER_INFO_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 1)
#define R600_GS_RING_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS + 2)
/* Currently R600_MAX_CONST_BUFFERS just fits on the hw, which has a limit
* of 16 const buffers.
* UCP/SAMPLE_POSITIONS are never accessed by same shader stage so they can use the same id.
*
* Fixing this properly would require the driver to combine its buffers into a single hardware buffer,
* which would also allow supporting the d3d 11 mandated minimum of 15 user const buffers.
* In order to support d3d 11 mandated minimum of 15 user const buffers
* we'd have to squash all use cases into one driver buffer.
*/
#define R600_SAMPLE_POSITIONS_CONST_BUFFER (R600_MAX_USER_CONST_BUFFERS)
@@ -316,7 +315,6 @@ struct r600_samplerview_state {
uint32_t dirty_mask;
uint32_t compressed_depthtex_mask; /* which textures are depth */
uint32_t compressed_colortex_mask;
boolean dirty_txq_constants;
boolean dirty_buffer_constants;
};

View File

@@ -5035,8 +5035,9 @@ static int r600_do_buffer_txq(struct r600_shader_ctx *ctx)
alu.op = ALU_OP1_MOV;
if (ctx->bc->chip_class >= EVERGREEN) {
alu.src[0].sel = 512 + (id / 4);
alu.src[0].chan = id % 4;
/* channel 0 or 2 of each word */
alu.src[0].sel = 512 + (id / 2);
alu.src[0].chan = (id % 2) * 2;
} else {
/* r600 we have them at channel 2 of the second dword */
alu.src[0].sel = 512 + (id * 2) + 1;
@@ -5095,6 +5096,14 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
inst->Instruction.Opcode == TGSI_OPCODE_TG4)
sampler_src_reg = 2;
/* TGSI moves the sampler to src reg 3 for TXD */
if (inst->Instruction.Opcode == TGSI_OPCODE_TXD)
sampler_src_reg = 3;
sampler_index_mode = inst->Src[sampler_src_reg].Indirect.Index == 2 ? 2 : 0; // CF_INDEX_1 : CF_INDEX_NONE
if (sampler_index_mode)
ctx->shader->uses_index_registers = true;
src_gpr = tgsi_tex_get_src_gpr(ctx, 0);
if (inst->Texture.Texture == TGSI_TEXTURE_BUFFER) {
@@ -5109,64 +5118,7 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
}
}
if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
/* TGSI moves the sampler to src reg 3 for TXD */
sampler_src_reg = 3;
sampler_index_mode = inst->Src[sampler_src_reg].Indirect.Index == 2 ? 2 : 0; // CF_INDEX_1 : CF_INDEX_NONE
for (i = 1; i < 3; i++) {
/* set gradients h/v */
memset(&tex, 0, sizeof(struct r600_bytecode_tex));
tex.op = (i == 1) ? FETCH_OP_SET_GRADIENTS_H :
FETCH_OP_SET_GRADIENTS_V;
tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
tex.sampler_index_mode = sampler_index_mode;
tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
tex.resource_index_mode = sampler_index_mode;
if (tgsi_tex_src_requires_loading(ctx, i)) {
tex.src_gpr = r600_get_temp(ctx);
tex.src_sel_x = 0;
tex.src_sel_y = 1;
tex.src_sel_z = 2;
tex.src_sel_w = 3;
for (j = 0; j < 4; j++) {
memset(&alu, 0, sizeof(struct r600_bytecode_alu));
alu.op = ALU_OP1_MOV;
r600_bytecode_src(&alu.src[0], &ctx->src[i], j);
alu.dst.sel = tex.src_gpr;
alu.dst.chan = j;
if (j == 3)
alu.last = 1;
alu.dst.write = 1;
r = r600_bytecode_add_alu(ctx->bc, &alu);
if (r)
return r;
}
} else {
tex.src_gpr = tgsi_tex_get_src_gpr(ctx, i);
tex.src_sel_x = ctx->src[i].swizzle[0];
tex.src_sel_y = ctx->src[i].swizzle[1];
tex.src_sel_z = ctx->src[i].swizzle[2];
tex.src_sel_w = ctx->src[i].swizzle[3];
tex.src_rel = ctx->src[i].rel;
}
tex.dst_gpr = ctx->temp_reg; /* just to avoid confusing the asm scheduler */
tex.dst_sel_x = tex.dst_sel_y = tex.dst_sel_z = tex.dst_sel_w = 7;
if (inst->Texture.Texture != TGSI_TEXTURE_RECT) {
tex.coord_type_x = 1;
tex.coord_type_y = 1;
tex.coord_type_z = 1;
tex.coord_type_w = 1;
}
r = r600_bytecode_add_tex(ctx->bc, &tex);
if (r)
return r;
}
} else if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) {
if (inst->Instruction.Opcode == TGSI_OPCODE_TXP) {
int out_chan;
/* Add perspective divide */
if (ctx->bc->chip_class == CAYMAN) {
@@ -5230,9 +5182,6 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
src_gpr = ctx->temp_reg;
}
sampler_index_mode = inst->Src[sampler_src_reg].Indirect.Index == 2 ? 2 : 0; // CF_INDEX_1 : CF_INDEX_NONE
if (sampler_index_mode)
ctx->shader->uses_index_registers = true;
if ((inst->Texture.Texture == TGSI_TEXTURE_CUBE ||
inst->Texture.Texture == TGSI_TEXTURE_CUBE_ARRAY ||
@@ -5451,6 +5400,69 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
src_gpr = ctx->temp_reg;
}
if (inst->Instruction.Opcode == TGSI_OPCODE_TXD) {
int temp_h = 0, temp_v = 0;
int start_val = 0;
/* if we've already loaded the src (i.e. CUBE don't reload it). */
if (src_loaded == TRUE)
start_val = 1;
else
src_loaded = TRUE;
for (i = start_val; i < 3; i++) {
int treg = r600_get_temp(ctx);
if (i == 0)
src_gpr = treg;
else if (i == 1)
temp_h = treg;
else
temp_v = treg;
for (j = 0; j < 4; j++) {
memset(&alu, 0, sizeof(struct r600_bytecode_alu));
alu.op = ALU_OP1_MOV;
r600_bytecode_src(&alu.src[0], &ctx->src[i], j);
alu.dst.sel = treg;
alu.dst.chan = j;
if (j == 3)
alu.last = 1;
alu.dst.write = 1;
r = r600_bytecode_add_alu(ctx->bc, &alu);
if (r)
return r;
}
}
for (i = 1; i < 3; i++) {
/* set gradients h/v */
memset(&tex, 0, sizeof(struct r600_bytecode_tex));
tex.op = (i == 1) ? FETCH_OP_SET_GRADIENTS_H :
FETCH_OP_SET_GRADIENTS_V;
tex.sampler_id = tgsi_tex_get_src_gpr(ctx, sampler_src_reg);
tex.sampler_index_mode = sampler_index_mode;
tex.resource_id = tex.sampler_id + R600_MAX_CONST_BUFFERS;
tex.resource_index_mode = sampler_index_mode;
tex.src_gpr = (i == 1) ? temp_h : temp_v;
tex.src_sel_x = 0;
tex.src_sel_y = 1;
tex.src_sel_z = 2;
tex.src_sel_w = 3;
tex.dst_gpr = r600_get_temp(ctx); /* just to avoid confusing the asm scheduler */
tex.dst_sel_x = tex.dst_sel_y = tex.dst_sel_z = tex.dst_sel_w = 7;
if (inst->Texture.Texture != TGSI_TEXTURE_RECT) {
tex.coord_type_x = 1;
tex.coord_type_y = 1;
tex.coord_type_z = 1;
tex.coord_type_w = 1;
}
r = r600_bytecode_add_tex(ctx->bc, &tex);
if (r)
return r;
}
}
if (src_requires_loading && !src_loaded) {
for (i = 0; i < 4; i++) {
memset(&alu, 0, sizeof(struct r600_bytecode_alu));
@@ -5686,9 +5698,16 @@ static int tgsi_tex(struct r600_shader_ctx *ctx)
memset(&alu, 0, sizeof(struct r600_bytecode_alu));
alu.op = ALU_OP1_MOV;
alu.src[0].sel = 512 + (id / 4);
alu.src[0].kc_bank = R600_TXQ_CONST_BUFFER;
alu.src[0].chan = id % 4;
if (ctx->bc->chip_class >= EVERGREEN) {
/* channel 1 or 3 of each word */
alu.src[0].sel = 512 + (id / 2);
alu.src[0].chan = ((id % 2) * 2) + 1;
} else {
/* r600 we have them at channel 2 of the second dword */
alu.src[0].sel = 512 + (id * 2) + 1;
alu.src[0].chan = 2;
}
alu.src[0].kc_bank = R600_BUFFER_INFO_CONST_BUFFER;
tgsi_dst(ctx, &inst->Dst[0], 2, &alu.dst);
alu.last = 1;
r = r600_bytecode_add_alu(ctx->bc, &alu);

View File

@@ -649,7 +649,6 @@ static void r600_set_sampler_views(struct pipe_context *pipe, unsigned shader,
dst->views.dirty_mask |= new_mask;
dst->views.compressed_depthtex_mask &= dst->views.enabled_mask;
dst->views.compressed_colortex_mask &= dst->views.enabled_mask;
dst->views.dirty_txq_constants = TRUE;
dst->views.dirty_buffer_constants = TRUE;
r600_sampler_views_dirty(rctx, &dst->views);
@@ -984,6 +983,7 @@ static void r600_set_sample_mask(struct pipe_context *pipe, unsigned sample_mask
* then in the shader, we AND the 4 components with 0xffffffff or 0,
* then OR the alpha with the value given here.
* We use a 6th constant to store the txq buffer size in
* we use 7th slot for number of cube layers in a cube map array.
*/
static void r600_setup_buffer_constants(struct r600_context *rctx, int shader_type)
{
@@ -1022,6 +1022,7 @@ static void r600_setup_buffer_constants(struct r600_context *rctx, int shader_ty
samplers->buffer_constants[offset + 4] = 0;
samplers->buffer_constants[offset + 5] = samplers->views.views[i]->base.texture->width0 / util_format_get_blocksize(samplers->views.views[i]->base.format);
samplers->buffer_constants[offset + 6] = samplers->views.views[i]->base.texture->array_size / 6;
}
}
@@ -1033,7 +1034,10 @@ static void r600_setup_buffer_constants(struct r600_context *rctx, int shader_ty
pipe_resource_reference(&cb.buffer, NULL);
}
/* On evergreen we only need to store the buffer size for TXQ */
/* On evergreen we store two values
* 1. buffer size for TXQ
* 2. number of cube layers in a cube map array.
*/
static void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type)
{
struct r600_textures_info *samplers = &rctx->samplers[shader_type];
@@ -1048,12 +1052,16 @@ static void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type
samplers->views.dirty_buffer_constants = FALSE;
bits = util_last_bit(samplers->views.enabled_mask);
array_size = bits * sizeof(uint32_t) * 4;
array_size = bits * 2 * sizeof(uint32_t) * 4;
samplers->buffer_constants = realloc(samplers->buffer_constants, array_size);
memset(samplers->buffer_constants, 0, array_size);
for (i = 0; i < bits; i++)
if (samplers->views.enabled_mask & (1 << i))
samplers->buffer_constants[i] = samplers->views.views[i]->base.texture->width0 / util_format_get_blocksize(samplers->views.views[i]->base.format);
for (i = 0; i < bits; i++) {
if (samplers->views.enabled_mask & (1 << i)) {
uint32_t offset = i * 2;
samplers->buffer_constants[offset] = samplers->views.views[i]->base.texture->width0 / util_format_get_blocksize(samplers->views.views[i]->base.format);
samplers->buffer_constants[offset + 1] = samplers->views.views[i]->base.texture->array_size / 6;
}
}
cb.buffer = NULL;
cb.user_buffer = samplers->buffer_constants;
@@ -1063,35 +1071,6 @@ static void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type
pipe_resource_reference(&cb.buffer, NULL);
}
static void r600_setup_txq_cube_array_constants(struct r600_context *rctx, int shader_type)
{
struct r600_textures_info *samplers = &rctx->samplers[shader_type];
int bits;
uint32_t array_size;
struct pipe_constant_buffer cb;
int i;
if (!samplers->views.dirty_txq_constants)
return;
samplers->views.dirty_txq_constants = FALSE;
bits = util_last_bit(samplers->views.enabled_mask);
array_size = bits * sizeof(uint32_t) * 4;
samplers->txq_constants = realloc(samplers->txq_constants, array_size);
memset(samplers->txq_constants, 0, array_size);
for (i = 0; i < bits; i++)
if (samplers->views.enabled_mask & (1 << i))
samplers->txq_constants[i] = samplers->views.views[i]->base.texture->array_size / 6;
cb.buffer = NULL;
cb.user_buffer = samplers->txq_constants;
cb.buffer_offset = 0;
cb.buffer_size = array_size;
rctx->b.b.set_constant_buffer(&rctx->b.b, shader_type, R600_TXQ_CONST_BUFFER, &cb);
pipe_resource_reference(&cb.buffer, NULL);
}
/* set sample xy locations as array of fragment shader constants */
void r600_set_sample_locations_constant_buffer(struct r600_context *rctx)
{
@@ -1175,7 +1154,7 @@ static bool r600_update_derived_state(struct r600_context *rctx)
struct pipe_context * ctx = (struct pipe_context*)rctx;
bool ps_dirty = false, vs_dirty = false, gs_dirty = false;
bool blend_disable;
bool need_buf_const;
if (!rctx->blitter->running) {
unsigned i;
@@ -1296,29 +1275,35 @@ static bool r600_update_derived_state(struct r600_context *rctx)
/* on R600 we stuff masks + txq info into one constant buffer */
/* on evergreen we only need a txq info one */
if (rctx->b.chip_class < EVERGREEN) {
if (rctx->ps_shader && rctx->ps_shader->current->shader.uses_tex_buffers)
r600_setup_buffer_constants(rctx, PIPE_SHADER_FRAGMENT);
if (rctx->vs_shader && rctx->vs_shader->current->shader.uses_tex_buffers)
r600_setup_buffer_constants(rctx, PIPE_SHADER_VERTEX);
if (rctx->gs_shader && rctx->gs_shader->current->shader.uses_tex_buffers)
r600_setup_buffer_constants(rctx, PIPE_SHADER_GEOMETRY);
} else {
if (rctx->ps_shader && rctx->ps_shader->current->shader.uses_tex_buffers)
eg_setup_buffer_constants(rctx, PIPE_SHADER_FRAGMENT);
if (rctx->vs_shader && rctx->vs_shader->current->shader.uses_tex_buffers)
eg_setup_buffer_constants(rctx, PIPE_SHADER_VERTEX);
if (rctx->gs_shader && rctx->gs_shader->current->shader.uses_tex_buffers)
eg_setup_buffer_constants(rctx, PIPE_SHADER_GEOMETRY);
if (rctx->ps_shader) {
need_buf_const = rctx->ps_shader->current->shader.uses_tex_buffers || rctx->ps_shader->current->shader.has_txq_cube_array_z_comp;
if (need_buf_const) {
if (rctx->b.chip_class < EVERGREEN)
r600_setup_buffer_constants(rctx, PIPE_SHADER_FRAGMENT);
else
eg_setup_buffer_constants(rctx, PIPE_SHADER_FRAGMENT);
}
}
if (rctx->vs_shader) {
need_buf_const = rctx->vs_shader->current->shader.uses_tex_buffers || rctx->vs_shader->current->shader.has_txq_cube_array_z_comp;
if (need_buf_const) {
if (rctx->b.chip_class < EVERGREEN)
r600_setup_buffer_constants(rctx, PIPE_SHADER_VERTEX);
else
eg_setup_buffer_constants(rctx, PIPE_SHADER_VERTEX);
}
}
if (rctx->ps_shader && rctx->ps_shader->current->shader.has_txq_cube_array_z_comp)
r600_setup_txq_cube_array_constants(rctx, PIPE_SHADER_FRAGMENT);
if (rctx->vs_shader && rctx->vs_shader->current->shader.has_txq_cube_array_z_comp)
r600_setup_txq_cube_array_constants(rctx, PIPE_SHADER_VERTEX);
if (rctx->gs_shader && rctx->gs_shader->current->shader.has_txq_cube_array_z_comp)
r600_setup_txq_cube_array_constants(rctx, PIPE_SHADER_GEOMETRY);
if (rctx->gs_shader) {
need_buf_const = rctx->gs_shader->current->shader.uses_tex_buffers || rctx->gs_shader->current->shader.has_txq_cube_array_z_comp;
if (need_buf_const) {
if (rctx->b.chip_class < EVERGREEN)
r600_setup_buffer_constants(rctx, PIPE_SHADER_GEOMETRY);
else
eg_setup_buffer_constants(rctx, PIPE_SHADER_GEOMETRY);
}
}
if (rctx->b.chip_class < EVERGREEN && rctx->ps_shader && rctx->vs_shader) {
if (!r600_adjust_gprs(rctx)) {

View File

@@ -46,15 +46,22 @@ int bc_finalizer::run() {
for (regions_vec::reverse_iterator I = rv.rbegin(), E = rv.rend(); I != E;
++I) {
region_node *r = *I;
bool is_if = false;
assert(r);
bool loop = r->is_loop();
assert(r->first);
if (r->first->is_container()) {
container_node *repdep1 = static_cast<container_node*>(r->first);
assert(repdep1->is_depart() || repdep1->is_repeat());
if_node *n_if = static_cast<if_node*>(repdep1->first);
if (n_if && n_if->is_if())
is_if = true;
}
if (loop)
finalize_loop(r);
else
if (is_if)
finalize_if(r);
else
finalize_loop(r);
r->expand();
}
@@ -112,16 +119,33 @@ void bc_finalizer::finalize_loop(region_node* r) {
cf_node *loop_start = sh.create_cf(CF_OP_LOOP_START_DX10);
cf_node *loop_end = sh.create_cf(CF_OP_LOOP_END);
bool has_instr = false;
loop_start->jump_after(loop_end);
loop_end->jump_after(loop_start);
if (!r->is_loop()) {
for (depart_vec::iterator I = r->departs.begin(), E = r->departs.end();
I != E; ++I) {
depart_node *dep = *I;
if (!dep->empty()) {
has_instr = true;
break;
}
}
} else
has_instr = true;
if (has_instr) {
loop_start->jump_after(loop_end);
loop_end->jump_after(loop_start);
}
for (depart_vec::iterator I = r->departs.begin(), E = r->departs.end();
I != E; ++I) {
depart_node *dep = *I;
cf_node *loop_break = sh.create_cf(CF_OP_LOOP_BREAK);
loop_break->jump(loop_end);
dep->push_back(loop_break);
if (has_instr) {
cf_node *loop_break = sh.create_cf(CF_OP_LOOP_BREAK);
loop_break->jump(loop_end);
dep->push_back(loop_break);
}
dep->expand();
}
@@ -137,8 +161,10 @@ void bc_finalizer::finalize_loop(region_node* r) {
rep->expand();
}
r->push_front(loop_start);
r->push_back(loop_end);
if (has_instr) {
r->push_front(loop_start);
r->push_back(loop_end);
}
}
void bc_finalizer::finalize_if(region_node* r) {

View File

@@ -990,7 +990,7 @@ NineAdapter9_CreateDevice( struct NineAdapter9 *This,
params.BehaviorFlags = BehaviorFlags;
hr = NineDevice9_new(screen, &params, &caps, pPresentationParameters,
pD3D9, pPresentationGroup, This->ctx,
pD3D9, pPresentationGroup, This->ctx, FALSE, NULL,
(struct NineDevice9 **)ppReturnedDeviceInterface);
if (FAILED(hr)) {
DBG("Failed to create device.\n");

View File

@@ -41,25 +41,31 @@
HRESULT
NineBaseTexture9_ctor( struct NineBaseTexture9 *This,
struct NineUnknownParams *pParams,
struct pipe_resource *initResource,
D3DRESOURCETYPE Type,
D3DPOOL Pool )
D3DFORMAT format,
D3DPOOL Pool,
DWORD Usage)
{
BOOL alloc = (Pool == D3DPOOL_DEFAULT) && !This->base.resource &&
(This->format != D3DFMT_NULL);
BOOL alloc = (Pool == D3DPOOL_DEFAULT) && !initResource &&
(format != D3DFMT_NULL);
HRESULT hr;
DWORD usage = This->base.usage;
user_assert(!(usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) ||
DBG("This=%p, pParams=%p initResource=%p Type=%d format=%d Pool=%d Usage=%d\n",
This, pParams, initResource, Type, format, Pool, Usage);
user_assert(!(Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)) ||
Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
user_assert(!(usage & D3DUSAGE_DYNAMIC) ||
user_assert(!(Usage & D3DUSAGE_DYNAMIC) ||
Pool != D3DPOOL_MANAGED, D3DERR_INVALIDCALL);
hr = NineResource9_ctor(&This->base, pParams, alloc, Type, Pool);
hr = NineResource9_ctor(&This->base, pParams, initResource, alloc, Type, Pool, Usage);
if (FAILED(hr))
return hr;
This->format = format;
This->pipe = pParams->device->pipe;
This->mipfilter = (This->base.usage & D3DUSAGE_AUTOGENMIPMAP) ?
This->mipfilter = (Usage & D3DUSAGE_AUTOGENMIPMAP) ?
D3DTEXF_LINEAR : D3DTEXF_NONE;
This->lod = 0;
This->lod_resident = -1;
@@ -90,6 +96,8 @@ NineBaseTexture9_SetLOD( struct NineBaseTexture9 *This,
{
DWORD old = This->lod;
DBG("This=%p LODNew=%d\n", This, LODNew);
user_assert(This->base.pool == D3DPOOL_MANAGED, 0);
This->lod = MIN2(LODNew, This->base.info.last_level);
@@ -103,12 +111,16 @@ NineBaseTexture9_SetLOD( struct NineBaseTexture9 *This,
DWORD WINAPI
NineBaseTexture9_GetLOD( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
return This->lod;
}
DWORD WINAPI
NineBaseTexture9_GetLevelCount( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
if (This->base.usage & D3DUSAGE_AUTOGENMIPMAP)
return 1;
return This->base.info.last_level + 1;
@@ -118,6 +130,8 @@ HRESULT WINAPI
NineBaseTexture9_SetAutoGenFilterType( struct NineBaseTexture9 *This,
D3DTEXTUREFILTERTYPE FilterType )
{
DBG("This=%p FilterType=%d\n", This, FilterType);
if (!(This->base.usage & D3DUSAGE_AUTOGENMIPMAP))
return D3D_OK;
user_assert(FilterType != D3DTEXF_NONE, D3DERR_INVALIDCALL);
@@ -130,6 +144,8 @@ NineBaseTexture9_SetAutoGenFilterType( struct NineBaseTexture9 *This,
D3DTEXTUREFILTERTYPE WINAPI
NineBaseTexture9_GetAutoGenFilterType( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
return This->mipfilter;
}
@@ -430,6 +446,8 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
struct pipe_sampler_view templ;
uint8_t swizzle[4];
DBG("This=%p sRGB=%d\n", This, sRGB);
if (unlikely(!resource)) {
if (unlikely(This->format == D3DFMT_NULL))
return D3D_OK;
@@ -482,6 +500,8 @@ NineBaseTexture9_UpdateSamplerView( struct NineBaseTexture9 *This,
void WINAPI
NineBaseTexture9_PreLoad( struct NineBaseTexture9 *This )
{
DBG("This=%p\n", This);
if (This->dirty && This->base.pool == D3DPOOL_MANAGED)
NineBaseTexture9_UploadSelf(This);
}
@@ -490,9 +510,9 @@ NineBaseTexture9_PreLoad( struct NineBaseTexture9 *This )
void
NineBaseTexture9_Dump( struct NineBaseTexture9 *This )
{
DBG("\nNineBaseTexture9(%p->%p/%p): Pool=%s Type=%s Usage=%s\n"
DBG("\nNineBaseTexture9(%p->NULL/%p): Pool=%s Type=%s Usage=%s\n"
"Format=%s Dims=%ux%ux%u/%u LastLevel=%u Lod=%u(%u)\n", This,
This->base.resource, This->base.data,
This->base.resource,
nine_D3DPOOL_to_str(This->base.pool),
nine_D3DRTYPE_to_str(This->base.type),
nine_D3DUSAGE_to_str(This->base.usage),

View File

@@ -59,8 +59,11 @@ NineBaseTexture9( void *data )
HRESULT
NineBaseTexture9_ctor( struct NineBaseTexture9 *This,
struct NineUnknownParams *pParams,
struct pipe_resource *initResource,
D3DRESOURCETYPE Type,
D3DPOOL Pool );
D3DFORMAT format,
D3DPOOL Pool,
DWORD Usage);
void
NineBaseTexture9_dtor( struct NineBaseTexture9 *This );

View File

@@ -42,6 +42,11 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
D3DSURFACE_DESC sfdesc;
HRESULT hr;
DBG("This=%p pParams=%p EdgeLength=%u Levels=%u Usage=%d "
"Format=%d Pool=%d pSharedHandle=%p\n",
This, pParams, EdgeLength, Levels, Usage,
Format, Pool, pSharedHandle);
user_assert(!(Usage & D3DUSAGE_AUTOGENMIPMAP) ||
(Pool != D3DPOOL_SYSTEMMEM && Levels <= 1), D3DERR_INVALIDCALL);
@@ -50,9 +55,6 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
if (Usage & D3DUSAGE_AUTOGENMIPMAP)
Levels = 0;
This->base.format = Format;
This->base.base.usage = Usage;
info->screen = pParams->device->screen;
info->target = PIPE_TEXTURE_CUBE;
info->format = d3d9_to_pipe_format(Format);
@@ -85,8 +87,8 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
if (!This->surfaces)
return E_OUTOFMEMORY;
hr = NineBaseTexture9_ctor(&This->base, pParams, D3DRTYPE_CUBETEXTURE,
Pool);
hr = NineBaseTexture9_ctor(&This->base, pParams, NULL, D3DRTYPE_CUBETEXTURE,
Format, Pool, Usage);
if (FAILED(hr))
return hr;
This->base.pstype = 2;
@@ -105,7 +107,7 @@ NineCubeTexture9_ctor( struct NineCubeTexture9 *This,
sfdesc.Width = sfdesc.Height = u_minify(EdgeLength, i / 6);
hr = NineSurface9_new(This->base.base.base.device, NineUnknown(This),
This->base.base.resource, D3DRTYPE_CUBETEXTURE,
This->base.base.resource, NULL, D3DRTYPE_CUBETEXTURE,
i / 6, i % 6,
&sfdesc, &This->surfaces[i]);
if (FAILED(hr))
@@ -138,6 +140,8 @@ NineCubeTexture9_GetLevelDesc( struct NineCubeTexture9 *This,
UINT Level,
D3DSURFACE_DESC *pDesc )
{
DBG("This=%p Level=%u pDesc=%p\n", This, Level, pDesc);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
user_assert(Level == 0 || !(This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP),
D3DERR_INVALIDCALL);
@@ -155,6 +159,9 @@ NineCubeTexture9_GetCubeMapSurface( struct NineCubeTexture9 *This,
{
const unsigned s = Level * 6 + FaceType;
DBG("This=%p FaceType=%d Level=%u ppCubeMapSurface=%p\n",
This, FaceType, Level, ppCubeMapSurface);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
user_assert(Level == 0 || !(This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP),
D3DERR_INVALIDCALL);
@@ -176,6 +183,9 @@ NineCubeTexture9_LockRect( struct NineCubeTexture9 *This,
{
const unsigned s = Level * 6 + FaceType;
DBG("This=%p FaceType=%d Level=%u pLockedRect=%p pRect=%p Flags=%d\n",
This, FaceType, Level, pLockedRect, pRect, Flags);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
user_assert(Level == 0 || !(This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP),
D3DERR_INVALIDCALL);
@@ -191,6 +201,8 @@ NineCubeTexture9_UnlockRect( struct NineCubeTexture9 *This,
{
const unsigned s = Level * 6 + FaceType;
DBG("This=%p FaceType=%d Level=%u\n", This, FaceType, Level);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
user_assert(FaceType < 6, D3DERR_INVALIDCALL);
@@ -202,6 +214,8 @@ NineCubeTexture9_AddDirtyRect( struct NineCubeTexture9 *This,
D3DCUBEMAP_FACES FaceType,
const RECT *pDirtyRect )
{
DBG("This=%p FaceType=%d pDirtyRect=%p\n", This, FaceType, pDirtyRect);
user_assert(FaceType < 6, D3DERR_INVALIDCALL);
if (This->base.base.pool != D3DPOOL_MANAGED) {

View File

@@ -58,6 +58,8 @@ NineDevice9_SetDefaultState( struct NineDevice9 *This, boolean is_reset )
{
struct NineSurface9 *refSurf = NULL;
DBG("This=%p is_reset=%d\n", This, (int) is_reset);
assert(!This->is_recording);
nine_state_set_defaults(&This->state, &This->caps, is_reset);
@@ -94,6 +96,8 @@ NineDevice9_RestoreNonCSOState( struct NineDevice9 *This, unsigned mask )
{
struct pipe_context *pipe = This->pipe;
DBG("This=%p mask=%u\n", This, mask);
if (mask & 0x1) {
struct pipe_constant_buffer cb;
cb.buffer_offset = 0;
@@ -139,10 +143,18 @@ NineDevice9_ctor( struct NineDevice9 *This,
D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3D9 *pD3D9,
ID3DPresentGroup *pPresentationGroup,
struct d3dadapter9_context *pCTX )
struct d3dadapter9_context *pCTX,
boolean ex,
D3DDISPLAYMODEEX *pFullscreenDisplayMode )
{
unsigned i;
HRESULT hr = NineUnknown_ctor(&This->base, pParams);
DBG("This=%p pParams=%p pScreen=%p pCreationParameters=%p pCaps=%p pPresentationParameters=%p "
"pD3D9=%p pPresentationGroup=%p pCTX=%p ex=%d pFullscreenDisplayMode=%p\n",
This, pParams, pScreen, pCreationParameters, pCaps, pPresentationParameters, pD3D9,
pPresentationGroup, pCTX, (int) ex, pFullscreenDisplayMode);
if (FAILED(hr)) { return hr; }
list_inithead(&This->update_textures);
@@ -151,6 +163,7 @@ NineDevice9_ctor( struct NineDevice9 *This,
This->caps = *pCaps;
This->d3d9 = pD3D9;
This->params = *pCreationParameters;
This->ex = ex;
This->present = pPresentationGroup;
IDirect3D9_AddRef(This->d3d9);
ID3DPresentGroup_AddRef(This->present);
@@ -177,12 +190,12 @@ NineDevice9_ctor( struct NineDevice9 *This,
if (FAILED(hr))
return hr;
if (This->ex) {
if (ex) {
D3DDISPLAYMODEEX *mode = NULL;
struct NineSwapChain9Ex **ret =
(struct NineSwapChain9Ex **)&This->swapchains[i];
if (This->pFullscreenDisplayMode) mode = &(This->pFullscreenDisplayMode[i]);
if (pFullscreenDisplayMode) mode = &(pFullscreenDisplayMode[i]);
/* when this is a Device9Ex, it should create SwapChain9Exs */
hr = NineSwapChain9Ex_new(This, TRUE, present,
&pPresentationParameters[i], pCTX,
@@ -310,9 +323,6 @@ NineDevice9_ctor( struct NineDevice9 *This,
This->update = &This->state;
nine_update_state(This, ~0);
/* Is just used to pass the parameter from NineDevice9Ex_ctor */
This->pFullscreenDisplayMode = NULL;
ID3DPresentGroup_Release(This->present);
return D3D_OK;
@@ -413,7 +423,11 @@ NineDevice9_TestCooperativeLevel( struct NineDevice9 *This )
UINT WINAPI
NineDevice9_GetAvailableTextureMem( struct NineDevice9 *This )
{
return This->screen->get_param(This->screen, PIPE_CAP_VIDEO_MEMORY);
const unsigned mem = This->screen->get_param(This->screen, PIPE_CAP_VIDEO_MEMORY);
if (mem < 4096)
return mem << 20;
else
return UINT_MAX;
}
HRESULT WINAPI
@@ -536,6 +550,8 @@ NineDevice9_SetCursorPosition( struct NineDevice9 *This,
{
struct NineSwapChain9 *swap = This->swapchains[0];
DBG("This=%p X=%d Y=%d Flags=%d\n", This, X, Y, Flags);
This->cursor.pos.x = X;
This->cursor.pos.y = Y;
@@ -548,6 +564,9 @@ NineDevice9_ShowCursor( struct NineDevice9 *This,
BOOL bShow )
{
BOOL old = This->cursor.visible;
DBG("This=%p bShow=%d\n", This, (int) bShow);
This->cursor.visible = bShow && (This->cursor.hotspot.x != -1);
if (!This->cursor.software)
ID3DPresent_SetCursor(This->swapchains[0]->present, NULL, NULL, bShow);
@@ -564,6 +583,9 @@ NineDevice9_CreateAdditionalSwapChain( struct NineDevice9 *This,
ID3DPresent *present;
HRESULT hr;
DBG("This=%p pPresentationParameters=%p pSwapChain=%p\n",
This, pPresentationParameters, pSwapChain);
user_assert(pPresentationParameters, D3DERR_INVALIDCALL);
hr = ID3DPresentGroup_CreateAdditionalPresent(This->present, pPresentationParameters, &present);
@@ -641,6 +663,9 @@ NineDevice9_Present( struct NineDevice9 *This,
unsigned i;
HRESULT hr;
DBG("This=%p pSourceRect=%p pDestRect=%p hDestWindowOverride=%p pDirtyRegion=%p\n",
This, pSourceRect, pDestRect, hDestWindowOverride, pDirtyRegion);
/* XXX is this right? */
for (i = 0; i < This->nswapchains; ++i) {
hr = NineSwapChain9_Present(This->swapchains[i], pSourceRect, pDestRect,
@@ -974,7 +999,7 @@ create_zs_or_rt_surface(struct NineDevice9 *This,
} else {
resource = NULL;
}
hr = NineSurface9_new(This, NULL, resource, 0, 0, 0, &desc, &surface);
hr = NineSurface9_new(This, NULL, resource, NULL, 0, 0, 0, &desc, &surface);
pipe_resource_reference(&resource, NULL);
if (SUCCEEDED(hr))
@@ -1710,6 +1735,9 @@ NineDevice9_SetTransform( struct NineDevice9 *This,
{
struct nine_state *state = This->update;
D3DMATRIX *M = nine_state_access_transform(state, State, TRUE);
DBG("This=%p State=%d pMatrix=%p\n", This, State, pMatrix);
user_assert(M, D3DERR_INVALIDCALL);
*M = *pMatrix;
@@ -1738,6 +1766,9 @@ NineDevice9_MultiplyTransform( struct NineDevice9 *This,
struct nine_state *state = This->update;
D3DMATRIX T;
D3DMATRIX *M = nine_state_access_transform(state, State, TRUE);
DBG("This=%p State=%d pMatrix=%p\n", This, State, pMatrix);
user_assert(M, D3DERR_INVALIDCALL);
nine_d3d_matrix_matrix_mul(&T, pMatrix, M);
@@ -2172,6 +2203,7 @@ NineDevice9_SetTexture( struct NineDevice9 *This,
IDirect3DBaseTexture9 *pTexture )
{
struct nine_state *state = This->update;
struct NineBaseTexture9 *tex = NineBaseTexture9(pTexture);
DBG("This=%p Stage=%u pTexture=%p\n", This, Stage, pTexture);
@@ -2179,12 +2211,19 @@ NineDevice9_SetTexture( struct NineDevice9 *This,
Stage == D3DDMAPSAMPLER ||
(Stage >= D3DVERTEXTEXTURESAMPLER0 &&
Stage <= D3DVERTEXTEXTURESAMPLER3), D3DERR_INVALIDCALL);
user_assert(!tex || tex->base.pool != D3DPOOL_SCRATCH, D3DERR_INVALIDCALL);
if (unlikely(tex && tex->base.pool == D3DPOOL_SYSTEMMEM)) {
/* TODO: Currently not implemented. Better return error
* with message telling what's wrong */
ERR("This=%p D3DPOOL_SYSTEMMEM not implemented for SetTexture\n", This);
user_assert(tex->base.pool != D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL);
}
if (Stage >= D3DDMAPSAMPLER)
Stage = Stage - D3DDMAPSAMPLER + NINE_MAX_SAMPLERS_PS;
if (!This->is_recording) {
struct NineBaseTexture9 *tex = NineBaseTexture9(pTexture);
struct NineBaseTexture9 *old = state->texture[Stage];
if (old == tex)
return D3D_OK;
@@ -2648,6 +2687,11 @@ NineDevice9_ProcessVertices( struct NineDevice9 *This,
HRESULT hr;
unsigned buffer_offset, buffer_size;
DBG("This=%p SrcStartIndex=%u DestIndex=%u VertexCount=%u "
"pDestBuffer=%p pVertexDecl=%p Flags=%d\n",
This, SrcStartIndex, DestIndex, VertexCount, pDestBuffer,
pVertexDecl, Flags);
if (!screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS))
STUB(D3DERR_INVALIDCALL);
@@ -2725,6 +2769,9 @@ NineDevice9_CreateVertexDeclaration( struct NineDevice9 *This,
{
struct NineVertexDeclaration9 *vdecl;
DBG("This=%p pVertexElements=%p ppDecl=%p\n",
This, pVertexElements, ppDecl);
HRESULT hr = NineVertexDeclaration9_new(This, pVertexElements, &vdecl);
if (SUCCEEDED(hr))
*ppDecl = (IDirect3DVertexDeclaration9 *)vdecl;
@@ -2801,6 +2848,8 @@ NineDevice9_CreateVertexShader( struct NineDevice9 *This,
struct NineVertexShader9 *vs;
HRESULT hr;
DBG("This=%p pFunction=%p ppShader=%p\n", This, pFunction, ppShader);
hr = NineVertexShader9_new(This, &vs, pFunction, NULL);
if (FAILED(hr))
return hr;
@@ -2981,6 +3030,9 @@ NineDevice9_SetStreamSource( struct NineDevice9 *This,
struct NineVertexBuffer9 *pVBuf9 = NineVertexBuffer9(pStreamData);
const unsigned i = StreamNumber;
DBG("This=%p StreamNumber=%u pStreamData=%p OffsetInBytes=%u Stride=%u\n",
This, StreamNumber, pStreamData, OffsetInBytes, Stride);
user_assert(StreamNumber < This->caps.MaxStreams, D3DERR_INVALIDCALL);
user_assert(Stride <= This->caps.MaxStreamStride, D3DERR_INVALIDCALL);
@@ -3068,6 +3120,8 @@ NineDevice9_SetIndices( struct NineDevice9 *This,
{
struct nine_state *state = This->update;
DBG("This=%p pIndexData=%p\n", This, pIndexData);
if (likely(!This->is_recording))
if (state->idxbuf == NineIndexBuffer9(pIndexData))
return D3D_OK;
@@ -3099,6 +3153,8 @@ NineDevice9_CreatePixelShader( struct NineDevice9 *This,
struct NinePixelShader9 *ps;
HRESULT hr;
DBG("This=%p pFunction=%p ppShader=%p\n", This, pFunction, ppShader);
hr = NinePixelShader9_new(This, &ps, pFunction, NULL);
if (FAILED(hr))
return hr;
@@ -3301,6 +3357,8 @@ NineDevice9_CreateQuery( struct NineDevice9 *This,
struct NineQuery9 *query;
HRESULT hr;
DBG("This=%p Type=%d ppQuery=%p\n", This, Type, ppQuery);
if (!ppQuery)
return nine_is_query_supported(Type);
@@ -3447,6 +3505,8 @@ NineDevice9_new( struct pipe_screen *pScreen,
IDirect3D9 *pD3D9,
ID3DPresentGroup *pPresentationGroup,
struct d3dadapter9_context *pCTX,
boolean ex,
D3DDISPLAYMODEEX *pFullscreenDisplayMode,
struct NineDevice9 **ppOut )
{
BOOL lock;
@@ -3454,5 +3514,6 @@ NineDevice9_new( struct pipe_screen *pScreen,
NINE_NEW(Device9, ppOut, lock, /* args */
pScreen, pCreationParameters, pCaps,
pPresentationParameters, pD3D9, pPresentationGroup, pCTX);
pPresentationParameters, pD3D9, pPresentationGroup, pCTX,
ex, pFullscreenDisplayMode);
}

View File

@@ -48,7 +48,6 @@ struct NineDevice9
{
struct NineUnknown base;
boolean ex;
D3DDISPLAYMODEEX *pFullscreenDisplayMode;
/* G3D context */
struct pipe_screen *screen;
@@ -134,6 +133,8 @@ NineDevice9_new( struct pipe_screen *pScreen,
IDirect3D9 *pD3D9,
ID3DPresentGroup *pPresentationGroup,
struct d3dadapter9_context *pCTX,
boolean ex,
D3DDISPLAYMODEEX *pFullscreenDisplayMode,
struct NineDevice9 **ppOut );
HRESULT
@@ -145,7 +146,9 @@ NineDevice9_ctor( struct NineDevice9 *This,
D3DPRESENT_PARAMETERS *pPresentationParameters,
IDirect3D9 *pD3D9,
ID3DPresentGroup *pPresentationGroup,
struct d3dadapter9_context *pCTX );
struct d3dadapter9_context *pCTX,
boolean ex,
D3DDISPLAYMODEEX *pFullscreenDisplayMode );
void
NineDevice9_dtor( struct NineDevice9 *This );

View File

@@ -39,13 +39,18 @@ NineDevice9Ex_ctor( struct NineDevice9Ex *This,
ID3DPresentGroup *pPresentationGroup,
struct d3dadapter9_context *pCTX )
{
This->base.ex = TRUE;
This->base.pFullscreenDisplayMode = pFullscreenDisplayMode;
DBG("This=%p pParams=%p pScreen=%p pCreationParameters=%p pCaps=%p "
"pPresentationParameters=%p pFullscreenDisplayMode=%p "
"pD3D9Ex=%p pPresentationGroup=%p pCTX=%p\n",
This, pParams, pScreen, pCreationParameters, pCaps,
pPresentationParameters, pFullscreenDisplayMode,
pD3D9Ex, pPresentationGroup, pCTX);
return NineDevice9_ctor(&This->base, pParams,
pScreen, pCreationParameters, pCaps,
pPresentationParameters,
(IDirect3D9 *)pD3D9Ex, pPresentationGroup, pCTX);
(IDirect3D9 *)pD3D9Ex, pPresentationGroup, pCTX,
TRUE, pFullscreenDisplayMode);
}
static void
@@ -89,6 +94,11 @@ NineDevice9Ex_PresentEx( struct NineDevice9Ex *This,
unsigned i;
HRESULT hr;
DBG("This=%p pSourceRect=%p pDestRect=%p hDestWindowOverride=%p "
"pDirtyRegion=%p dwFlags=%d\n",
This, pSourceRect, pDestRect, hDestWindowOverride,
pDirtyRegion, dwFlags);
for (i = 0; i < This->base.nswapchains; i++) {
hr = NineSwapChain9_Present(This->base.swapchains[i], pSourceRect, pDestRect,
hDestWindowOverride, pDirtyRegion, dwFlags);
@@ -229,6 +239,9 @@ NineDevice9Ex_GetDisplayModeEx( struct NineDevice9Ex *This,
{
struct NineSwapChain9Ex *swapchain;
DBG("This=%p iSwapChain=%u pMode=%p pRotation=%p\n",
This, iSwapChain, pMode, pRotation);
user_assert(iSwapChain < This->base.nswapchains, D3DERR_INVALIDCALL);
swapchain = NineSwapChain9Ex(This->base.swapchains[iSwapChain]);

View File

@@ -76,8 +76,8 @@ NineIndexBuffer9_ctor( struct NineIndexBuffer9 *This,
info->last_level = 0;
info->nr_samples = 0;
hr = NineResource9_ctor(&This->base, pParams, TRUE, D3DRTYPE_INDEXBUFFER,
pDesc->Pool);
hr = NineResource9_ctor(&This->base, pParams, NULL, TRUE, D3DRTYPE_INDEXBUFFER,
pDesc->Pool, pDesc->Usage);
if (FAILED(hr))
return hr;

View File

@@ -58,6 +58,8 @@ NineUnknown_QueryInterface( struct NineUnknown *This,
{
unsigned i = 0;
DBG("This=%p riid=%p ppvObject=%p\n", This, riid, ppvObject);
if (!ppvObject) return E_POINTER;
do {

View File

@@ -30,25 +30,27 @@
#define NINE_RESOURCE_FLAG_DUMMY (PIPE_RESOURCE_FLAG_ST_PRIV << 2)
/* vertexdeclaration9.c */
unsigned nine_d3d9_to_nine_declusage(unsigned usage, unsigned index);
uint16_t nine_d3d9_to_nine_declusage(unsigned usage, unsigned index);
#define NINE_DECLUSAGE_POSITION(i) ( 0 + (i))
#define NINE_DECLUSAGE_BLENDWEIGHT(i) ( 5 + (i))
#define NINE_DECLUSAGE_BLENDINDICES(i) ( 9 + (i))
#define NINE_DECLUSAGE_NORMAL(i) (13 + (i))
#define NINE_DECLUSAGE_PSIZE 15
#define NINE_DECLUSAGE_TEXCOORD(i) (16 + (i))
#define NINE_DECLUSAGE_TANGENT(i) (32 + (i))
#define NINE_DECLUSAGE_BINORMAL(i) (34 + (i))
#define NINE_DECLUSAGE_TESSFACTOR 36
#define NINE_DECLUSAGE_POSITIONT 37
#define NINE_DECLUSAGE_COLOR(i) (38 + (i))
#define NINE_DECLUSAGE_DEPTH 43
#define NINE_DECLUSAGE_FOG 44
#define NINE_DECLUSAGE_SAMPLE 45
#define NINE_DECLUSAGE_NONE 46
#define NINE_DECLUSAGE_LAST NINE_DECLUSAGE_NONE
#define NINE_DECLUSAGE_COUNT (NINE_DECLUSAGE_LAST + 1)
#define NINE_DECLUSAGE_POSITION 0
#define NINE_DECLUSAGE_BLENDWEIGHT 1
#define NINE_DECLUSAGE_BLENDINDICES 2
#define NINE_DECLUSAGE_NORMAL 3
#define NINE_DECLUSAGE_TEXCOORD 4
#define NINE_DECLUSAGE_TANGENT 5
#define NINE_DECLUSAGE_BINORMAL 6
#define NINE_DECLUSAGE_COLOR 7
#define NINE_DECLUSAGE_POSITIONT 8
#define NINE_DECLUSAGE_PSIZE 9
#define NINE_DECLUSAGE_TESSFACTOR 10
#define NINE_DECLUSAGE_DEPTH 11
#define NINE_DECLUSAGE_FOG 12
#define NINE_DECLUSAGE_SAMPLE 13
#define NINE_DECLUSAGE_NONE 14
#define NINE_DECLUSAGE_COUNT (NINE_DECLUSAGE_NONE + 1)
#define NINE_DECLUSAGE_i(declusage, n) NINE_DECLUSAGE_##declusage + n * NINE_DECLUSAGE_COUNT
#define NINED3DCLEAR_DEPTHSTENCIL (D3DCLEAR_ZBUFFER | D3DCLEAR_STENCIL)

View File

@@ -189,13 +189,10 @@ static void nine_ureg_tgsi_dump(struct ureg_program *ureg, boolean override)
/* AL should contain base address of lights table. */
#define LIGHT_CONST(i) \
ureg_src_indirect(ureg_src_register(TGSI_FILE_CONSTANT, (i)), _X(AL))
ureg_src_indirect(ureg_DECL_constant(ureg, i), _X(AL))
#define MATERIAL_CONST(i) \
ureg_src_register(TGSI_FILE_CONSTANT, 19 + (i))
#define MISC_CONST(i) \
ureg_src_register(TGSI_FILE_CONSTANT, (i))
ureg_DECL_constant(ureg, 19 + (i))
#define _CONST(n) ureg_DECL_constant(ureg, n)
@@ -278,7 +275,7 @@ struct vs_build_ctx
struct ureg_program *ureg;
const struct nine_ff_vs_key *key;
unsigned input[PIPE_MAX_ATTRIBS];
uint16_t input[PIPE_MAX_ATTRIBS];
unsigned num_inputs;
struct ureg_src aVtx;
@@ -307,7 +304,7 @@ get_texcoord_sn(struct pipe_screen *screen)
}
static INLINE struct ureg_src
build_vs_add_input(struct vs_build_ctx *vs, unsigned ndecl)
build_vs_add_input(struct vs_build_ctx *vs, uint16_t ndecl)
{
const unsigned i = vs->num_inputs++;
assert(i < PIPE_MAX_ATTRIBS);
@@ -373,10 +370,10 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
* (texture coordinates handled later)
*/
vs->aVtx = build_vs_add_input(vs,
key->position_t ? NINE_DECLUSAGE_POSITIONT : NINE_DECLUSAGE_POSITION(0));
key->position_t ? NINE_DECLUSAGE_POSITIONT : NINE_DECLUSAGE_POSITION);
if (need_rNrm)
vs->aNrm = build_vs_add_input(vs, NINE_DECLUSAGE_NORMAL(0));
vs->aNrm = build_vs_add_input(vs, NINE_DECLUSAGE_NORMAL);
vs->aCol[0] = ureg_imm1f(ureg, 1.0f);
vs->aCol[1] = ureg_imm1f(ureg, 1.0f);
@@ -385,9 +382,9 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
const unsigned mask = key->mtl_diffuse | key->mtl_specular |
key->mtl_ambient | key->mtl_emissive;
if ((mask & 0x1) && !key->color0in_one)
vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(0));
vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 0));
if ((mask & 0x2) && !key->color1in_one)
vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(1));
vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 1));
vs->mtlD = MATERIAL_CONST(1);
vs->mtlA = MATERIAL_CONST(2);
@@ -402,20 +399,20 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
if (key->mtl_emissive == 1) vs->mtlE = vs->aCol[0]; else
if (key->mtl_emissive == 2) vs->mtlE = vs->aCol[1];
} else {
if (!key->color0in_one) vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(0));
if (!key->color1in_one) vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_COLOR(1));
if (!key->color0in_one) vs->aCol[0] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 0));
if (!key->color1in_one) vs->aCol[1] = build_vs_add_input(vs, NINE_DECLUSAGE_i(COLOR, 1));
}
if (key->vertexpointsize)
vs->aPsz = build_vs_add_input(vs, NINE_DECLUSAGE_PSIZE);
if (key->vertexblend_indexed)
vs->aInd = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDINDICES(0));
vs->aInd = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDINDICES);
if (key->vertexblend)
vs->aWgt = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDWEIGHT(0));
vs->aWgt = build_vs_add_input(vs, NINE_DECLUSAGE_BLENDWEIGHT);
if (key->vertextween) {
vs->aVtx1 = build_vs_add_input(vs, NINE_DECLUSAGE_POSITION(1));
vs->aNrm1 = build_vs_add_input(vs, NINE_DECLUSAGE_NORMAL(1));
vs->aVtx1 = build_vs_add_input(vs, NINE_DECLUSAGE_i(POSITION,1));
vs->aNrm1 = build_vs_add_input(vs, NINE_DECLUSAGE_i(NORMAL,1));
}
/* Declare outputs:
@@ -599,7 +596,7 @@ nine_ff_build_vs(struct NineDevice9 *device, struct vs_build_ctx *vs)
oTex[i] = ureg_DECL_output(ureg, texcoord_sn, i);
if (tci == NINED3DTSS_TCI_PASSTHRU)
vs->aTex[idx] = build_vs_add_input(vs, NINE_DECLUSAGE_TEXCOORD(idx));
vs->aTex[idx] = build_vs_add_input(vs, NINE_DECLUSAGE_i(TEXCOORD,idx));
if (!dim) {
dst[c = 4] = oTex[i];
@@ -1377,7 +1374,7 @@ nine_ff_get_vs(struct NineDevice9 *device)
enum pipe_error err;
struct vs_build_ctx bld;
struct nine_ff_vs_key key;
unsigned s;
unsigned s, i;
assert(sizeof(key) <= sizeof(key.value32));
@@ -1388,14 +1385,19 @@ nine_ff_get_vs(struct NineDevice9 *device)
/* FIXME: this shouldn't be NULL, but it is on init */
if (state->vdecl) {
if (state->vdecl->usage_map[NINE_DECLUSAGE_POSITIONT] != 0xff)
key.position_t = 1;
if (state->vdecl->usage_map[NINE_DECLUSAGE_COLOR(0)] == 0xff)
key.color0in_one = 1;
if (state->vdecl->usage_map[NINE_DECLUSAGE_COLOR(1)] == 0xff)
key.color1in_one = 1;
if (state->vdecl->usage_map[NINE_DECLUSAGE_PSIZE] != 0xff)
key.vertexpointsize = 1;
key.color0in_one = 1;
key.color1in_one = 1;
for (i = 0; i < state->vdecl->nelems; i++) {
uint16_t usage = state->vdecl->usage_map[i];
if (usage == NINE_DECLUSAGE_POSITIONT)
key.position_t = 1;
else if (usage == NINE_DECLUSAGE_i(COLOR, 0))
key.color0in_one = 0;
else if (usage == NINE_DECLUSAGE_i(COLOR, 1))
key.color1in_one = 0;
else if (usage == NINE_DECLUSAGE_PSIZE)
key.vertexpointsize = 1;
}
}
if (!key.vertexpointsize)
key.pointscale = !!state->rs[D3DRS_POINTSCALEENABLE];

View File

@@ -239,7 +239,7 @@ struct sm1_dst_param
BYTE file;
BYTE mask;
BYTE mod;
BYTE shift; /* sint4 */
int8_t shift; /* sint4 */
BYTE type;
};
@@ -1685,101 +1685,93 @@ sm1_declusage_to_tgsi(struct tgsi_declaration_semantic *sem,
boolean tc,
struct sm1_semantic *dcl)
{
const unsigned generic_base = tc ? 0 : 8; /* TEXCOORD[0..7] */
BYTE index = dcl->usage_idx;
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 0;
/* TGSI_SEMANTIC_GENERIC assignments (+8 if !PIPE_CAP_TGSI_TEXCOORD):
* Try to put frequently used semantics at low GENERIC indices.
/* For everything that is not matching to a TGSI_SEMANTIC_****,
* we match to a TGSI_SEMANTIC_GENERIC with index.
*
* POSITION[1..4]: 17, 27, 28, 29
* COLOR[2..4]: 14, 15, 26
* TEXCOORD[8..15]: 10, 11, 18, 19, 20, 21, 22, 23
* BLENDWEIGHT[0..3]: 0, 4, 8, 12
* BLENDINDICES[0..3]: 1, 5, 9, 13
* NORMAL[0..1]: 2, 6
* TANGENT[0]: 3, 24
* BINORMAL[0]: 7, 25
* TESSFACTOR[0]: 16
* The index can be anything UINT16 and usage_idx is BYTE,
* so we can fit everything. It doesn't matter if indices
* are close together or low.
*
*
* POSITION >= 1: 10 * index + 6
* COLOR >= 2: 10 * (index-1) + 7
* TEXCOORD[0..15]: index
* BLENDWEIGHT: 10 * index + 18
* BLENDINDICES: 10 * index + 19
* NORMAL: 10 * index + 20
* TANGENT: 10 * index + 21
* BINORMAL: 10 * index + 22
* TESSFACTOR: 10 * index + 23
*/
switch (dcl->usage) {
case D3DDECLUSAGE_POSITION:
case D3DDECLUSAGE_POSITIONT:
case D3DDECLUSAGE_DEPTH:
sem->Name = TGSI_SEMANTIC_POSITION;
assert(dcl->usage_idx <= 4);
if (dcl->usage_idx == 1) {
if (index == 0) {
sem->Name = TGSI_SEMANTIC_POSITION;
sem->Index = 0;
} else {
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = generic_base + 17;
} else
if (dcl->usage_idx >= 2) {
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = generic_base + 27 + (dcl->usage_idx - 2);
sem->Index = 10 * index + 6;
}
break;
case D3DDECLUSAGE_COLOR:
assert(dcl->usage_idx <= 4);
if (dcl->usage_idx < 2) {
if (index < 2) {
sem->Name = TGSI_SEMANTIC_COLOR;
sem->Index = dcl->usage_idx;
} else
if (dcl->usage_idx < 4) {
sem->Index = generic_base + 14 + (dcl->usage_idx - 2);
sem->Index = index;
} else {
sem->Index = generic_base + 26;
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 10 * (index-1) + 7;
}
break;
case D3DDECLUSAGE_FOG:
assert(index == 0);
sem->Name = TGSI_SEMANTIC_FOG;
assert(dcl->usage_idx == 0);
sem->Index = 0;
break;
case D3DDECLUSAGE_PSIZE:
assert(index == 0);
sem->Name = TGSI_SEMANTIC_PSIZE;
assert(dcl->usage_idx == 0);
sem->Index = 0;
break;
case D3DDECLUSAGE_TEXCOORD:
assert(dcl->usage_idx < 16);
if (dcl->usage_idx < 8) {
if (tc)
sem->Name = TGSI_SEMANTIC_TEXCOORD;
sem->Index = dcl->usage_idx;
} else
if (dcl->usage_idx < 10) {
sem->Index = generic_base + 10 + (dcl->usage_idx - 8);
} else {
sem->Index = generic_base + 18 + (dcl->usage_idx - 10);
}
assert(index < 16);
if (index < 8 && tc)
sem->Name = TGSI_SEMANTIC_TEXCOORD;
else
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = index;
break;
case D3DDECLUSAGE_BLENDWEIGHT: /* 0, 4, 8, 12 */
assert(dcl->usage_idx < 4);
sem->Index = generic_base + dcl->usage_idx * 4;
case D3DDECLUSAGE_BLENDWEIGHT:
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 10 * index + 18;
break;
case D3DDECLUSAGE_BLENDINDICES: /* 1, 5, 9, 13 */
assert(dcl->usage_idx < 4);
sem->Index = generic_base + dcl->usage_idx * 4 + 1;
case D3DDECLUSAGE_BLENDINDICES:
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 10 * index + 19;
break;
case D3DDECLUSAGE_NORMAL: /* 2, 3 */
assert(dcl->usage_idx < 2);
sem->Index = generic_base + 2 + dcl->usage_idx * 4;
case D3DDECLUSAGE_NORMAL:
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 10 * index + 20;
break;
case D3DDECLUSAGE_TANGENT:
/* Yes these are weird, but we try to fit the more frequently used
* into lower slots. */
assert(dcl->usage_idx <= 1);
sem->Index = generic_base + (dcl->usage_idx ? 24 : 3);
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 10 * index + 21;
break;
case D3DDECLUSAGE_BINORMAL:
assert(dcl->usage_idx <= 1);
sem->Index = generic_base + (dcl->usage_idx ? 25 : 7);
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 10 * index + 22;
break;
case D3DDECLUSAGE_TESSFACTOR:
assert(dcl->usage_idx == 0);
sem->Index = generic_base + 16;
sem->Name = TGSI_SEMANTIC_GENERIC;
sem->Index = 10 * index + 23;
break;
case D3DDECLUSAGE_SAMPLE:
sem->Name = TGSI_SEMANTIC_COUNT;
sem->Index = 0;
break;
default:
assert(!"Invalid DECLUSAGE.");
@@ -2535,6 +2527,7 @@ sm1_parse_get_param(struct shader_translator *tx, DWORD *reg, DWORD *rel)
static void
sm1_parse_dst_param(struct sm1_dst_param *dst, DWORD tok)
{
uint8_t shift;
dst->file =
(tok & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT |
(tok & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2;
@@ -2543,7 +2536,8 @@ sm1_parse_dst_param(struct sm1_dst_param *dst, DWORD tok)
dst->rel = NULL;
dst->mask = (tok & NINED3DSP_WRITEMASK_MASK) >> NINED3DSP_WRITEMASK_SHIFT;
dst->mod = (tok & D3DSP_DSTMOD_MASK) >> D3DSP_DSTMOD_SHIFT;
dst->shift = (tok & D3DSP_DSTSHIFT_MASK) >> D3DSP_DSTSHIFT_SHIFT;
shift = (tok & D3DSP_DSTSHIFT_MASK) >> D3DSP_DSTSHIFT_SHIFT;
dst->shift = (shift & 0x8) ? -(shift & 0x7) : shift & 0x7;
}
static void

View File

@@ -48,7 +48,7 @@ struct nine_shader_info
void *cso; /* out, pipe cso for bind_vs,fs_state */
uint8_t input_map[PIPE_MAX_ATTRIBS]; /* VS input -> NINE_DECLUSAGE_x */
uint16_t input_map[PIPE_MAX_ATTRIBS]; /* VS input -> NINE_DECLUSAGE_x */
uint8_t num_inputs; /* there may be unused inputs (NINE_DECLUSAGE_NONE) */
boolean position_t; /* out, true if VP writes pre-transformed position */

View File

@@ -141,11 +141,9 @@ update_viewport(struct NineDevice9 *device)
pvport.scale[0] = (float)vport->Width * 0.5f;
pvport.scale[1] = (float)vport->Height * -0.5f;
pvport.scale[2] = vport->MaxZ - vport->MinZ;
pvport.scale[3] = 1.0f;
pvport.translate[0] = (float)vport->Width * 0.5f + (float)vport->X;
pvport.translate[1] = (float)vport->Height * 0.5f + (float)vport->Y;
pvport.translate[2] = vport->MinZ;
pvport.translate[3] = 0.0f;
pipe->set_viewport_states(pipe, 0, 1, &pvport);
}
@@ -186,7 +184,8 @@ update_vertex_elements(struct NineDevice9 *device)
struct nine_state *state = &device->state;
const struct NineVertexDeclaration9 *vdecl = device->state.vdecl;
const struct NineVertexShader9 *vs;
unsigned n, l, b;
unsigned n, b, i;
int index;
struct pipe_vertex_element ve[PIPE_MAX_ATTRIBS];
state->stream_usage_mask = 0;
@@ -199,11 +198,16 @@ update_vertex_elements(struct NineDevice9 *device)
DBG("looking up input %u (usage %u) from vdecl(%p)\n",
n, vs->input_map[n].ndecl, vdecl);
assert(vs->input_map[n].ndecl < Elements(vdecl->usage_map));
l = vdecl->usage_map[vs->input_map[n].ndecl];
index = -1;
for (i = 0; i < vdecl->nelems; i++) {
if (vdecl->usage_map[i] == vs->input_map[n].ndecl) {
index = i;
break;
}
}
if (likely(l < vdecl->nelems)) {
ve[n] = vdecl->elems[l];
if (index >= 0) {
ve[n] = vdecl->elems[index];
b = ve[n].vertex_buffer_index;
state->stream_usage_mask |= 1 << b;
/* XXX wine just uses 1 here: */
@@ -400,7 +404,7 @@ update_constants(struct NineDevice9 *device, unsigned shader_type)
const_i = &device->state.ps_const_i[0][0];
dirty_b = device->state.changed.ps_const_b;
device->state.changed.vs_const_b = 0;
device->state.changed.ps_const_b = 0;
const_b = device->state.ps_const_b;
b_true = device->ps_bool_true;

View File

@@ -39,6 +39,8 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
struct nine_shader_info info;
HRESULT hr;
DBG("This=%p pParams=%p pFunction=%p cso=%p\n", This, pParams, pFunction, cso);
hr = NineUnknown_ctor(&This->base, pParams);
if (FAILED(hr))
return hr;
@@ -110,6 +112,8 @@ NinePixelShader9_GetFunction( struct NinePixelShader9 *This,
void *pData,
UINT *pSizeOfData )
{
DBG("This=%p pData=%p pSizeOfData=%p\n", This, pData, pSizeOfData);
user_assert(pSizeOfData, D3DERR_INVALIDCALL);
if (!pData) {

View File

@@ -107,6 +107,8 @@ NineQuery9_ctor( struct NineQuery9 *This,
const unsigned ptype = d3dquerytype_to_pipe_query(Type);
HRESULT hr;
DBG("This=%p pParams=%p Type=%d\n", This, pParams, Type);
hr = NineUnknown_ctor(&This->base, pParams);
if (FAILED(hr))
return hr;
@@ -170,6 +172,8 @@ NineQuery9_Issue( struct NineQuery9 *This,
{
struct pipe_context *pipe = This->base.device->pipe;
DBG("This=%p dwIssueFlags=%d\n", This, dwIssueFlags);
user_assert((dwIssueFlags == D3DISSUE_BEGIN && !This->instant) ||
(dwIssueFlags == 0) ||
(dwIssueFlags == D3DISSUE_END), D3DERR_INVALIDCALL);
@@ -186,10 +190,12 @@ NineQuery9_Issue( struct NineQuery9 *This,
pipe->begin_query(pipe, This->pq);
This->state = NINE_QUERY_STATE_RUNNING;
} else {
if (This->state == NINE_QUERY_STATE_RUNNING) {
pipe->end_query(pipe, This->pq);
This->state = NINE_QUERY_STATE_ENDED;
}
if (This->state != NINE_QUERY_STATE_RUNNING &&
This->type != D3DQUERYTYPE_EVENT &&
This->type != D3DQUERYTYPE_TIMESTAMP)
pipe->begin_query(pipe, This->pq);
pipe->end_query(pipe, This->pq);
This->state = NINE_QUERY_STATE_ENDED;
}
return D3D_OK;
}
@@ -221,6 +227,9 @@ NineQuery9_GetData( struct NineQuery9 *This,
union pipe_query_result presult;
union nine_query_result nresult;
DBG("This=%p pData=%p dwSize=%d dwGetDataFlags=%d\n",
This, pData, dwSize, dwGetDataFlags);
user_assert(This->state != NINE_QUERY_STATE_RUNNING, D3DERR_INVALIDCALL);
user_assert(dwSize == 0 || pData, D3DERR_INVALIDCALL);
user_assert(dwGetDataFlags == 0 ||

View File

@@ -38,29 +38,42 @@
HRESULT
NineResource9_ctor( struct NineResource9 *This,
struct NineUnknownParams *pParams,
struct pipe_resource *initResource,
BOOL Allocate,
D3DRESOURCETYPE Type,
D3DPOOL Pool )
D3DPOOL Pool,
DWORD Usage)
{
struct pipe_screen *screen;
HRESULT hr;
DBG("This=%p pParams=%p initResource=%p Allocate=%d "
"Type=%d Pool=%d Usage=%d\n",
This, pParams, initResource, (int) Allocate,
Type, Pool, Usage);
DBG("This=%p pParams=%p initResource=%p Allocate=%d Type=%d Pool=%d usage=%d\n",
This, pParams, initResource, Allocate, Type, Pool, Usage);
hr = NineUnknown_ctor(&This->base, pParams);
if (FAILED(hr))
return hr;
This->info.screen = screen = This->base.device->screen;
if (initResource)
pipe_resource_reference(&This->resource, initResource);
if (Allocate) {
assert(!initResource);
DBG("(%p) Creating pipe_resource.\n", This);
This->resource = screen->resource_create(screen, &This->info);
if (!This->resource)
return D3DERR_OUTOFVIDEOMEMORY;
}
This->data = NULL; /* FIXME remove, rather set it to null in surface9.c*/
This->type = Type;
This->pool = Pool;
This->usage = Usage;
This->priority = 0;
This->pdata = util_hash_table_create(ht_guid_hash, ht_guid_compare);
@@ -82,10 +95,6 @@ NineResource9_dtor( struct NineResource9 *This )
* still hold a reference. */
pipe_resource_reference(&This->resource, NULL);
/* release allocated system memory for non-D3DPOOL_DEFAULT resources */
if (This->data)
FREE(This->data);
NineUnknown_dtor(&This->base);
}
@@ -201,6 +210,9 @@ NineResource9_SetPriority( struct NineResource9 *This,
DWORD PriorityNew )
{
DWORD prev = This->priority;
DBG("This=%p, PriorityNew=%d\n", This, PriorityNew);
This->priority = PriorityNew;
return prev;
}

View File

@@ -36,8 +36,6 @@ struct NineResource9
struct pipe_resource *resource; /* device resource */
uint8_t *data; /* system memory backing */
D3DRESOURCETYPE type;
D3DPOOL pool;
DWORD priority;
@@ -57,9 +55,11 @@ NineResource9( void *data )
HRESULT
NineResource9_ctor( struct NineResource9 *This,
struct NineUnknownParams *pParams,
struct pipe_resource *initResource,
BOOL Allocate,
D3DRESOURCETYPE Type,
D3DPOOL Pool );
D3DPOOL Pool,
DWORD Usage);
void
NineResource9_dtor( struct NineResource9 *This );

View File

@@ -35,6 +35,9 @@ NineStateBlock9_ctor( struct NineStateBlock9 *This,
enum nine_stateblock_type type )
{
HRESULT hr = NineUnknown_ctor(&This->base, pParams);
DBG("This=%p pParams=%p type=%d\n", This, pParams, type);
if (FAILED(hr))
return hr;

View File

@@ -43,6 +43,7 @@ NineSurface9_ctor( struct NineSurface9 *This,
struct NineUnknownParams *pParams,
struct NineUnknown *pContainer,
struct pipe_resource *pResource,
void *user_buffer,
uint8_t TextureType,
unsigned Level,
unsigned Layer,
@@ -62,6 +63,8 @@ NineSurface9_ctor( struct NineSurface9 *This,
assert(pResource ||
pDesc->Pool != D3DPOOL_DEFAULT || pDesc->Format == D3DFMT_NULL);
assert(!pResource || !user_buffer);
This->base.info.screen = pParams->device->screen;
This->base.info.target = PIPE_TEXTURE_2D;
This->base.info.format = d3d9_to_pipe_format(pDesc->Format);
@@ -82,20 +85,17 @@ NineSurface9_ctor( struct NineSurface9 *This,
if (pDesc->Pool == D3DPOOL_SYSTEMMEM) {
This->base.info.usage = PIPE_USAGE_STAGING;
if (pResource)
This->base.data = (uint8_t *)pResource; /* this is *pSharedHandle */
pResource = NULL;
This->data = (uint8_t *)user_buffer; /* this is *pSharedHandle */
assert(!pResource);
} else {
if (pResource && (pDesc->Usage & D3DUSAGE_DYNAMIC))
pResource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
pipe_resource_reference(&This->base.resource, pResource);
}
hr = NineResource9_ctor(&This->base, pParams, FALSE, D3DRTYPE_SURFACE,
pDesc->Pool);
hr = NineResource9_ctor(&This->base, pParams, pResource, FALSE, D3DRTYPE_SURFACE,
pDesc->Pool, pDesc->Usage);
if (FAILED(hr))
return hr;
This->base.usage = pDesc->Usage;
This->pipe = This->base.base.device->pipe;
This->transfer = NULL;
@@ -109,13 +109,20 @@ NineSurface9_ctor( struct NineSurface9 *This,
This->stride = util_format_get_stride(This->base.info.format, pDesc->Width);
This->stride = align(This->stride, 4);
if (!pResource && !This->base.data) {
hr = NineSurface9_AllocateData(This);
if (FAILED(hr))
return hr;
if (!pResource && !This->data) {
const unsigned size = This->stride *
util_format_get_nblocksy(This->base.info.format, This->desc.Height);
DBG("(%p(This=%p),level=%u) Allocating 0x%x bytes of system memory.\n",
This->base.base.container, This, This->level, size);
This->data = (uint8_t *)MALLOC(size);
if (!This->data)
return E_OUTOFMEMORY;
This->manage_data = TRUE;
} else {
if (pResource && NineSurface9_IsOffscreenPlain(This))
pResource->flags |= NINE_RESOURCE_FLAG_LOCKABLE;
pResource->flags |= NINE_RESOURCE_FLAG_LOCKABLE; /* why setting this flag there ? too late ? should be before NineResource9_ctor call perhaps ? */
}
NineSurface9_Dump(This);
@@ -133,6 +140,9 @@ NineSurface9_dtor( struct NineSurface9 *This )
pipe_surface_reference(&This->surface[0], NULL);
pipe_surface_reference(&This->surface[1], NULL);
/* release allocated system memory for non-D3DPOOL_DEFAULT resources */
if (This->manage_data && This->data)
FREE(This->data);
NineResource9_dtor(&This->base);
}
@@ -167,7 +177,7 @@ NineSurface9_Dump( struct NineSurface9 *This )
DBG("\nNineSurface9(%p->%p/%p): Pool=%s Type=%s Usage=%s\n"
"Dims=%ux%u Format=%s Stride=%u Lockable=%i\n"
"Level=%u(%u), Layer=%u\n", This, This->base.resource, This->base.data,
"Level=%u(%u), Layer=%u\n", This, This->base.resource, This->data,
nine_D3DPOOL_to_str(This->desc.Pool),
nine_D3DRTYPE_to_str(This->desc.Type),
nine_D3DUSAGE_to_str(This->desc.Usage),
@@ -240,6 +250,8 @@ NineSurface9_AddDirtyRect( struct NineSurface9 *This,
float area[2];
struct u_rect rect, cover_a, cover_b;
DBG("This=%p box=%p\n", This, box);
if (!box) {
This->dirty_rects[0].x0 = 0;
This->dirty_rects[0].y0 = 0;
@@ -286,8 +298,8 @@ NineSurface9_GetSystemMemPointer(struct NineSurface9 *This, int x, int y)
y = util_format_get_nblocksy(This->base.info.format, y);
assert(This->base.data);
return This->base.data + (y * This->stride + x_offset);
assert(This->data);
return This->data + (y * This->stride + x_offset);
}
HRESULT WINAPI
@@ -360,7 +372,7 @@ NineSurface9_LockRect( struct NineSurface9 *This,
user_warn(This->desc.Format == D3DFMT_NULL);
if (This->base.data) {
if (This->data) {
DBG("returning system memory\n");
pLockedRect->Pitch = This->stride;
@@ -419,73 +431,6 @@ NineSurface9_ReleaseDC( struct NineSurface9 *This,
STUB(D3DERR_INVALIDCALL);
}
/* nine private */
HRESULT
NineSurface9_AllocateData( struct NineSurface9 *This )
{
#if 0
struct pipe_screen *screen = This->base.info.screen;
/* XXX: Can't use staging resource because apparently apps expect
* memory offsets to be the same across locks.
* NV50 doesn't support direct mapping yet so only enable this if
* everything else works.
*/
if (This->base.pool == D3DPOOL_SYSTEMMEM) {
/* Allocate a staging resource to save a copy:
* user -> staging resource
* staging resource -> (blit) -> video memory
*
* Instead of:
* user -> system memory
* system memory -> transfer staging area
* transfer -> video memory
*
* Does this work if we "lose" the device ?
*/
struct pipe_resource *resource;
struct pipe_resource templ;
templ.target = PIPE_TEXTURE_2D;
templ.format = This->base.info.format;
templ.width0 = This->desc.Width;
templ.height0 = This->desc.Height;
templ.depth0 = 1;
templ.array_size = 1;
templ.last_level = 0;
templ.nr_samples = 0;
templ.usage = PIPE_USAGE_STAGING;
templ.bind =
PIPE_BIND_SAMPLER_VIEW |
PIPE_BIND_TRANSFER_WRITE |
PIPE_BIND_TRANSFER_READ;
templ.flags = 0;
DBG("(%p(This=%p),level=%u) Allocating staging resource.\n",
This->base.base.container, This, This->level);
resource = screen->resource_create(screen, &templ);
if (!resource)
DBG("Failed to allocate staging resource.\n");
/* Also deallocate old staging resource. */
pipe_resource_reference(&This->base.resource, resource);
}
#endif
if (!This->base.resource) {
const unsigned size = This->stride *
util_format_get_nblocksy(This->base.info.format, This->desc.Height);
DBG("(%p(This=%p),level=%u) Allocating 0x%x bytes of system memory.\n",
This->base.base.container, This, This->level, size);
This->base.data = (uint8_t *)MALLOC(size);
if (!This->base.data)
return E_OUTOFMEMORY;
}
return D3D_OK;
}
IDirect3DSurface9Vtbl NineSurface9_vtable = {
(void *)NineUnknown_QueryInterface,
(void *)NineUnknown_AddRef,
@@ -528,6 +473,9 @@ NineSurface9_CopySurface( struct NineSurface9 *This,
uint8_t *p_dst;
const uint8_t *p_src;
DBG("This=%p From=%p pDestPoint=%p pSourceRect=%p\n",
This, From, pDestPoint, pSourceRect);
user_assert(This->desc.Format == From->desc.Format, D3DERR_INVALIDCALL);
dst_box.x = pDestPoint ? pDestPoint->x : 0;
@@ -643,6 +591,8 @@ NineSurface9_UploadSelf( struct NineSurface9 *This )
uint8_t *ptr;
unsigned i;
DBG("This=%p\n", This);
assert(This->base.pool == D3DPOOL_MANAGED);
if (!NineSurface9_IsDirty(This))
@@ -699,6 +649,7 @@ HRESULT
NineSurface9_new( struct NineDevice9 *pDevice,
struct NineUnknown *pContainer,
struct pipe_resource *pResource,
void *user_buffer,
uint8_t TextureType,
unsigned Level,
unsigned Layer,
@@ -706,6 +657,6 @@ NineSurface9_new( struct NineDevice9 *pDevice,
struct NineSurface9 **ppOut )
{
NINE_DEVICE_CHILD_NEW(Surface9, ppOut, pDevice, /* args */
pContainer, pResource,
pContainer, pResource, user_buffer,
TextureType, Level, Layer, pDesc);
}

View File

@@ -47,6 +47,8 @@ struct NineSurface9
unsigned layer;
D3DSURFACE_DESC desc;
uint8_t *data; /* system memory backing */
boolean manage_data;
unsigned stride; /* for system memory backing */
/* wine doesn't even use these, 2 will be enough */
@@ -62,6 +64,7 @@ HRESULT
NineSurface9_new( struct NineDevice9 *pDevice,
struct NineUnknown *pContainer,
struct pipe_resource *pResource,
void *user_buffer,
uint8_t TextureType, /* 0 if pContainer isn't BaseTexure9 */
unsigned Level,
unsigned Layer,
@@ -73,6 +76,7 @@ NineSurface9_ctor( struct NineSurface9 *This,
struct NineUnknownParams *pParams,
struct NineUnknown *pContainer,
struct pipe_resource *pResource,
void *user_buffer,
uint8_t TextureType,
unsigned Level,
unsigned Layer,
@@ -124,9 +128,6 @@ NineSurface9_ClearDirtyRects( struct NineSurface9 *This )
memset(&This->dirty_rects, 0, sizeof(This->dirty_rects));
}
HRESULT
NineSurface9_AllocateData( struct NineSurface9 *This );
HRESULT
NineSurface9_UploadSelf( struct NineSurface9 *This );

View File

@@ -304,7 +304,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
} else {
desc.Format = pParams->BackBufferFormat;
desc.Usage = D3DUSAGE_RENDERTARGET;
hr = NineSurface9_new(pDevice, NineUnknown(This), resource, 0,
hr = NineSurface9_new(pDevice, NineUnknown(This), resource, NULL, 0,
0, 0, &desc, &This->buffers[i]);
if (has_present_buffers)
pipe_resource_reference(&resource, NULL);
@@ -347,7 +347,7 @@ NineSwapChain9_Resize( struct NineSwapChain9 *This,
/* XXX wine thinks the container of this should be the device */
desc.Format = pParams->AutoDepthStencilFormat;
desc.Usage = D3DUSAGE_DEPTHSTENCIL;
hr = NineSurface9_new(pDevice, NineUnknown(pDevice), resource, 0,
hr = NineSurface9_new(pDevice, NineUnknown(pDevice), resource, NULL, 0,
0, 0, &desc, &This->zsbuf);
pipe_resource_reference(&resource, NULL);
if (FAILED(hr)) {
@@ -737,6 +737,11 @@ NineSwapChain9_Present( struct NineSwapChain9 *This,
HRESULT hr = present(This, pSourceRect, pDestRect,
hDestWindowOverride, pDirtyRegion, dwFlags);
DBG("This=%p pSourceRect=%p pDestRect=%p hDestWindowOverride=%p "
"pDirtyRegion=%p dwFlags=%d\n",
This, pSourceRect, pDestRect, hDestWindowOverride,
pDirtyRegion,dwFlags);
if (hr == D3DERR_WASSTILLDRAWING)
return hr;
@@ -832,7 +837,7 @@ NineSwapChain9_GetFrontBufferData( struct NineSwapChain9 *This,
/* NineSurface9_CopySurface needs same format. */
desc.Format = dest_surface->desc.Format;
desc.Usage = D3DUSAGE_RENDERTARGET;
hr = NineSurface9_new(pDevice, NineUnknown(This), temp_resource, 0,
hr = NineSurface9_new(pDevice, NineUnknown(This), temp_resource, NULL, 0,
0, 0, &desc, &temp_surface);
pipe_resource_reference(&temp_resource, NULL);
if (FAILED(hr)) {

View File

@@ -37,6 +37,10 @@ NineSwapChain9Ex_ctor( struct NineSwapChain9Ex *This,
HWND hFocusWindow,
D3DDISPLAYMODEEX *mode )
{
DBG("This=%p pParams=%p implicit=%d pPresent=%p pPresentationParameters=%p "
"pCTX=%p hFocusWindow=%p mode=%p",
This, pParams, (int) implicit, pPresent, pPresentationParameters, pCTX, hFocusWindow, mode);
return NineSwapChain9_ctor(&This->base, pParams, implicit, pPresent,
pPresentationParameters, pCTX, hFocusWindow, mode);
}

View File

@@ -46,10 +46,11 @@ NineTexture9_ctor( struct NineTexture9 *This,
{
struct pipe_screen *screen = pParams->device->screen;
struct pipe_resource *info = &This->base.base.info;
struct pipe_resource *resource;
unsigned l;
D3DSURFACE_DESC sfdesc;
HRESULT hr;
const boolean shared_create = pSharedHandle && !*pSharedHandle;
void *user_buffer = NULL;
DBG("(%p) Width=%u Height=%u Levels=%u Usage=%s Format=%s Pool=%s "
"pSharedHandle=%p\n", This, Width, Height, Levels,
@@ -77,10 +78,7 @@ NineTexture9_ctor( struct NineTexture9 *This,
Pool == D3DPOOL_DEFAULT, D3DERR_INVALIDCALL);
if (pSharedHandle && Pool == D3DPOOL_DEFAULT) {
/* Note: Below there is some implementation to support buffer sharing in
* this case, but it won't work for cross-process. Thus just ignore
* that code. */
if (shared_create) {
if (!*pSharedHandle) {
DBG("Creating Texture with invalid handle. Importing will fail\n.");
*pSharedHandle = (HANDLE)1; /* Wine would keep it NULL */
pSharedHandle = NULL;
@@ -94,9 +92,6 @@ NineTexture9_ctor( struct NineTexture9 *This,
if (Usage & D3DUSAGE_AUTOGENMIPMAP)
Levels = 0;
This->base.format = Format;
This->base.base.usage = Usage;
info->screen = screen;
info->target = PIPE_TEXTURE_2D;
info->format = d3d9_to_pipe_format(Format);
@@ -130,25 +125,15 @@ NineTexture9_ctor( struct NineTexture9 *This,
if (Pool == D3DPOOL_SYSTEMMEM)
info->usage = PIPE_USAGE_STAGING;
if (pSharedHandle && !shared_create) {
if (Pool == D3DPOOL_SYSTEMMEM) {
/* Hack for surface creation. */
This->base.base.resource = (struct pipe_resource *)*pSharedHandle;
} else {
struct pipe_resource *res;
res = screen->resource_from_handle(screen, info,
(struct winsys_handle *)pSharedHandle);
if (!res)
return D3DERR_NOTFOUND;
This->base.base.resource = res;
}
if (pSharedHandle && *pSharedHandle) { /* Pool == D3DPOOL_SYSTEMMEM */
user_buffer = (void *)*pSharedHandle;
}
This->surfaces = CALLOC(info->last_level + 1, sizeof(*This->surfaces));
if (!This->surfaces)
return E_OUTOFMEMORY;
hr = NineBaseTexture9_ctor(&This->base, pParams, D3DRTYPE_TEXTURE, Pool);
hr = NineBaseTexture9_ctor(&This->base, pParams, NULL, D3DRTYPE_TEXTURE, Format, Pool, Usage);
if (FAILED(hr))
return hr;
This->base.pstype = (Height == 1) ? 1 : 0;
@@ -163,12 +148,19 @@ NineTexture9_ctor( struct NineTexture9 *This,
sfdesc.Pool = Pool;
sfdesc.MultiSampleType = D3DMULTISAMPLE_NONE;
sfdesc.MultiSampleQuality = 0;
if (Pool == D3DPOOL_SYSTEMMEM)
resource = NULL;
else
resource = This->base.base.resource;
for (l = 0; l <= info->last_level; ++l) {
sfdesc.Width = u_minify(Width, l);
sfdesc.Height = u_minify(Height, l);
hr = NineSurface9_new(This->base.base.base.device, NineUnknown(This),
This->base.base.resource, D3DRTYPE_TEXTURE, l, 0,
resource, user_buffer,
D3DRTYPE_TEXTURE, l, 0,
&sfdesc, &This->surfaces[l]);
if (FAILED(hr))
return hr;
@@ -176,19 +168,8 @@ NineTexture9_ctor( struct NineTexture9 *This,
This->dirty_rect.depth = 1; /* widht == 0 means empty, depth stays 1 */
if (pSharedHandle) {
if (Pool == D3DPOOL_SYSTEMMEM) {
This->base.base.resource = NULL;
if (shared_create)
*pSharedHandle = This->surfaces[0]->base.data;
} else
if (shared_create) {
boolean ok;
ok = screen->resource_get_handle(screen, This->base.base.resource,
(struct winsys_handle *)pSharedHandle);
if (!ok)
return D3DERR_DRIVERINTERNALERROR;
}
if (pSharedHandle && !*pSharedHandle) {/* Pool == D3DPOOL_SYSTEMMEM */
*pSharedHandle = This->surfaces[0]->data;
}
return D3D_OK;
@@ -245,6 +226,9 @@ NineTexture9_LockRect( struct NineTexture9 *This,
const RECT *pRect,
DWORD Flags )
{
DBG("This=%p Level=%u pLockedRect=%p pRect=%p Flags=%d\n",
This, Level, pLockedRect, pRect, Flags);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
user_assert(Level == 0 || !(This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP),
D3DERR_INVALIDCALL);
@@ -257,6 +241,8 @@ HRESULT WINAPI
NineTexture9_UnlockRect( struct NineTexture9 *This,
UINT Level )
{
DBG("This=%p Level=%u\n", This, Level);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
return NineSurface9_UnlockRect(This->surfaces[Level]);

View File

@@ -85,8 +85,8 @@ NineVertexBuffer9_ctor( struct NineVertexBuffer9 *This,
info->last_level = 0;
info->nr_samples = 0;
hr = NineResource9_ctor(&This->base, pParams, TRUE, D3DRTYPE_VERTEXBUFFER,
pDesc->Pool);
hr = NineResource9_ctor(&This->base, pParams, NULL, TRUE,
D3DRTYPE_VERTEXBUFFER, pDesc->Pool, pDesc->Usage);
if (FAILED(hr))
return hr;

View File

@@ -95,21 +95,20 @@ nine_d3ddeclusage_check(unsigned usage, unsigned usage_idx)
{
switch (usage) {
case D3DDECLUSAGE_POSITIONT:
case D3DDECLUSAGE_PSIZE:
case D3DDECLUSAGE_TESSFACTOR:
case D3DDECLUSAGE_DEPTH:
case D3DDECLUSAGE_FOG:
case D3DDECLUSAGE_SAMPLE:
return usage_idx <= 0;
case D3DDECLUSAGE_NORMAL:
case D3DDECLUSAGE_TANGENT:
case D3DDECLUSAGE_BINORMAL:
return usage_idx <= 1;
case D3DDECLUSAGE_POSITION:
case D3DDECLUSAGE_BLENDWEIGHT:
case D3DDECLUSAGE_BLENDINDICES:
case D3DDECLUSAGE_COLOR:
return usage_idx <= 4;
return TRUE;
case D3DDECLUSAGE_PSIZE:
case D3DDECLUSAGE_FOG:
case D3DDECLUSAGE_SAMPLE:
return usage_idx <= 0;
case D3DDECLUSAGE_TEXCOORD:
return usage_idx <= 15;
default:
@@ -118,8 +117,8 @@ nine_d3ddeclusage_check(unsigned usage, unsigned usage_idx)
}
#define NINE_DECLUSAGE_CASE0(n) case D3DDECLUSAGE_##n: return NINE_DECLUSAGE_##n
#define NINE_DECLUSAGE_CASEi(n) case D3DDECLUSAGE_##n: return NINE_DECLUSAGE_##n(usage_idx)
INLINE unsigned
#define NINE_DECLUSAGE_CASEi(n) case D3DDECLUSAGE_##n: return NINE_DECLUSAGE_i(n, usage_idx)
uint16_t
nine_d3d9_to_nine_declusage(unsigned usage, unsigned usage_idx)
{
if (!nine_d3ddeclusage_check(usage, usage_idx))
@@ -135,7 +134,7 @@ nine_d3d9_to_nine_declusage(unsigned usage, unsigned usage_idx)
NINE_DECLUSAGE_CASEi(TANGENT);
NINE_DECLUSAGE_CASEi(BINORMAL);
NINE_DECLUSAGE_CASE0(TESSFACTOR);
NINE_DECLUSAGE_CASE0(POSITIONT);
NINE_DECLUSAGE_CASEi(POSITIONT);
NINE_DECLUSAGE_CASEi(COLOR);
NINE_DECLUSAGE_CASE0(DEPTH);
NINE_DECLUSAGE_CASE0(FOG);
@@ -148,58 +147,25 @@ nine_d3d9_to_nine_declusage(unsigned usage, unsigned usage_idx)
static const char *nine_declusage_names[] =
{
[NINE_DECLUSAGE_POSITION(0)] = "POSITION",
[NINE_DECLUSAGE_POSITION(1)] = "POSITION1",
[NINE_DECLUSAGE_POSITION(2)] = "POSITION2",
[NINE_DECLUSAGE_POSITION(3)] = "POSITION3",
[NINE_DECLUSAGE_POSITION(4)] = "POSITION4",
[NINE_DECLUSAGE_BLENDWEIGHT(0)] = "BLENDWEIGHT",
[NINE_DECLUSAGE_BLENDWEIGHT(1)] = "BLENDWEIGHT1",
[NINE_DECLUSAGE_BLENDWEIGHT(2)] = "BLENDWEIGHT2",
[NINE_DECLUSAGE_BLENDWEIGHT(3)] = "BLENDWEIGHT3",
[NINE_DECLUSAGE_BLENDINDICES(0)] = "BLENDINDICES",
[NINE_DECLUSAGE_BLENDINDICES(1)] = "BLENDINDICES1",
[NINE_DECLUSAGE_BLENDINDICES(2)] = "BLENDINDICES2",
[NINE_DECLUSAGE_BLENDINDICES(3)] = "BLENDINDICES3",
[NINE_DECLUSAGE_NORMAL(0)] = "NORMAL",
[NINE_DECLUSAGE_NORMAL(1)] = "NORMAL1",
[NINE_DECLUSAGE_POSITION] = "POSITION",
[NINE_DECLUSAGE_BLENDWEIGHT] = "BLENDWEIGHT",
[NINE_DECLUSAGE_BLENDINDICES] = "BLENDINDICES",
[NINE_DECLUSAGE_NORMAL] = "NORMAL",
[NINE_DECLUSAGE_PSIZE] = "PSIZE",
[NINE_DECLUSAGE_TEXCOORD(0)] = "TEXCOORD0",
[NINE_DECLUSAGE_TEXCOORD(1)] = "TEXCOORD1",
[NINE_DECLUSAGE_TEXCOORD(2)] = "TEXCOORD2",
[NINE_DECLUSAGE_TEXCOORD(3)] = "TEXCOORD3",
[NINE_DECLUSAGE_TEXCOORD(4)] = "TEXCOORD4",
[NINE_DECLUSAGE_TEXCOORD(5)] = "TEXCOORD5",
[NINE_DECLUSAGE_TEXCOORD(6)] = "TEXCOORD6",
[NINE_DECLUSAGE_TEXCOORD(7)] = "TEXCOORD7",
[NINE_DECLUSAGE_TEXCOORD(8)] = "TEXCOORD8",
[NINE_DECLUSAGE_TEXCOORD(9)] = "TEXCOORD9",
[NINE_DECLUSAGE_TEXCOORD(10)] = "TEXCOORD10",
[NINE_DECLUSAGE_TEXCOORD(11)] = "TEXCOORD11",
[NINE_DECLUSAGE_TEXCOORD(12)] = "TEXCOORD12",
[NINE_DECLUSAGE_TEXCOORD(13)] = "TEXCOORD13",
[NINE_DECLUSAGE_TEXCOORD(14)] = "TEXCOORD14",
[NINE_DECLUSAGE_TEXCOORD(15)] = "TEXCOORD15",
[NINE_DECLUSAGE_TANGENT(0)] = "TANGENT",
[NINE_DECLUSAGE_TANGENT(1)] = "TANGENT1",
[NINE_DECLUSAGE_BINORMAL(0)] = "BINORMAL",
[NINE_DECLUSAGE_BINORMAL(1)] = "BINORMAL1",
[NINE_DECLUSAGE_TEXCOORD] = "TEXCOORD",
[NINE_DECLUSAGE_TANGENT] = "TANGENT",
[NINE_DECLUSAGE_BINORMAL] = "BINORMAL",
[NINE_DECLUSAGE_TESSFACTOR] = "TESSFACTOR",
[NINE_DECLUSAGE_POSITIONT] = "POSITIONT",
[NINE_DECLUSAGE_COLOR(0)] = "DIFFUSE",
[NINE_DECLUSAGE_COLOR(1)] = "SPECULAR",
[NINE_DECLUSAGE_COLOR(2)] = "COLOR2",
[NINE_DECLUSAGE_COLOR(3)] = "COLOR3",
[NINE_DECLUSAGE_COLOR(4)] = "COLOR4",
[NINE_DECLUSAGE_COLOR] = "DIFFUSE",
[NINE_DECLUSAGE_DEPTH] = "DEPTH",
[NINE_DECLUSAGE_FOG] = "FOG",
[NINE_DECLUSAGE_NONE] = "(NONE)",
[NINE_DECLUSAGE_COUNT] = "(OOB)"
};
static INLINE const char *
nine_declusage_name(unsigned ndcl)
{
return nine_declusage_names[MIN2(ndcl, Elements(nine_declusage_names) - 1)];
return nine_declusage_names[ndcl % NINE_DECLUSAGE_COUNT];
}
HRESULT
@@ -210,6 +176,8 @@ NineVertexDeclaration9_ctor( struct NineVertexDeclaration9 *This,
const D3DCAPS9 *caps;
unsigned i;
DBG("This=%p pParams=%p pElements=%p\n", This, pParams, pElements);
HRESULT hr = NineUnknown_ctor(&This->base, pParams);
if (FAILED(hr)) { return hr; }
@@ -223,15 +191,14 @@ NineVertexDeclaration9_ctor( struct NineVertexDeclaration9 *This,
This->decls = CALLOC(This->nelems+1, sizeof(D3DVERTEXELEMENT9));
This->elems = CALLOC(This->nelems, sizeof(struct pipe_vertex_element));
This->usage_map = CALLOC(This->nelems, sizeof(uint16_t));
if (!This->decls || !This->elems) { return E_OUTOFMEMORY; }
memcpy(This->decls, pElements, sizeof(D3DVERTEXELEMENT9)*(This->nelems+1));
memset(This->usage_map, 0xff, sizeof(This->usage_map));
for (i = 0; i < This->nelems; ++i) {
uint8_t usage = nine_d3d9_to_nine_declusage(This->decls[i].Usage,
This->decls[i].UsageIndex);
This->usage_map[usage] = i;
uint16_t usage = nine_d3d9_to_nine_declusage(This->decls[i].Usage,
This->decls[i].UsageIndex);
This->usage_map[i] = usage;
This->elems[i].src_offset = This->decls[i].Offset;
This->elems[i].instance_divisor = 0;
@@ -239,11 +206,12 @@ NineVertexDeclaration9_ctor( struct NineVertexDeclaration9 *This,
This->elems[i].src_format = decltype_format(This->decls[i].Type);
/* XXX Remember Method (tesselation), Usage, UsageIndex */
DBG("VERTEXELEMENT[%u]: Stream=%u Offset=%u Type=%s DeclUsage=%s\n", i,
DBG("VERTEXELEMENT[%u]: Stream=%u Offset=%u Type=%s DeclUsage=%s%d\n", i,
This->decls[i].Stream,
This->decls[i].Offset,
util_format_name(This->elems[i].src_format),
nine_declusage_name(usage));
nine_declusage_name(usage),
usage / NINE_DECLUSAGE_COUNT);
}
return D3D_OK;
@@ -256,6 +224,8 @@ NineVertexDeclaration9_dtor( struct NineVertexDeclaration9 *This )
FREE(This->decls);
if (This->elems)
FREE(This->elems);
if (This->usage_map)
FREE(This->usage_map);
NineUnknown_dtor(&This->base);
}
@@ -460,6 +430,9 @@ NineVertexDeclaration9_ConvertStreamOutput(
void *src_map;
void *dst_map;
DBG("This=%p pDstBuf=%p DestIndex=%u VertexCount=%u pSrcBuf=%p so=%p\n",
This, pDstBuf, DestIndex, VertexCount, pSrcBuf, so);
transkey.output_stride = 0;
for (i = 0; i < This->nelems; ++i) {
enum pipe_format format;

View File

@@ -40,9 +40,9 @@ struct NineVertexDeclaration9
struct pipe_vertex_element *elems;
unsigned nelems;
/* DECLUSAGE -> element index, for selecting the vertex element
/* index -> DECLUSAGE, for selecting the vertex element
* for each VS input */
uint8_t usage_map[NINE_DECLUSAGE_COUNT];
uint16_t *usage_map;
D3DVERTEXELEMENT9 *decls;
DWORD fvf;

View File

@@ -40,6 +40,9 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This,
HRESULT hr;
unsigned i;
DBG("This=%p pParams=%p pFunction=%p cso=%p\n",
This, pParams, pFunction, cso);
hr = NineUnknown_ctor(&This->base, pParams);
if (FAILED(hr))
return hr;

View File

@@ -32,7 +32,7 @@ struct NineVertexShader9
struct nine_shader_variant variant;
struct {
uint8_t ndecl; /* NINE_DECLUSAGE_x */
uint16_t ndecl; /* NINE_DECLUSAGE_x */
} input_map[PIPE_MAX_ATTRIBS];
unsigned num_inputs;

View File

@@ -342,6 +342,9 @@ NineVolume9_CopyVolume( struct NineVolume9 *This,
uint8_t *p_dst;
const uint8_t *p_src;
DBG("This=%p From=%p dstx=%u dsty=%u dstz=%u pSrcBox=%p\n",
This, From, dstx, dsty, dstz, pSrcBox);
user_assert(This->desc.Format == From->desc.Format, D3DERR_INVALIDCALL);
dst_box.x = dstx;
@@ -527,6 +530,9 @@ NineVolume9_SetPrivateData( struct NineVolume9 *This,
struct pheader *header;
const void *user_data = pData;
DBG("This=%p refguid=%p pData=%p SizeOfData=%d Flags=%d\n",
This, refguid, pData, SizeOfData, Flags);
if (Flags & D3DSPD_IUNKNOWN)
user_assert(SizeOfData == sizeof(IUnknown *), D3DERR_INVALIDCALL);
@@ -593,6 +599,8 @@ NineVolume9_FreePrivateData( struct NineVolume9 *This,
{
struct pheader *header;
DBG("This=%p refguid=%p\n", This, refguid);
header = util_hash_table_get(This->pdata, refguid);
if (!header) { return D3DERR_NOTFOUND; }

View File

@@ -41,6 +41,11 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This,
D3DVOLUME_DESC voldesc;
HRESULT hr;
DBG("This=%p pParams=%p Width=%u Height=%u Depth=%u Levels=%u "
"Usage=%d Format=%d Pool=%d pSharedHandle=%p\n",
This, pParams, Width, Height, Depth, Levels,
Usage, Format, Pool, pSharedHandle);
/* An IDirect3DVolume9 cannot be bound as a render target can it ? */
user_assert(!(Usage & (D3DUSAGE_RENDERTARGET | D3DUSAGE_DEPTHSTENCIL)),
D3DERR_INVALIDCALL);
@@ -52,9 +57,6 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This,
if (Usage & D3DUSAGE_AUTOGENMIPMAP)
Levels = 0;
This->base.format = Format;
This->base.base.usage = Usage;
info->screen = pParams->device->screen;
info->target = PIPE_TEXTURE_3D;
info->format = d3d9_to_pipe_format(Format);
@@ -83,8 +85,8 @@ NineVolumeTexture9_ctor( struct NineVolumeTexture9 *This,
return E_OUTOFMEMORY;
This->base.pstype = 3;
hr = NineBaseTexture9_ctor(&This->base, pParams,
D3DRTYPE_VOLUMETEXTURE, Pool);
hr = NineBaseTexture9_ctor(&This->base, pParams, NULL,
D3DRTYPE_VOLUMETEXTURE, Format, Pool, Usage);
if (FAILED(hr))
return hr;
@@ -159,6 +161,9 @@ NineVolumeTexture9_LockBox( struct NineVolumeTexture9 *This,
const D3DBOX *pBox,
DWORD Flags )
{
DBG("This=%p Level=%u pLockedVolume=%p pBox=%p Flags=%d\n",
This, Level, pLockedVolume, pBox, Flags);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
user_assert(Level == 0 || !(This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP),
D3DERR_INVALIDCALL);
@@ -171,6 +176,8 @@ HRESULT WINAPI
NineVolumeTexture9_UnlockBox( struct NineVolumeTexture9 *This,
UINT Level )
{
DBG("This=%p Level=%u\n", This, Level);
user_assert(Level <= This->base.base.info.last_level, D3DERR_INVALIDCALL);
return NineVolume9_UnlockBox(This->volumes[Level]);
@@ -180,6 +187,8 @@ HRESULT WINAPI
NineVolumeTexture9_AddDirtyBox( struct NineVolumeTexture9 *This,
const D3DBOX *pDirtyBox )
{
DBG("This=%p pDirtybox=%p\n", This, pDirtyBox);
if (This->base.base.pool != D3DPOOL_MANAGED) {
if (This->base.base.usage & D3DUSAGE_AUTOGENMIPMAP)
This->base.dirty_mip = TRUE;

View File

@@ -367,7 +367,6 @@ EXPORTS
wglUseFontBitmapsW
wglUseFontOutlinesA
wglUseFontOutlinesW
wglGetExtensionsStringARB
DrvCopyContext
DrvCreateContext
DrvCreateLayerContext

View File

@@ -62,7 +62,7 @@ d3dadapter9_la_LDFLAGS = \
-shrext .so \
-module \
-no-undefined \
-version-number $(NINE_MAJOR):$(NINE_MINOR) \
-version-number $(NINE_MAJOR):$(NINE_MINOR):$(NINE_TINY) \
$(GC_SECTIONS) \
$(LD_NO_UNDEFINED)

View File

@@ -6,6 +6,6 @@ moduledir=@D3D_DRIVER_INSTALL_DIR@
Name: d3d
Description: Native D3D driver modules
Version: @VERSION@
Version: @NINE_VERSION@
Requires.private: @DRI_PC_REQ_PRIV@
Cflags: -I${includedir}

View File

@@ -49,6 +49,7 @@ public:
{
instructions = insts;
progress = false;
index = 0;
}
bool run()
@@ -62,6 +63,7 @@ public:
private:
exec_list *instructions;
bool progress;
unsigned index;
};
void
@@ -70,14 +72,20 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
if (!*rvalue)
return;
ir_constant *con = (*rvalue)->as_constant();
ir_dereference_array *dra = (*rvalue)->as_dereference_array();
if (!dra)
return;
ir_constant *con = dra->array->as_constant();
if (!con || !con->type->is_array())
return;
void *mem_ctx = ralloc_parent(con);
char *uniform_name = ralloc_asprintf(mem_ctx, "constarray__%d", index++);
ir_variable *uni =
new(mem_ctx) ir_variable(con->type, "constarray", ir_var_uniform);
new(mem_ctx) ir_variable(con->type, uniform_name, ir_var_uniform);
uni->constant_initializer = con;
uni->constant_value = con;
uni->data.has_initializer = true;
@@ -87,7 +95,8 @@ lower_const_array_visitor::handle_rvalue(ir_rvalue **rvalue)
uni->data.max_array_access = uni->type->length - 1;
instructions->push_head(uni);
*rvalue = new(mem_ctx) ir_dereference_variable(uni);
ir_dereference_variable *varref = new(mem_ctx) ir_dereference_variable(uni);
*rvalue = new(mem_ctx) ir_dereference_array(varref, dra->array_index);
progress = true;
}

View File

@@ -16,6 +16,7 @@ if env['platform'] == 'windows':
env.Append(CPPDEFINES = [
'_GDI32_', # prevent gl* being declared __declspec(dllimport) in MS headers
'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers
'KHRONOS_DLL_EXPORTS', # declare gl* as __declspec(dllexport) in Khronos headers
])
if env['gles']:
env.Append(CPPDEFINES = ['_GLAPI_DLL_EXPORTS'])

View File

@@ -3354,6 +3354,7 @@ vec4_visitor::move_uniform_array_access_to_pull_constants()
{
int pull_constant_loc[this->uniforms];
memset(pull_constant_loc, -1, sizeof(pull_constant_loc));
bool nested_reladdr;
/* Walk through and find array access of uniforms. Put a copy of that
* uniform in the pull constant buffer.
@@ -3361,44 +3362,51 @@ vec4_visitor::move_uniform_array_access_to_pull_constants()
* Note that we don't move constant-indexed accesses to arrays. No
* testing has been done of the performance impact of this choice.
*/
foreach_block_and_inst_safe(block, vec4_instruction, inst, cfg) {
for (int i = 0 ; i < 3; i++) {
if (inst->src[i].file != UNIFORM || !inst->src[i].reladdr)
continue;
do {
nested_reladdr = false;
int uniform = inst->src[i].reg;
foreach_block_and_inst_safe(block, vec4_instruction, inst, cfg) {
for (int i = 0 ; i < 3; i++) {
if (inst->src[i].file != UNIFORM || !inst->src[i].reladdr)
continue;
/* If this array isn't already present in the pull constant buffer,
* add it.
*/
if (pull_constant_loc[uniform] == -1) {
const gl_constant_value **values =
&stage_prog_data->param[uniform * 4];
int uniform = inst->src[i].reg;
pull_constant_loc[uniform] = stage_prog_data->nr_pull_params / 4;
if (inst->src[i].reladdr->reladdr)
nested_reladdr = true; /* will need another pass */
assert(uniform < uniform_array_size);
for (int j = 0; j < uniform_size[uniform] * 4; j++) {
stage_prog_data->pull_param[stage_prog_data->nr_pull_params++]
= values[j];
}
}
/* If this array isn't already present in the pull constant buffer,
* add it.
*/
if (pull_constant_loc[uniform] == -1) {
const gl_constant_value **values =
&stage_prog_data->param[uniform * 4];
/* Set up the annotation tracking for new generated instructions. */
base_ir = inst->ir;
current_annotation = inst->annotation;
pull_constant_loc[uniform] = stage_prog_data->nr_pull_params / 4;
dst_reg temp = dst_reg(this, glsl_type::vec4_type);
assert(uniform < uniform_array_size);
for (int j = 0; j < uniform_size[uniform] * 4; j++) {
stage_prog_data->pull_param[stage_prog_data->nr_pull_params++]
= values[j];
}
}
emit_pull_constant_load(block, inst, temp, inst->src[i],
pull_constant_loc[uniform]);
/* Set up the annotation tracking for new generated instructions. */
base_ir = inst->ir;
current_annotation = inst->annotation;
inst->src[i].file = temp.file;
inst->src[i].reg = temp.reg;
inst->src[i].reg_offset = temp.reg_offset;
inst->src[i].reladdr = NULL;
dst_reg temp = dst_reg(this, glsl_type::vec4_type);
emit_pull_constant_load(block, inst, temp, inst->src[i],
pull_constant_loc[uniform]);
inst->src[i].file = temp.file;
inst->src[i].reg = temp.reg;
inst->src[i].reg_offset = temp.reg_offset;
inst->src[i].reladdr = NULL;
}
}
}
} while (nested_reladdr);
/* Now there are no accesses of the UNIFORM file with a reladdr, so
* no need to track them as larger-than-vec4 objects. This will be

View File

@@ -129,6 +129,20 @@ get_attr_override(const struct brw_vue_map *vue_map, int urb_entry_read_offset,
}
static bool
is_drawing_points(const struct brw_context *brw)
{
/* Determine if the primitives *reaching the SF* are points */
if (brw->geometry_program) {
/* BRW_NEW_GEOMETRY_PROGRAM */
return brw->geometry_program->OutputType == GL_POINTS;
} else {
/* BRW_NEW_PRIMITIVE */
return brw->primitive == _3DPRIM_POINTLIST;
}
}
/**
* Create the mapping from the FS inputs we produce to the previous pipeline
* stage (GS or VS) outputs they source from.
@@ -149,6 +163,23 @@ calculate_attr_overrides(const struct brw_context *brw,
/* _NEW_LIGHT */
bool shade_model_flat = brw->ctx.Light.ShadeModel == GL_FLAT;
/* From the Ivybridge PRM, Vol 2 Part 1, 3DSTATE_SBE,
* description of dw10 Point Sprite Texture Coordinate Enable:
*
* "This field must be programmed to zero when non-point primitives
* are rendered."
*
* The SandyBridge PRM doesn't explicitly say that point sprite enables
* must be programmed to zero when rendering non-point primitives, but
* the IvyBridge PRM does, and if we don't, we get garbage.
*
* This is not required on Haswell, as the hardware ignores this state
* when drawing non-points -- although we do still need to be careful to
* correctly set the attr overrides.
*/
/* BRW_NEW_PRIMITIVE | BRW_NEW_GEOMETRY_PROGRAM */
bool drawing_points = is_drawing_points(brw);
/* Initialize all the attr_overrides to 0. In the loop below we'll modify
* just the ones that correspond to inputs used by the fs.
*/
@@ -167,18 +198,20 @@ calculate_attr_overrides(const struct brw_context *brw,
/* _NEW_POINT */
bool point_sprite = false;
if (brw->ctx.Point.PointSprite &&
(attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) &&
brw->ctx.Point.CoordReplace[attr - VARYING_SLOT_TEX0]) {
point_sprite = true;
if (drawing_points) {
if (brw->ctx.Point.PointSprite &&
(attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) &&
brw->ctx.Point.CoordReplace[attr - VARYING_SLOT_TEX0]) {
point_sprite = true;
}
if (attr == VARYING_SLOT_PNTC)
point_sprite = true;
if (point_sprite)
*point_sprite_enables |= (1 << input_index);
}
if (attr == VARYING_SLOT_PNTC)
point_sprite = true;
if (point_sprite)
*point_sprite_enables |= (1 << input_index);
/* flat shading */
if (interp_qualifier == INTERP_QUALIFIER_FLAT ||
(shade_model_flat && is_gl_Color &&
@@ -410,7 +443,9 @@ const struct brw_tracked_state gen6_sf_state = {
_NEW_POINT |
_NEW_MULTISAMPLE),
.brw = (BRW_NEW_CONTEXT |
BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_GEOMETRY_PROGRAM |
BRW_NEW_PRIMITIVE |
BRW_NEW_VUE_MAP_GEOM_OUT),
.cache = CACHE_NEW_WM_PROG
},

View File

@@ -92,7 +92,9 @@ const struct brw_tracked_state gen7_sbe_state = {
_NEW_POINT |
_NEW_PROGRAM),
.brw = (BRW_NEW_CONTEXT |
BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_FRAGMENT_PROGRAM |
BRW_NEW_GEOMETRY_PROGRAM |
BRW_NEW_PRIMITIVE |
BRW_NEW_VUE_MAP_GEOM_OUT),
.cache = CACHE_NEW_WM_PROG
},

View File

@@ -627,7 +627,7 @@ descriptor=[
# == GL_CURRENT_MATRIX_NV
[ "CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
# == GL_CURRENT_MATRIX_NV
[ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
[ "TRANSPOSE_CURRENT_MATRIX_ARB", "LOC_CUSTOM, TYPE_MATRIX_T, 0, extra_ARB_vertex_program_ARB_fragment_program" ],
# == GL_PROGRAM_ERROR_POSITION_NV
[ "PROGRAM_ERROR_POSITION_ARB", "CONTEXT_INT(Program.ErrorPos), extra_ARB_vertex_program_ARB_fragment_program" ],

View File

@@ -1542,7 +1542,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target,
maxSize >>= level;
if (width < 2 * border || width > 2 * border + maxSize)
return GL_FALSE;
if (height < 1 || height > ctx->Const.MaxArrayTextureLayers)
if (height < 0 || height > ctx->Const.MaxArrayTextureLayers)
return GL_FALSE;
if (!ctx->Extensions.ARB_texture_non_power_of_two) {
if (width > 0 && !_mesa_is_pow_two(width - 2 * border))

View File

@@ -2229,7 +2229,7 @@ _mesa_compute_compressed_pixelstore(GLuint dims, mesa_format texFormat,
if (packing->RowLength) {
store->TotalBytesPerRow = packing->CompressedBlockSize *
(packing->RowLength + bw - 1) / bw;
((packing->RowLength + bw - 1) / bw);
}
store->SkipBytes += packing->SkipPixels * packing->CompressedBlockSize / bw;