DXGL r884 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r883‎ | r884 | r885 >
Date:14:40, 9 December 2018
Author:admin
Status:new
Tags:
Comment:
Implement GetFourCCCodes API.
Use __int64 data type for 2D shader IDs.
Modified paths:
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/ShaderGen2D.h (modified) (history)
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/fourcc.c (added) (history)
  • /ddraw/fourcc.h (added) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /vs8/ddraw/ddraw.vcproj (modified) (history)

Diff [purge]

Index: ddraw/ShaderGen2D.cpp
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2013-2017 William Feely
 3+// Copyright (C) 2013-2018 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -55,6 +55,8 @@
5656 Bit 29: (DXGL) Source color key range
5757 Bit 30: (DXGL) Dest. color key range
5858 Bit 31: reserved for DXGL usage
 59+Bits 32-39: Texture type input
 60+Bits 40-47: Texture type output
5961 AND the dwFlags by 0xF2FAADFF before packing ROP index bits
6062 */
6163
@@ -650,7 +652,7 @@
651653 "pixel = colorsizedest;\n",//FF WHITENESS
652654 };
653655
654 -DWORD PackROPBits(DWORD rop, DWORD flags)
 656+__int64 PackROPBits(DWORD rop, __int64 flags)
655657 {
656658 DWORD out = flags & 0xF2FAADFF;
657659 if (rop & 0x10000) out |= 1 << 9;
@@ -664,7 +666,7 @@
665667 return out;
666668 }
667669
668 -DWORD UnpackROPBits(DWORD flags)
 670+DWORD UnpackROPBits(__int64 flags)
669671 {
670672 DWORD out = 0;
671673 if (flags & (1 << 9)) out |= 1;
@@ -707,7 +709,7 @@
708710 gen->genindex = 0;
709711 }
710712
711 -void ShaderGen2D_CreateShader2D(ShaderGen2D *gen, int index, DWORD id)
 713+void ShaderGen2D_CreateShader2D(ShaderGen2D *gen, int index, __int64 id)
712714 {
713715 STRING tmp;
714716 DWORD rop;
Index: ddraw/ShaderGen2D.h
@@ -1,5 +1,5 @@
22 // DXGL
3 -// Copyright (C) 2013 William Feely
 3+// Copyright (C) 2013-2018 William Feely
44
55 // This library is free software; you can redistribute it and/or
66 // modify it under the terms of the GNU Lesser General Public
@@ -39,7 +39,7 @@
4040 struct GenShader2D
4141 {
4242 _GENSHADER2D shader;
43 - DWORD id;
 43+ __int64 id;
4444 };
4545
4646 typedef struct ShaderGen2D
@@ -57,11 +57,11 @@
5858 extern const DWORD supported_rops[8];
5959 extern const DWORD supported_rops_gl2[8];
6060
61 -DWORD PackROPBits(DWORD rop, DWORD flags);
 61+__int64 PackROPBits(DWORD rop, __int64 flags);
6262
6363 void ShaderGen2D_Init(ShaderGen2D *gen, glExtensions *ext, ShaderManager *shaderman);
6464 void ShaderGen2D_Delete(ShaderGen2D *gen);
65 -void ShaderGen2D_CreateShader2D(ShaderGen2D *gen, int index, DWORD id);
 65+void ShaderGen2D_CreateShader2D(ShaderGen2D *gen, int index, __int64 id);
6666
6767 #ifdef __cplusplus
6868 }
Index: ddraw/ddraw.vcxproj
@@ -319,6 +319,7 @@
320320 <ClInclude Include="common.h" />
321321 <ClInclude Include="const.h" />
322322 <ClInclude Include="ddraw.h" />
 323+ <ClInclude Include="fourcc.h" />
323324 <ClInclude Include="glClassFactory.h" />
324325 <ClInclude Include="glDirect3D.h" />
325326 <ClInclude Include="glDirect3DDevice.h" />
@@ -403,6 +404,15 @@
404405 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
405406 </PrecompiledHeader>
406407 </ClCompile>
 408+ <ClCompile Include="fourcc.c">
 409+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
 410+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
 411+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug VS2017|Win32'">NotUsing</PrecompiledHeader>
 412+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">NotUsing</PrecompiledHeader>
 413+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
 414+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release VS2017|Win32'">NotUsing</PrecompiledHeader>
 415+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
 416+ </ClCompile>
407417 <ClCompile Include="glClassFactory.cpp" />
408418 <ClCompile Include="dxguid.c">
409419 <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
Index: ddraw/ddraw.vcxproj.filters
@@ -161,6 +161,9 @@
162162 <ClInclude Include="colorconv.h">
163163 <Filter>Header Files</Filter>
164164 </ClInclude>
 165+ <ClInclude Include="fourcc.h">
 166+ <Filter>Header Files</Filter>
 167+ </ClInclude>
165168 </ItemGroup>
166169 <ItemGroup>
167170 <ClCompile Include="ddraw.cpp">
@@ -271,6 +274,9 @@
272275 <ClCompile Include="colorconv.c">
273276 <Filter>Source Files</Filter>
274277 </ClCompile>
 278+ <ClCompile Include="fourcc.c">
 279+ <Filter>Source Files</Filter>
 280+ </ClCompile>
275281 </ItemGroup>
276282 <ItemGroup>
277283 <ResourceCompile Include="ddraw.rc">
Index: ddraw/fourcc.c
@@ -0,0 +1,31 @@
 2+// DXGL
 3+// Copyright (C) 2018 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#include <windows.h>
 20+#include <mmsystem.h>
 21+#include "fourcc.h"
 22+
 23+static const int START_FOURCC = __LINE__;
 24+const DWORD dxglfourcc[] =
 25+{ 0 // TODO: Add FourCC codes and remove placeholder
 26+};
 27+static const int END_FOURCC = __LINE__ - 4;
 28+
 29+int GetNumFOURCC()
 30+{
 31+ return END_FOURCC - START_FOURCC;
 32+}
\ No newline at end of file
Index: ddraw/fourcc.h
@@ -0,0 +1,33 @@
 2+// DXGL
 3+// Copyright (C) 2018 William Feely
 4+
 5+// This library is free software; you can redistribute it and/or
 6+// modify it under the terms of the GNU Lesser General Public
 7+// License as published by the Free Software Foundation; either
 8+// version 2.1 of the License, or (at your option) any later version.
 9+
 10+// This library is distributed in the hope that it will be useful,
 11+// but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 13+// Lesser General Public License for more details.
 14+
 15+// You should have received a copy of the GNU Lesser General Public
 16+// License along with this library; if not, write to the Free Software
 17+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 18+
 19+#pragma once
 20+#ifndef __FOURCC_H
 21+#define __FOURCC_H
 22+
 23+#ifdef __cplusplus
 24+extern "C" {
 25+#endif
 26+
 27+extern const DWORD dxglfourcc[];
 28+int GetNumFOURCC();
 29+
 30+#ifdef __cplusplus
 31+}
 32+#endif
 33+
 34+#endif //__FOURCC_H
\ No newline at end of file
Index: ddraw/glDirectDraw.cpp
@@ -32,6 +32,7 @@
3333 #include "glRenderer.h"
3434 #include "../common/version.h"
3535 #include "hooks.h"
 36+#include "fourcc.h"
3637
3738 #ifndef DISP_CHANGE_BADDUALVIEW
3839 #define DISP_CHANGE_BADDUALVIEW -6
@@ -1629,10 +1630,16 @@
16301631 TRACE_ENTER(3,14,this,14,lpNumCodes,14,lpCodes);
16311632 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
16321633 if(!lpNumCodes) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
1633 - if(!lpCodes) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
1634 - FIXME("IDirectDraw::GetFourCCCodes: stub\n");
1635 - TRACE_EXIT(23,DDERR_GENERIC);
1636 - ERR(DDERR_GENERIC);
 1634+ *lpNumCodes = GetNumFOURCC();
 1635+ if (lpCodes)
 1636+ {
 1637+ for (int i = 0; i < *lpNumCodes; i++)
 1638+ {
 1639+ lpCodes[i] = dxglfourcc[i];
 1640+ }
 1641+ }
 1642+ TRACE_EXIT(23,DD_OK);
 1643+ return DD_OK;
16371644 }
16381645 HRESULT WINAPI glDirectDraw7::GetGDISurface(LPDIRECTDRAWSURFACE7 FAR *lplpGDIDDSurface)
16391646 {
Index: ddraw/glRenderer.cpp
@@ -3353,7 +3353,7 @@
33543354 RECT srcrect;
33553355 RECT destrect, destrect2;
33563356 This->ddInterface->GetSizes(sizes);
3357 - DWORD shaderid;
 3357+ unsigned __int64 shaderid;
33583358 DDSURFACEDESC2 ddsd;
33593359 ddsd = cmd->dest->levels[cmd->destlevel].ddsd;
33603360 if (!memcmp(&cmd->destrect, &nullrect, sizeof(RECT)))
@@ -3379,6 +3379,7 @@
33803380 if (rop_texture_usage[(cmd->bltfx.dwROP >> 16) & 0xFF] & 4) usepattern = TRUE;
33813381 }
33823382 else shaderid = cmd->flags & 0xF2FAADFF;
 3383+ //TODO: Add src/dest texture types
33833384 if (cmd->flags & DDBLT_KEYDEST) usedest = TRUE;
33843385 if (IsAlphaCKey())
33853386 {
Index: vs8/ddraw/ddraw.vcproj
@@ -270,6 +270,26 @@
271271 </FileConfiguration>
272272 </File>
273273 <File
 274+ RelativePath="..\..\ddraw\fourcc.c"
 275+ >
 276+ <FileConfiguration
 277+ Name="Debug|Win32"
 278+ >
 279+ <Tool
 280+ Name="VCCLCompilerTool"
 281+ UsePrecompiledHeader="0"
 282+ />
 283+ </FileConfiguration>
 284+ <FileConfiguration
 285+ Name="Release|Win32"
 286+ >
 287+ <Tool
 288+ Name="VCCLCompilerTool"
 289+ UsePrecompiledHeader="0"
 290+ />
 291+ </FileConfiguration>
 292+ </File>
 293+ <File
274294 RelativePath="..\..\ddraw\glClassFactory.cpp"
275295 >
276296 </File>
@@ -576,6 +596,10 @@
577597 >
578598 </File>
579599 <File
 600+ RelativePath="..\..\ddraw\fourcc.h"
 601+ >
 602+ </File>
 603+ <File
580604 RelativePath="..\..\ddraw\glClassFactory.h"
581605 >
582606 </File>