Index: ddraw/ShaderGen2D.cpp |
— | — | @@ -57,86 +57,6 @@ |
58 | 58 | AND the dwFlags by 0xF2FAADFF before packing ROP index bits
|
59 | 59 | */
|
60 | 60 |
|
61 | | -const DWORD valid_rop_codes[256] = {
|
62 | | - 0x00000042,0x00010289,0x00020C89,0x000300AA,0x00040C88,0x000500A9,0x00060865,0x000702C5,
|
63 | | - 0x00080F08,0x00090245,0x000A0329,0x000B0B2A,0x000C0324,0x000D0B25,0x000E08A5,0x000F0001,
|
64 | | - 0x00100C85,0x001100A6,0x00120868,0x001302C8,0x00140869,0x001502C9,0x00165CCA,0x00171D54,
|
65 | | - 0x00180D59,0x00191CC8,0x001A06C5,0x001B0768,0x001C06CA,0x001D0766,0x001E01A5,0x001F0385,
|
66 | | - 0x00200F09,0x00210248,0x00220326,0x00230B24,0x00240D55,0x00251CC5,0x002606C8,0x00271868,
|
67 | | - 0x00280369,0x002916CA,0x002A0CC9,0x002B1D58,0x002C0784,0x002D060A,0x002E064A,0x002F0E2A,
|
68 | | - 0x0030032A,0x00310B28,0x00320688,0x00330008,0x003406C4,0x00351864,0x003601A8,0x00370388,
|
69 | | - 0x0038078A,0x00390604,0x003A0644,0x003B0E24,0x003C004A,0x003D18A4,0x003E1B24,0x003F00EA,
|
70 | | - 0x00400F0A,0x00410249,0x00420D5D,0x00431CC4,0x00440328,0x00450B29,0x004606C6,0x0047076A,
|
71 | | - 0x00480368,0x004916C5,0x004A0789,0x004B0605,0x004C0CC8,0x004D1954,0x004E0645,0x004F0E25,
|
72 | | - 0x00500325,0x00510B26,0x005206C9,0x00530764,0x005408A9,0x00550009,0x005601A9,0x00570389,
|
73 | | - 0x00580785,0x00590609,0x005A0049,0x005B18A9,0x005C0649,0x005D0E29,0x005E1B29,0x005F00E9,
|
74 | | - 0x00600365,0x006116C6,0x00620786,0x00630608,0x00640788,0x00650606,0x00660046,0x006718A8,
|
75 | | - 0x006858A6,0x00690145,0x006A01E9,0x006B178A,0x006C01E8,0x006D1785,0x006E1E28,0x006F0C65,
|
76 | | - 0x00700CC5,0x00711D5C,0x00720648,0x00730E28,0x00740646,0x00750E26,0x00761B28,0x007700E6,
|
77 | | - 0x007801E5,0x00791786,0x007A1E29,0x007B0C68,0x007C1E24,0x007D0C69,0x007E0955,0x007F03C9,
|
78 | | - 0x008003E9,0x00810975,0x00820C49,0x00831E04,0x00840C48,0x00851E05,0x008617A6,0x008701C5,
|
79 | | - 0x008800C6,0x00891B08,0x008A0E06,0x008B0666,0x008C0E08,0x008D0668,0x008E1D7C,0x008F0CE5,
|
80 | | - 0x00900C45,0x00911E08,0x009217A9,0x009301C4,0x009417AA,0x009501C9,0x00960169,0x0097588A,
|
81 | | - 0x00981888,0x00990066,0x009A0709,0x009B07A8,0x009C0704,0x009D07A6,0x009E16E6,0x009F0345,
|
82 | | - 0x00A000C9,0x00A11B05,0x00A20E09,0x00A30669,0x00A41885,0x00A50065,0x00A60706,0x00A707A5,
|
83 | | - 0x00A803A9,0x00A90189,0x00AA0029,0x00AB0889,0x00AC0744,0x00AD06E9,0x00AE0B06,0x00AF0229,
|
84 | | - 0x00B00E05,0x00B10665,0x00B21974,0x00B30CE8,0x00B4070A,0x00B507A9,0x00B616E9,0x00B70348,
|
85 | | - 0x00B8074A,0x00B906E6,0x00BA0B09,0x00BB0226,0x00BC1CE4,0x00BD0D7D,0x00BE0269,0x00BF08C9,
|
86 | | - 0x00C000CA,0x00C11B04,0x00C21884,0x00C3006A,0x00C40E04,0x00C50664,0x00C60708,0x00C707AA,
|
87 | | - 0x00C803A8,0x00C90184,0x00CA0749,0x00CB06E4,0x00CC0020,0x00CD0888,0x00CE0B08,0x00CF0224,
|
88 | | - 0x00D00E0A,0x00D1066A,0x00D20705,0x00D307A4,0x00D41D78,0x00D50CE9,0x00D616EA,0x00D70349,
|
89 | | - 0x00D80745,0x00D906E8,0x00DA1CE9,0x00DB0D75,0x00DC0B04,0x00DD0228,0x00DE0268,0x00DF08C8,
|
90 | | - 0x00E003A5,0x00E10185,0x00E20746,0x00E306EA,0x00E40748,0x00E506E5,0x00E61CE8,0x00E70D79,
|
91 | | - 0x00E81D74,0x00E95CE6,0x00EA02E9,0x00EB0849,0x00EC02E8,0x00ED0848,0x00EE0086,0x00EF0A08,
|
92 | | - 0x00F00021,0x00F10885,0x00F20B05,0x00F3022A,0x00F40B0A,0x00F50225,0x00F60265,0x00F708C5,
|
93 | | - 0x00F802E5,0x00F90845,0x00FA0089,0x00FB0A09,0x00FC008A,0x00FD0A0A,0x00FE02A9,0x00FF0062
|
94 | | -};
|
95 | | -
|
96 | | -/*
|
97 | | -1 - Source
|
98 | | -2 - Dest
|
99 | | -4 - Pattern */
|
100 | | -const DWORD rop_texture_usage[256] = {
|
101 | | - 0,7,7,5,7,6,7,7,7,7,6,7,5,7,7,4,
|
102 | | - 7,3,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
103 | | - 7,7,3,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
104 | | - 5,7,7,1,7,7,7,7,7,7,7,7,5,7,7,5,
|
105 | | - 7,7,7,7,3,7,7,7,7,7,7,7,7,7,7,7,
|
106 | | - 6,7,7,7,7,2,7,7,7,7,6,7,7,7,7,6,
|
107 | | - 7,7,7,7,7,7,3,7,7,7,7,7,7,7,7,7,
|
108 | | - 7,7,7,7,7,7,7,3,7,7,7,7,7,7,7,7,
|
109 | | - 7,7,7,7,7,7,7,7,3,7,7,7,7,7,7,7,
|
110 | | - 7,7,7,7,7,7,7,7,7,3,7,7,7,7,7,7,
|
111 | | - 6,7,7,7,7,6,7,7,7,7,2,7,7,7,7,6,
|
112 | | - 7,7,7,7,7,7,7,7,7,7,7,3,7,7,7,7,
|
113 | | - 5,7,7,5,7,7,7,7,7,7,7,7,1,7,7,5,
|
114 | | - 7,7,7,7,7,7,7,7,7,7,7,7,7,3,7,7,
|
115 | | - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,3,7,
|
116 | | - 4,7,7,5,7,6,7,7,7,7,6,7,5,7,7,0
|
117 | | -};
|
118 | | -
|
119 | | -const DWORD supported_rops[8] = {
|
120 | | - 0xFFFFFFFF,
|
121 | | - 0xFFFFFFFF,
|
122 | | - 0xFFFFFFFF,
|
123 | | - 0xFFFFFFFF,
|
124 | | - 0xFFFFFFFF,
|
125 | | - 0xFFFFFFFF,
|
126 | | - 0xFFFFFFFF,
|
127 | | - 0xFFFFFFFF
|
128 | | -};
|
129 | | -
|
130 | | -const DWORD supported_rops_gl2[8] = {
|
131 | | - 0x00008001,
|
132 | | - 0x00080000,
|
133 | | - 0x00200000,
|
134 | | - 0x00000000,
|
135 | | - 0x00000000,
|
136 | | - 0x00000400,
|
137 | | - 0x00001000,
|
138 | | - 0x80010000
|
139 | | -};
|
140 | | -
|
141 | 61 | static const char revheader[] =
|
142 | 62 | "//REV" STR(SHADER2DVERSION) "\n";
|
143 | 63 | static const char version_110[] = "#version 110\n";
|
Index: ddraw/const.c |
— | — | @@ -17,4 +17,83 @@ |
18 | 18 |
|
19 | 19 | #include "common.h"
|
20 | 20 |
|
21 | | -const RECT nullrect = { -1,-1,-1,-1 }; |
\ No newline at end of file |
| 21 | +const RECT nullrect = { -1,-1,-1,-1 };
|
| 22 | +const DWORD valid_rop_codes[256] = {
|
| 23 | + 0x00000042,0x00010289,0x00020C89,0x000300AA,0x00040C88,0x000500A9,0x00060865,0x000702C5,
|
| 24 | + 0x00080F08,0x00090245,0x000A0329,0x000B0B2A,0x000C0324,0x000D0B25,0x000E08A5,0x000F0001,
|
| 25 | + 0x00100C85,0x001100A6,0x00120868,0x001302C8,0x00140869,0x001502C9,0x00165CCA,0x00171D54,
|
| 26 | + 0x00180D59,0x00191CC8,0x001A06C5,0x001B0768,0x001C06CA,0x001D0766,0x001E01A5,0x001F0385,
|
| 27 | + 0x00200F09,0x00210248,0x00220326,0x00230B24,0x00240D55,0x00251CC5,0x002606C8,0x00271868,
|
| 28 | + 0x00280369,0x002916CA,0x002A0CC9,0x002B1D58,0x002C0784,0x002D060A,0x002E064A,0x002F0E2A,
|
| 29 | + 0x0030032A,0x00310B28,0x00320688,0x00330008,0x003406C4,0x00351864,0x003601A8,0x00370388,
|
| 30 | + 0x0038078A,0x00390604,0x003A0644,0x003B0E24,0x003C004A,0x003D18A4,0x003E1B24,0x003F00EA,
|
| 31 | + 0x00400F0A,0x00410249,0x00420D5D,0x00431CC4,0x00440328,0x00450B29,0x004606C6,0x0047076A,
|
| 32 | + 0x00480368,0x004916C5,0x004A0789,0x004B0605,0x004C0CC8,0x004D1954,0x004E0645,0x004F0E25,
|
| 33 | + 0x00500325,0x00510B26,0x005206C9,0x00530764,0x005408A9,0x00550009,0x005601A9,0x00570389,
|
| 34 | + 0x00580785,0x00590609,0x005A0049,0x005B18A9,0x005C0649,0x005D0E29,0x005E1B29,0x005F00E9,
|
| 35 | + 0x00600365,0x006116C6,0x00620786,0x00630608,0x00640788,0x00650606,0x00660046,0x006718A8,
|
| 36 | + 0x006858A6,0x00690145,0x006A01E9,0x006B178A,0x006C01E8,0x006D1785,0x006E1E28,0x006F0C65,
|
| 37 | + 0x00700CC5,0x00711D5C,0x00720648,0x00730E28,0x00740646,0x00750E26,0x00761B28,0x007700E6,
|
| 38 | + 0x007801E5,0x00791786,0x007A1E29,0x007B0C68,0x007C1E24,0x007D0C69,0x007E0955,0x007F03C9,
|
| 39 | + 0x008003E9,0x00810975,0x00820C49,0x00831E04,0x00840C48,0x00851E05,0x008617A6,0x008701C5,
|
| 40 | + 0x008800C6,0x00891B08,0x008A0E06,0x008B0666,0x008C0E08,0x008D0668,0x008E1D7C,0x008F0CE5,
|
| 41 | + 0x00900C45,0x00911E08,0x009217A9,0x009301C4,0x009417AA,0x009501C9,0x00960169,0x0097588A,
|
| 42 | + 0x00981888,0x00990066,0x009A0709,0x009B07A8,0x009C0704,0x009D07A6,0x009E16E6,0x009F0345,
|
| 43 | + 0x00A000C9,0x00A11B05,0x00A20E09,0x00A30669,0x00A41885,0x00A50065,0x00A60706,0x00A707A5,
|
| 44 | + 0x00A803A9,0x00A90189,0x00AA0029,0x00AB0889,0x00AC0744,0x00AD06E9,0x00AE0B06,0x00AF0229,
|
| 45 | + 0x00B00E05,0x00B10665,0x00B21974,0x00B30CE8,0x00B4070A,0x00B507A9,0x00B616E9,0x00B70348,
|
| 46 | + 0x00B8074A,0x00B906E6,0x00BA0B09,0x00BB0226,0x00BC1CE4,0x00BD0D7D,0x00BE0269,0x00BF08C9,
|
| 47 | + 0x00C000CA,0x00C11B04,0x00C21884,0x00C3006A,0x00C40E04,0x00C50664,0x00C60708,0x00C707AA,
|
| 48 | + 0x00C803A8,0x00C90184,0x00CA0749,0x00CB06E4,0x00CC0020,0x00CD0888,0x00CE0B08,0x00CF0224,
|
| 49 | + 0x00D00E0A,0x00D1066A,0x00D20705,0x00D307A4,0x00D41D78,0x00D50CE9,0x00D616EA,0x00D70349,
|
| 50 | + 0x00D80745,0x00D906E8,0x00DA1CE9,0x00DB0D75,0x00DC0B04,0x00DD0228,0x00DE0268,0x00DF08C8,
|
| 51 | + 0x00E003A5,0x00E10185,0x00E20746,0x00E306EA,0x00E40748,0x00E506E5,0x00E61CE8,0x00E70D79,
|
| 52 | + 0x00E81D74,0x00E95CE6,0x00EA02E9,0x00EB0849,0x00EC02E8,0x00ED0848,0x00EE0086,0x00EF0A08,
|
| 53 | + 0x00F00021,0x00F10885,0x00F20B05,0x00F3022A,0x00F40B0A,0x00F50225,0x00F60265,0x00F708C5,
|
| 54 | + 0x00F802E5,0x00F90845,0x00FA0089,0x00FB0A09,0x00FC008A,0x00FD0A0A,0x00FE02A9,0x00FF0062
|
| 55 | +};
|
| 56 | +
|
| 57 | +/*
|
| 58 | +1 - Source
|
| 59 | +2 - Dest
|
| 60 | +4 - Pattern */
|
| 61 | +const DWORD rop_texture_usage[256] = {
|
| 62 | + 0,7,7,5,7,6,7,7,7,7,6,7,5,7,7,4,
|
| 63 | + 7,3,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
| 64 | + 7,7,3,7,7,7,7,7,7,7,7,7,7,7,7,7,
|
| 65 | + 5,7,7,1,7,7,7,7,7,7,7,7,5,7,7,5,
|
| 66 | + 7,7,7,7,3,7,7,7,7,7,7,7,7,7,7,7,
|
| 67 | + 6,7,7,7,7,2,7,7,7,7,6,7,7,7,7,6,
|
| 68 | + 7,7,7,7,7,7,3,7,7,7,7,7,7,7,7,7,
|
| 69 | + 7,7,7,7,7,7,7,3,7,7,7,7,7,7,7,7,
|
| 70 | + 7,7,7,7,7,7,7,7,3,7,7,7,7,7,7,7,
|
| 71 | + 7,7,7,7,7,7,7,7,7,3,7,7,7,7,7,7,
|
| 72 | + 6,7,7,7,7,6,7,7,7,7,2,7,7,7,7,6,
|
| 73 | + 7,7,7,7,7,7,7,7,7,7,7,3,7,7,7,7,
|
| 74 | + 5,7,7,5,7,7,7,7,7,7,7,7,1,7,7,5,
|
| 75 | + 7,7,7,7,7,7,7,7,7,7,7,7,7,3,7,7,
|
| 76 | + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,3,7,
|
| 77 | + 4,7,7,5,7,6,7,7,7,7,6,7,5,7,7,0
|
| 78 | +};
|
| 79 | +
|
| 80 | +const DWORD supported_rops[8] = {
|
| 81 | + 0xFFFFFFFF,
|
| 82 | + 0xFFFFFFFF,
|
| 83 | + 0xFFFFFFFF,
|
| 84 | + 0xFFFFFFFF,
|
| 85 | + 0xFFFFFFFF,
|
| 86 | + 0xFFFFFFFF,
|
| 87 | + 0xFFFFFFFF,
|
| 88 | + 0xFFFFFFFF
|
| 89 | +};
|
| 90 | +
|
| 91 | +const DWORD supported_rops_gl2[8] = {
|
| 92 | + 0x00008001,
|
| 93 | + 0x00080000,
|
| 94 | + 0x00200000,
|
| 95 | + 0x00000000,
|
| 96 | + 0x00000000,
|
| 97 | + 0x00000400,
|
| 98 | + 0x00001000,
|
| 99 | + 0x80010000
|
| 100 | +};
|
Index: ddraw/const.h |
— | — | @@ -24,7 +24,16 @@ |
25 | 25 | #endif
|
26 | 26 |
|
27 | 27 | extern const RECT nullrect;
|
| 28 | + extern const DWORD valid_rop_codes[256];
|
| 29 | + extern const DWORD rop_texture_usage[256];
|
| 30 | + extern const DWORD supported_rops[8];
|
| 31 | + extern const DWORD supported_rops_gl2[8];
|
28 | 32 |
|
| 33 | +#ifdef _M_X64
|
| 34 | +#define _PTR_MASK 0xFFFFFFFFFFFFFFFFui64
|
| 35 | +#else
|
| 36 | +#define _PTR_MASK 0xFFFFFFFF
|
| 37 | +#endif
|
29 | 38 | #ifdef __cplusplus
|
30 | 39 | }
|
31 | 40 | #endif
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | #include "ddraw.h"
|
28 | 28 | #include "ShaderGen3D.h"
|
29 | 29 | #include "matrix.h"
|
| 30 | +#include "util.h"
|
30 | 31 |
|
31 | 32 | extern "C" {
|
32 | 33 |
|
— | — | @@ -96,8 +97,10 @@ |
97 | 98 | * Pointer to glRenderer object
|
98 | 99 | * @param cmdsize
|
99 | 100 | * Requested size for command buffer
|
| 101 | + * @return
|
| 102 | + * TRUE if ending command, FALSE otherwise
|
100 | 103 | */
|
101 | | -void CheckCmdBuffer(glRenderer *This, DWORD cmdsize, DWORD uploadsize, DWORD vertexsize, DWORD indexsize)
|
| 104 | +BOOL CheckCmdBuffer(glRenderer *This, DWORD cmdsize, DWORD uploadsize, DWORD vertexsize, DWORD indexsize)
|
102 | 105 | {
|
103 | 106 | BOOL over = FALSE;
|
104 | 107 | if (cmdsize)
|
— | — | @@ -120,7 +123,12 @@ |
121 | 124 | if ((This->state.cmd->write_ptr_index + indexsize) > This->state.cmd->indices->size)
|
122 | 125 | over = TRUE;
|
123 | 126 | }
|
124 | | - if (over) glRenderer_EndCommand(This, FALSE, TRUE);
|
| 127 | + if (over)
|
| 128 | + {
|
| 129 | + glRenderer_EndCommand(This, FALSE, TRUE);
|
| 130 | + return TRUE;
|
| 131 | + }
|
| 132 | + else return FALSE;
|
125 | 133 | }
|
126 | 134 |
|
127 | 135 | /**
|
— | — | @@ -136,12 +144,8 @@ |
137 | 145 | * @return
|
138 | 146 | * Return value specific to command, DD_OK if succeeded.
|
139 | 147 | */
|
140 | | -HRESULT glRenderer_AddCommand(glRenderer *This, BYTE *command, BOOL inner)
|
| 148 | +HRESULT glRenderer_AddCommand(glRenderer *This, QueueCmd *cmd, BOOL inner)
|
141 | 149 | {
|
142 | | - DWORD opcode = (DWORD)*command;
|
143 | | - DWORD cmdsize = (DWORD)*((unsigned char*)command + 4);
|
144 | | - BYTE *cmddata = command + 8;
|
145 | | - SetWndCommand *wndcmd = (SetWndCommand*)cmddata;
|
146 | 150 | HRESULT error;
|
147 | 151 | // Command specific variables
|
148 | 152 | RECT wndrect;
|
— | — | @@ -149,7 +153,7 @@ |
150 | 154 | LONG_PTR winstyle, winstyleex;
|
151 | 155 | BOOL restart_cmd = FALSE;
|
152 | 156 | if (!inner) EnterCriticalSection(&This->cs);
|
153 | | - switch (opcode)
|
| 157 | + switch (cmd->Generic.opcode)
|
154 | 158 | {
|
155 | 159 | case OP_NULL:
|
156 | 160 | error = DD_OK; // No need to write to the command buffer
|
— | — | @@ -164,54 +168,74 @@ |
165 | 169 | break;
|
166 | 170 | case OP_CREATE: // Creates a texture. Needs to sync in order to return the
|
167 | 171 | // texture object.
|
168 | | - CheckCmdBuffer(This, cmdsize + 8, 0, 0, 0);
|
169 | | - memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, command, cmdsize + 8);
|
170 | | - This->state.cmd->write_ptr_cmd += (cmdsize + 8);
|
| 172 | + CheckCmdBuffer(This, cmd->MakeTexture.size + 8, 0, 0, 0);
|
| 173 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, cmd, cmd->MakeTexture.size + 8);
|
| 174 | + This->state.cmd->write_ptr_cmd += (cmd->MakeTexture.size + 8);
|
171 | 175 | error = DD_OK;
|
172 | 176 | break;
|
173 | 177 | case OP_UPLOAD: // This one can fill the upload buffer fast; upload buffer is
|
174 | 178 | // initialized to 2x primary for <=128MB, 1.5x for <=256MB, or
|
175 | 179 | // 1.25x for >256MB upload buffer size.
|
176 | | - ((UploadTextureCmd*)command)->texturesize =
|
177 | | - ((UploadTextureCmd*)command)->texture->levels[((UploadTextureCmd*)command)->level].ddsd.lPitch
|
178 | | - * ((UploadTextureCmd*)command)->texture->levels[((UploadTextureCmd*)command)->level].ddsd.dwHeight;
|
179 | | - ((UploadTextureCmd*)command)->content =
|
180 | | - (BYTE*)((UploadTextureCmd*)command)->texture->levels[((UploadTextureCmd*)command)->level].buffer;
|
181 | | - ((UploadTextureCmd*)command)->offset = This->state.cmd->write_ptr_upload;
|
182 | | - CheckCmdBuffer(This, cmdsize + 8, 0, 0, 0);
|
183 | | - memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, command, cmdsize + 8);
|
184 | | - This->state.cmd->write_ptr_cmd += (cmdsize + 8);
|
| 180 | + cmd->UploadTexture.texturesize =
|
| 181 | + cmd->UploadTexture.texture->levels[cmd->UploadTexture.level].ddsd.lPitch
|
| 182 | + * cmd->UploadTexture.texture->levels[cmd->UploadTexture.level].ddsd.dwHeight;
|
| 183 | + cmd->UploadTexture.content =
|
| 184 | + (BYTE*)cmd->UploadTexture.texture->levels[cmd->UploadTexture.level].buffer;
|
| 185 | + cmd->UploadTexture.offset = This->state.cmd->write_ptr_upload;
|
| 186 | + CheckCmdBuffer(This, cmd->UploadTexture.size + 8, 0, 0, 0);
|
| 187 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, cmd, cmd->UploadTexture.size + 8);
|
| 188 | + This->state.cmd->write_ptr_cmd += (cmd->UploadTexture.size + 8);
|
185 | 189 | memcpy(This->state.cmd->uploadbuffer + This->state.cmd->write_ptr_upload,
|
186 | | - ((UploadTextureCmd*)command)->content, ((UploadTextureCmd*)command)->texturesize);
|
| 190 | + cmd->UploadTexture.content, cmd->UploadTexture.texturesize);
|
187 | 191 | error = DD_OK;
|
188 | 192 | break;
|
189 | 193 | case OP_DOWNLOAD: // Downloads a texture. Needs to sync in order to receive the
|
190 | 194 | // texture data.
|
191 | | - CheckCmdBuffer(This, cmdsize + 8, 0, 0, 0);
|
192 | | - memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, command, cmdsize + 8);
|
193 | | - This->state.cmd->write_ptr_cmd += (cmdsize + 8);
|
| 195 | + CheckCmdBuffer(This, cmd->DownloadTexture.size + 8, 0, 0, 0);
|
| 196 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, cmd, cmd->DownloadTexture.size + 8);
|
| 197 | + This->state.cmd->write_ptr_cmd += (cmd->DownloadTexture.size + 8);
|
194 | 198 | error = DD_OK;
|
195 | 199 | break;
|
196 | 200 | case OP_DELETETEX: // Deletes a texture. Non-blocking becuase frontend has
|
197 | 201 | // forgotten the texture.
|
198 | | - CheckCmdBuffer(This, cmdsize + 8, 0, 0, 0);
|
199 | | - memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, command, cmdsize + 8);
|
200 | | - This->state.cmd->write_ptr_cmd += (cmdsize + 8);
|
| 202 | + CheckCmdBuffer(This, cmd->DeleteTexture.size + 8, 0, 0, 0);
|
| 203 | + memcpy(This->state.cmd->cmdbuffer + This->state.cmd->write_ptr_cmd, cmd, cmd->DeleteTexture.size + 8);
|
| 204 | + This->state.cmd->write_ptr_cmd += (cmd->DeleteTexture.size + 8);
|
201 | 205 | error = DD_OK;
|
202 | 206 | break;
|
203 | 207 | case OP_BLT: // Perform a Blt() operation, issuing necessary commands to set it
|
204 | 208 | // up.
|
205 | | - // Compare last command minus rotation
|
206 | | - if (This->state.last_cmd == OP_BLT)
|
| 209 | + // Check if last major command is Blt().
|
| 210 | + if (This->state.last_cmd.Generic.opcode == OP_BLT)
|
207 | 211 | {
|
208 | | - // Generate vertices
|
209 | | - // Rotate vertices if necessary
|
210 | | - // Write vertices to VBO
|
211 | | - // Update command in buffer
|
| 212 | + // Compare last command minus rotation
|
| 213 | + if (((cmd->Blt.cmd.flags & 0xBFABFFF) == (This->state.last_cmd.Blt.cmd.flags & 0xBFABFFF)) &&
|
| 214 | + !comp_bltfx(&This->state.last_cmd.Blt.cmd.bltfx, &cmd->Blt.cmd.bltfx, cmd->Blt.cmd.flags))
|
| 215 | + restart_cmd = FALSE;
|
| 216 | + else restart_cmd = TRUE;
|
| 217 | + if(!restart_cmd)
|
| 218 | + {
|
| 219 | + // Generate vertices
|
| 220 | + // Rotate vertices if necessary
|
| 221 | + // Write vertices to VBO
|
| 222 | + // Update command in buffer
|
| 223 | + }
|
| 224 | +
|
212 | 225 | }
|
213 | 226 | if(restart_cmd)
|
214 | 227 | {
|
| 228 | + BOOL usedest = FALSE;
|
| 229 | + BOOL usepattern = FALSE;
|
| 230 | + if ((cmd->Blt.cmd.bltfx.dwSize == sizeof(DDBLTFX)) && (cmd->Blt.cmd.flags & DDBLT_ROP))
|
| 231 | + {
|
| 232 | + if (rop_texture_usage[(cmd->Blt.cmd.bltfx.dwROP >> 16) & 0xFF] & 2) usedest = TRUE;
|
| 233 | + if (rop_texture_usage[(cmd->Blt.cmd.bltfx.dwROP >> 16) & 0xFF] & 4) usepattern = TRUE;
|
| 234 | + }
|
215 | 235 | // Run backbuffer if using dest
|
| 236 | + if (usedest)
|
| 237 | + {
|
| 238 | +
|
| 239 | + }
|
216 | 240 | // Set Src texture (Unit 8)
|
217 | 241 | // Set Dest texture (Unit 9)
|
218 | 242 | // Set Pattern texture (Unit 10)
|
— | — | @@ -318,7 +342,7 @@ |
319 | 343 | error = DDERR_INVALIDPARAMS;
|
320 | 344 | break;
|
321 | 345 | }
|
322 | | - This->state.last_cmd = opcode;
|
| 346 | + This->state.last_cmd.Generic.opcode = cmd->Generic.opcode;
|
323 | 347 | if (!inner) LeaveCriticalSection(&This->cs);
|
324 | 348 | return error;
|
325 | 349 | }
|
Index: ddraw/glRenderer.h |
— | — | @@ -145,7 +145,7 @@ |
146 | 146 | size_t scenesize, scenesizevertex, scenesizeindex;
|
147 | 147 | } glRenderer;
|
148 | 148 |
|
149 | | -HRESULT glRenderer_AddCommand(glRenderer *This, BYTE *command, BOOL inner);
|
| 149 | +HRESULT glRenderer_AddCommand(glRenderer *This, QueueCmd *command, BOOL inner);
|
150 | 150 | void glRenderer_Init(glRenderer *This, int width, int height, int bpp, BOOL fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd);
|
151 | 151 | void glRenderer_Delete(glRenderer *This);
|
152 | 152 | DWORD glRenderer_GetBPP(glRenderer *This);
|
Index: ddraw/struct.h |
— | — | @@ -447,14 +447,6 @@ |
448 | 448 | size_t read_ptr_index;
|
449 | 449 | } CommandBuffer;
|
450 | 450 |
|
451 | | -typedef struct RenderState
|
452 | | -{
|
453 | | - CommandBuffer *cmd;
|
454 | | - DWORD last_cmd;
|
455 | | - BYTE *last_cmd_start;
|
456 | | - BltCommand last_blt;
|
457 | | -} RenderState;
|
458 | | -
|
459 | 451 | typedef struct RenderTarget
|
460 | 452 | {
|
461 | 453 | glTexture *target;
|
Index: ddraw/struct_command.h |
— | — | @@ -19,6 +19,11 @@ |
20 | 20 | #ifndef __STRUCT_COMMAND_H
|
21 | 21 | #define __STRUCT_COMMAND_H
|
22 | 22 |
|
| 23 | +typedef struct GenericCmd
|
| 24 | +{
|
| 25 | + DWORD opcode;
|
| 26 | + DWORD size;
|
| 27 | +} GenericCmd;
|
23 | 28 | typedef struct MakeTextureCmd
|
24 | 29 | {
|
25 | 30 | DWORD opcode;
|
— | — | @@ -226,6 +231,7 @@ |
227 | 232 |
|
228 | 233 | typedef union QueueCmd
|
229 | 234 | {
|
| 235 | + GenericCmd Generic;
|
230 | 236 | MakeTextureCmd MakeTexture;
|
231 | 237 | UploadTextureCmd UploadTexture;
|
232 | 238 | DownloadTextureCmd DownloadTexture;
|
— | — | @@ -253,4 +259,11 @@ |
254 | 260 | MIN_STORAGE_CMD MIN_STORAGE;
|
255 | 261 | } QueueCmd;
|
256 | 262 |
|
| 263 | +typedef struct RenderState
|
| 264 | +{
|
| 265 | + CommandBuffer *cmd;
|
| 266 | + QueueCmd last_cmd;
|
| 267 | + BYTE *last_cmd_start;
|
| 268 | +} RenderState;
|
| 269 | +
|
257 | 270 | #endif //__STRUCT_COMMAND_H |
\ No newline at end of file |
Index: ddraw/util.c |
— | — | @@ -15,12 +15,16 @@ |
16 | 16 | // License along with this library; if not, write to the Free Software
|
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 |
|
| 19 | +// Note: Requires a SSE2 and AVX compatible compiler.
|
| 20 | +
|
19 | 21 | #include "common.h"
|
20 | 22 | #include "util.h"
|
| 23 | +#include "const.h"
|
21 | 24 |
|
22 | 25 | #ifdef _MSC_VER
|
23 | 26 | #pragma optimize("g", off)
|
24 | 27 | #endif
|
| 28 | +extern DXGLCFG dxglcfg;
|
25 | 29 | /**
|
26 | 30 | * Tests if a pointer is valid for reading from. Uses SEH on Visual C++,
|
27 | 31 | * non-recommended Windows API on other systems.
|
— | — | @@ -95,4 +99,63 @@ |
96 | 100 | if (IsBadWritePtr(ptr, 1)) return 0;
|
97 | 101 | else return 1;
|
98 | 102 | #endif
|
99 | | -} |
\ No newline at end of file |
| 103 | +}
|
| 104 | +
|
| 105 | +void AndMem(void *dest, const void *a, const void *b, size_t size)
|
| 106 | +{
|
| 107 | + // Buffer must be multiple of 4 and should be DWORD aligned
|
| 108 | + size_t i;
|
| 109 | + for (i = 0; i < size>>2; i++)
|
| 110 | + {
|
| 111 | + ((DWORD*)dest)[i] = ((DWORD*)a)[i] & ((DWORD*)b)[i];
|
| 112 | + }
|
| 113 | +}
|
| 114 | +
|
| 115 | +const DDBLTFX cmp_fx =
|
| 116 | +{
|
| 117 | + 0xFFFFFFFF, // dwSize
|
| 118 | + 0x00000180, // dwDDFX & (DDBLTFX_ZBUFFERBASEDEST | DDBLTFX_ZBUFFERRANGE)
|
| 119 | + 0xFFFFFFFF, // dwROP
|
| 120 | + 0xFFFFFFFF, // dwDDROP
|
| 121 | + 0x00000000, // dwRotationAngle
|
| 122 | + 0xFFFFFFFF, // dwZBufferOpCode
|
| 123 | + 0x00000000, // dwZBufferLow
|
| 124 | + 0x00000000, // dwZBufferHigh
|
| 125 | + 0x00000000, // dwZBufferBaseDest
|
| 126 | + 0xFFFFFFFF, // dwZDestConstBitDepth
|
| 127 | + (LPDIRECTDRAWSURFACE)0x00000000, // dwZDestConst and lpDDSZBufferDest
|
| 128 | + 0xFFFFFFFF, // dwZSrcConstBitDepth
|
| 129 | + (LPDIRECTDRAWSURFACE)0x00000000, // dwZSrcConst and lpDDSZBufferSrc
|
| 130 | + 0xFFFFFFFF, // dwAlphaEdgeBlendBitDepth
|
| 131 | + 0x00000000, // dwAlphaEdgeBlend
|
| 132 | + 0x00000000, // dwReserved
|
| 133 | + 0xFFFFFFFF, // dwAlphaDestConstBitDepth
|
| 134 | + (LPDIRECTDRAWSURFACE)0x00000000, // dwAlphaDestConst and lpDDSAlphaDest
|
| 135 | + 0xFFFFFFFF, // dwAlphaSrcConstBitDepth
|
| 136 | + (LPDIRECTDRAWSURFACE)0x00000000, // dwAlphaSrcConst and lpDDSAlphaSrc
|
| 137 | + 0x00000000, // dwFillColor, dwFillDepth, dwFillPixel, and lpDDSPattern
|
| 138 | + {0,0}, // ddckDestColorkey
|
| 139 | + {0,0} // ddckSrcColorkey
|
| 140 | +};
|
| 141 | +BOOL comp_bltfx(DDBLTFX *a, DDBLTFX *b, DWORD flags)
|
| 142 | +{
|
| 143 | + DDBLTFX comp_mask;
|
| 144 | + DDBLTFX comp_a;
|
| 145 | + DDBLTFX comp_b;
|
| 146 | + if (!a && !b) return FALSE; // If both have no BLTFX
|
| 147 | + if ((!a && b) || (a && !b)) return TRUE; // One has BLTFX but not other
|
| 148 | + memcpy(&comp_mask, &cmp_fx, sizeof(DDBLTFX));
|
| 149 | + if(flags & DDBLT_ROP)
|
| 150 | + {
|
| 151 | + if (rop_texture_usage[(a->dwROP >> 16) & 0xFF] & 4)
|
| 152 | + comp_mask.lpDDSPattern = _PTR_MASK;
|
| 153 | + }
|
| 154 | + if (flags & DDBLT_ZBUFFERDESTOVERRIDE) comp_mask.lpDDSZBufferDest = _PTR_MASK;
|
| 155 | + if (flags & DDBLT_ZBUFFERSRCOVERRIDE) comp_mask.lpDDSZBufferSrc = _PTR_MASK;
|
| 156 | + if (flags & DDBLT_ALPHADESTSURFACEOVERRIDE) comp_mask.lpDDSAlphaDest = _PTR_MASK;
|
| 157 | + if (flags & DDBLT_ALPHASRCSURFACEOVERRIDE) comp_mask.lpDDSAlphaSrc = _PTR_MASK;
|
| 158 | + AndMem(&comp_a, a, &comp_mask, sizeof(DDBLTFX));
|
| 159 | + AndMem(&comp_b, b, &comp_mask, sizeof(DDBLTFX));
|
| 160 | + if (!memcmp(&comp_a, &comp_b, sizeof(DDBLTFX))) return FALSE;
|
| 161 | + else return TRUE;
|
| 162 | +} |
\ No newline at end of file |
Index: ddraw/util.h |
— | — | @@ -25,6 +25,8 @@ |
26 | 26 |
|
27 | 27 | char IsReadablePointer(void *ptr, LONG_PTR size);
|
28 | 28 | char IsWritablePointer(void *ptr, LONG_PTR size, BOOL preserve);
|
| 29 | +void AndMem(void *dest, const void *a, const void *b, size_t size);
|
| 30 | +BOOL comp_bltfx(DDBLTFX *a, DDBLTFX *b, DWORD flags);
|
29 | 31 |
|
30 | 32 | #ifdef __cplusplus
|
31 | 33 | }
|