Re: Tips for debugging D3D Textures & DirectSound?
Nadav Frum <[email protected]> Fri, 22 Oct 2004 12:26:02 +0200 (IST)
| Newsgroups | gmane.comp.emulators.winex.devel |
|---|---|
| Message-ID | <Pine.LNX.4.44_heb2.10.0410221207520.23766-200000@localhost.localdomain> |
On Thu, 13 Oct 2004 Gavriel State wrote:
> Just to be clear, the hard part with NPOT texturing is the fact that
> with the currently available GL extensions, the texture coordinates need
> to be sent to GL in the range of (0..width, 0..height), instead of the
> (0..1, 0..1) we are given by the application using D3D.This means that
> in order to support these textures without the upcoming GL 2.0
> extensions, we would need to have a duplicate texture coordinate buffer
> with the coordinates in the (0..width, 0..height) form, and fill it from
> the (0..1, 0..1) source data.We already have to do similar things when
> we have pretransformed position coordinates, and with vertex color data,
> and there are some very complex optimizations at the
> x11drv/executebuffer level to ensure that they can work with acceptable
> performance.
I examined the pre-render transformation you do for position coordinates
of the XYZRHW format. The XYZRHW format gives you a vector of the form
(x, y, z, 1/w) which you convert to (wx, wy, wz, w). This is correct.
However, to my understanding, the vector (x, y, z, 1.0) would also be
correct. This vector can be input without a pre-render transformation by
loading a 3 dimension vector into glVertexPointer.
I have attached a patch which reverses the RHW pre-render conversion.
Nadav Frum
----------
P.S. Is it possible to batch the wine-devel posts in such a way that the
individual posts can be accessed and replied to individually.
winex-20041022-no_rhw_conversion.patch
(text/plain, 6.8 KB)
--- winex-20041022/dlls/d3dgl/fixedfunc.c.rhw 2004-04-21 22:26:55.000000000 +0300
+++ winex-20041022/dlls/d3dgl/fixedfunc.c 2004-10-22 12:02:40.970234680 +0200
@@ -31,7 +31,7 @@
#define D3DFVF_TEXCOUNT(x) (((x) & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT)
#define D3DFVF_TEXCOORDSIZE(fvf,idx) ( ((((fvf)>>((idx)*2 + 16)) + 1) & 0x0003) + 1 )
-/* D3DFVF_XYZRHW and D3DFVF_XYZGLW */
+/* D3DFVF_XYZRHW */
#define ISTLFVF(x) (((x) & 0xe) == 4)
static inline DWORD D3D_GL_PositionSize(DWORD fvf)
@@ -45,98 +45,6 @@
return max((fvf & 0xe) / 2, 2) - 2;
}
-static inline void GL_convert_position(const float* in, float* out)
-{
- float w;
-
- /* Reportedly Microsoft uses 2^20 in their ProcessVertices impl. */
- if (in[3] == 0.0) w = 1048576.0;
- else w = 1.0 / in[3];
-
- out[0] = in[0] * w;
- out[1] = in[1] * w;
- out[2] = in[2] * w;
- out[3] = w;
-}
-
-
-static HRESULT GL_build_position_array(GL_D3D_priv* priv, DWORD fvf,
- DWORD vstart, DWORD vcount,
- LPGLDRAWPRIMITIVESTRIDEDDATA data,
- const WORD* indices, DWORD nindices,
- DWORD ibase)
-{
- LPBYTE in;
- LPD3DVALUE out;
- DWORD stride = data->position.dwStride;
- DWORD size;
-
- size = vcount * 4 * sizeof(D3DVALUE);
- if (size > priv->vertex_array_size)
- {
- LPVOID new_array;
-
- size = max(size, 2 * priv->vertex_array_size);
-
- new_array = VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE,
- PAGE_READWRITE);
-
- if (new_array == NULL) return E_OUTOFMEMORY;
-
- VirtualFree(priv->vertex_array, 0, MEM_RELEASE);
-
- priv->vertex_array = new_array;
- priv->vertex_array_size = size;
- }
-
- in = data->position.lpvData;
- out = priv->vertex_array;
-
- if (indices != NULL && nindices < vcount)
- {
- in += ibase * stride;
- out -= (vstart - ibase) * 4;
- while (nindices--)
- {
- DWORD index = *indices++;
-
- GL_convert_position((LPFLOAT)(in + index * stride),
- (LPFLOAT)(out + index * 4));
- }
- }
- else
- {
- in += vstart * stride;
- while (vcount--)
- {
- GL_convert_position((LPFLOAT)in, (LPFLOAT)out);
-
- in += stride;
- out += 4;
- }
- }
-
- return DD_OK;
-}
-
-static void GL_fixup_position_array(GL_D3D_priv* priv, DWORD fvf,
- DWORD vstart, DWORD vcount,
- LPGLDRAWPRIMITIVESTRIDEDDATA data,
- const WORD* indices, DWORD nindices,
- DWORD ibase)
-{
- if ((fvf & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)
- {
- DWORD stride = 4 * sizeof(D3DVALUE);
-
- GL_build_position_array(priv, fvf, vstart, vcount, data, indices, nindices, ibase);
-
- data->position.lpvData = (LPBYTE)priv->vertex_array - vstart * stride;
- data->position.dwStride = stride;
- }
-}
-
-
static inline DWORD rot16(DWORD x)
{
return (x << 16) | (x >> 16);
@@ -650,15 +558,10 @@
static void GL_load_arrays(GL_D3D_priv* priv, DWORD fvf, DWORD start,
LPGLDRAWPRIMITIVESTRIDEDDATA stride)
{
- DWORD position_size, num_weights;
+ DWORD num_weights;
DWORD inuse, tstages;
DWORD i;
- if (ISTLFVF(fvf))
- position_size = 4;
- else
- position_size = 3;
-
num_weights = D3D_GL_BlendWeights(fvf);
if (num_weights && (fvf & D3DFVF_LASTBETA_UBYTE4)) num_weights--;
@@ -674,7 +577,7 @@
if (priv->pVertexArray != STRIDE_DATA_PTR(position) ||
priv->sVertexArray != STRIDE_DATA_STRIDE(position))
{
- glVertexPointer(position_size, GL_FLOAT, STRIDE_DATA(position));
+ glVertexPointer(3, GL_FLOAT, STRIDE_DATA(position));
priv->pVertexArray = STRIDE_DATA_PTR(position);
priv->sVertexArray = STRIDE_DATA_STRIDE(position);
}
@@ -1326,10 +1229,6 @@
* renderstates and settings. */
static BOOL GL_IsDirectlyRenderable(GL_D3D_priv* priv, DWORD vt)
{
- /* RHW is directly supported if it has been converted to OpenGL format. */
- if ((vt & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)
- return FALSE;
-
if (vt & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR))
{
DWORD vertex_colors = (vt >> 6) & 3;
@@ -1786,13 +1685,7 @@
x = STRIDE_DATA(position);
if ((fvf & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
- D3DVALUE w = 1.0/x[3];
TRACE(" XYZRHW: %f, %f, %f, %f (%p)\n", x[0], x[1], x[2], x[3], x);
- TRACE(" XYZ*W : %f, %f, %f, %f\n", x[0]*w, x[1]*w, x[2]*w, w);
- } else if ((fvf & D3DFVF_POSITION_MASK) == D3DFVF_XYZGLW) {
- D3DVALUE rhw = 1.0/x[3];
- TRACE(" XYZGLW: %f, %f, %f, %f (%p)\n", x[0], x[1], x[2], x[3], x);
- TRACE(" XYZ/W : %f, %f, %f, %f\n", x[0]*rhw, x[1]*rhw, x[2]*rhw, x[3]);
} else {
TRACE(" XYZ : %f, %f, %f (%p)\n", x[0], x[1], x[2], x);
/* FIXME: blend weights */
@@ -1955,8 +1848,6 @@
/* FIXME: recompute vertex materials only on (NEW_LIGHTING | NEW_TNL_MODE) ? */
fvf = GL_fixup_vertex_materials(priv, fvf, &priv->stride);
- GL_fixup_position_array(priv, fvf, dwVStart, dwVCount,
- &priv->stride, indices, dwCount, dwIndexBase);
GL_fixup_color_arrays(priv, fvf, dwVStart, dwVCount,
&priv->stride, indices, dwCount, dwIndexBase);
--- winex-20041022/dlls/x11drv/executebuffer.c.rhw 2004-04-29 22:19:18.000000000 +0300
+++ winex-20041022/dlls/x11drv/executebuffer.c 2004-10-22 12:02:41.016227688 +0200
@@ -908,15 +908,11 @@
static BOOL X11DRV_GLX_DoesFVFNeedConversion(DWORD fvf)
{
- return ((fvf & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW
- || (fvf & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)));
+ return (fvf & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR));
}
static DWORD X11DRV_GLX_ConvertedFVF(DWORD fvf)
{
- if ((fvf & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)
- fvf |= D3DFVF_XYZGLW;
-
if (fvf & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR))
fvf |= D3DFVF_GLCOLORORDER;
@@ -968,26 +964,6 @@
switch (fvf & D3DFVF_POSITION_MASK)
{
- case D3DFVF_XYZRHW:
- {
- float w;
- const FLOAT* inf = (const FLOAT*)in;
- LPFLOAT outf = (LPFLOAT)out;
-
- /* Reportedly Microsoft uses 2^20 in their ProcessVertices impl. */
- if (inf[3] == 0.0) w = 1048576.0;
- else w = 1.0 / inf[3];
-
- outf[0] = inf[0] * w;
- outf[1] = inf[1] * w;
- outf[2] = inf[2] * w;
- outf[3] = w;
-
- in += 4;
- out += 4;
- }
- break;
-
case D3DFVF_XYZB5:
*out++ = *in++;
case D3DFVF_XYZB4:
@@ -997,6 +973,7 @@
case D3DFVF_XYZB2:
*out++ = *in++;
case D3DFVF_XYZB1:
+ case D3DFVF_XYZRHW:
*out++ = *in++;
case D3DFVF_XYZ:
*out++ = *in++;
--- winex-20041022/include/wine/d3dhalgl.h.rhw 2004-01-28 20:27:49.000000000 +0200
+++ winex-20041022/include/wine/d3dhalgl.h 2004-10-22 12:02:41.035224800 +0200
@@ -16,7 +16,6 @@
#endif
#define D3DFVF_GLCOLORORDER 0x2000 /* colours reordered to RGBA */
-#define D3DFVF_XYZGLW 0x4004 /* RHW converted to W */
typedef struct
{