Index: ddraw/glRenderer.cpp |
— | — | @@ -141,12 +141,19 @@ |
142 | 142 | * First DWORD: Command ID, see glRenderer.h
|
143 | 143 | * Second DWORD: Size of command data, rounded up to nearest DWORD
|
144 | 144 | * Third DWORD and beyond: command data
|
| 145 | + * @param inner
|
| 146 | + * TRUE if called from within this function.
|
| 147 | + * @param wait
|
| 148 | + * TRUE to force the queue to wait until completion
|
145 | 149 | * @return
|
146 | 150 | * Return value specific to command, DD_OK if succeeded.
|
147 | 151 | */
|
148 | | -HRESULT glRenderer_AddCommand(glRenderer *This, QueueCmd *cmd, BOOL inner)
|
| 152 | +HRESULT glRenderer_AddCommand(glRenderer *This, QueueCmd *cmd, BOOL inner, BOOL wait)
|
149 | 153 | {
|
150 | 154 | HRESULT error;
|
| 155 | + QueueCmd tmp_cmd;
|
| 156 | + RECT r1, r2;
|
| 157 | + int i;
|
151 | 158 | // Command specific variables
|
152 | 159 | RECT wndrect;
|
153 | 160 | int screenx, screeny;
|
— | — | @@ -213,6 +220,10 @@ |
214 | 221 | !comp_bltfx(&This->state.last_cmd.Blt.cmd.bltfx, &cmd->Blt.cmd.bltfx, cmd->Blt.cmd.flags))
|
215 | 222 | restart_cmd = FALSE;
|
216 | 223 | else restart_cmd = TRUE;
|
| 224 | + if ((cmd->Blt.cmd.bltfx.dwSize == sizeof(DDBLTFX)) && (cmd->Blt.cmd.flags & DDBLT_ROP))
|
| 225 | + {
|
| 226 | + if (rop_texture_usage[(cmd->Blt.cmd.bltfx.dwROP >> 16) & 0xFF] & 2) restart_cmd = TRUE;
|
| 227 | + }
|
217 | 228 | if(!restart_cmd)
|
218 | 229 | {
|
219 | 230 | // Generate vertices
|
— | — | @@ -234,13 +245,78 @@ |
235 | 246 | // Run backbuffer if using dest
|
236 | 247 | if (usedest)
|
237 | 248 | {
|
238 | | -
|
| 249 | + r1.left = r1.top = 0;
|
| 250 | + if (memcmp(&cmd->Blt.cmd.destrect, &nullrect, sizeof(RECT)))
|
| 251 | + {
|
| 252 | + r1.right = cmd->Blt.cmd.destrect.right - cmd->Blt.cmd.destrect.left;
|
| 253 | + r1.bottom = cmd->Blt.cmd.destrect.bottom - cmd->Blt.cmd.destrect.top;
|
| 254 | + }
|
| 255 | + else
|
| 256 | + {
|
| 257 | + r1.right = cmd->Blt.cmd.dest->levels[0].ddsd.dwWidth;
|
| 258 | + r1.bottom = cmd->Blt.cmd.dest->levels[0].ddsd.dwHeight;
|
| 259 | + }
|
| 260 | + // Check backbuffer size and resize
|
| 261 | + if((This->backbuffer->levels[0].ddsd.dwWidth < r1.right) ||
|
| 262 | + (This->backbuffer->levels[0].ddsd.dwHeight < r1.bottom))
|
| 263 | + {
|
| 264 | + DDSURFACEDESC2 newdesc = This->backbuffer->levels[0].ddsd;
|
| 265 | + if (newdesc.dwWidth < r1.right) newdesc.dwWidth = r1.right;
|
| 266 | + if (newdesc.dwHeight < r1.bottom) newdesc.dwHeight = r1.bottom;
|
| 267 | + tmp_cmd.SetTextureSurfaceDesc.opcode = OP_SETTEXTURESURFACEDESC;
|
| 268 | + tmp_cmd.SetTextureSurfaceDesc.size = sizeof(SetTextureSurfaceDescCmd);
|
| 269 | + tmp_cmd.SetTextureSurfaceDesc.level = 0;
|
| 270 | + tmp_cmd.SetTextureSurfaceDesc.desc = newdesc;
|
| 271 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, TRUE);
|
| 272 | + }
|
| 273 | + tmp_cmd.Blt.opcode = OP_BLT;
|
| 274 | + tmp_cmd.Blt.size = sizeof(BltCmd);
|
| 275 | + tmp_cmd.Blt.cmd.flags = 0;
|
| 276 | + tmp_cmd.Blt.cmd.destrect = r1;
|
| 277 | + tmp_cmd.Blt.cmd.srcrect = cmd->Blt.cmd.destrect;
|
| 278 | + tmp_cmd.Blt.cmd.src = cmd->Blt.cmd.dest;
|
| 279 | + tmp_cmd.Blt.cmd.dest = This->backbuffer;
|
| 280 | + tmp_cmd.Blt.cmd.srclevel = cmd->Blt.cmd.srclevel;
|
| 281 | + tmp_cmd.Blt.cmd.destlevel = 0;
|
| 282 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
239 | 283 | }
|
| 284 | + i = 0;
|
| 285 | + tmp_cmd.SetTexture.opcode = OP_SETTEXTURE;
|
| 286 | + tmp_cmd.SetTexture.size = sizeof(SetTextureCmd);
|
240 | 287 | // Set Src texture (Unit 8)
|
| 288 | + if (cmd->Blt.cmd.src)
|
| 289 | + {
|
| 290 | + tmp_cmd.SetTexture.texstage[i].stage = 8;
|
| 291 | + tmp_cmd.SetTexture.texstage[i].texture = cmd->Blt.cmd.src;
|
| 292 | + tmp_cmd.SetTexture.size += (sizeof(DWORD) + sizeof(glTexture*));
|
| 293 | + i++;
|
| 294 | + }
|
241 | 295 | // Set Dest texture (Unit 9)
|
| 296 | + tmp_cmd.SetTexture.texstage[i].stage = 9;
|
| 297 | + tmp_cmd.SetTexture.texstage[i].texture = tmp_cmd.Blt.cmd.dest;
|
242 | 298 | // Set Pattern texture (Unit 10)
|
| 299 | + if (usepattern)
|
| 300 | + {
|
| 301 | + tmp_cmd.SetTexture.size += (sizeof(DWORD) + sizeof(glTexture*));
|
| 302 | + tmp_cmd.SetTexture.texstage[i].stage = 10;
|
| 303 | + tmp_cmd.SetTexture.texstage[i].texture = cmd->Blt.cmd.pattern;
|
| 304 | + }
|
243 | 305 | // Set clipper texture (Unit 11)
|
| 306 | + if (cmd->Blt.cmd.dest->stencil)
|
| 307 | + {
|
| 308 | + tmp_cmd.SetTexture.size += (sizeof(DWORD) + sizeof(glTexture*));
|
| 309 | + tmp_cmd.SetTexture.texstage[i].stage = 11;
|
| 310 | + tmp_cmd.SetTexture.texstage[i].texture = cmd->Blt.cmd.dest->stencil;
|
| 311 | + }
|
| 312 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
244 | 313 | // Set shader mode and params
|
| 314 | + tmp_cmd.SetShader2D.opcode = OP_SETSHADER2D;
|
| 315 | + tmp_cmd.SetShader2D.size = sizeof(SetShader2DCmd);
|
| 316 | + tmp_cmd.SetShader2D.type = 1;
|
| 317 | + if ((cmd->Blt.cmd.bltfx.dwSize == sizeof(DDBLTFX)) && (cmd->Blt.cmd.flags & DDBLT_ROP))
|
| 318 | + tmp_cmd.SetShader2D.id = PackROPBits(cmd->Blt.cmd.bltfx.dwROP, cmd->Blt.cmd.flags);
|
| 319 | + else tmp_cmd.SetShader2D.id = cmd->Blt.cmd.flags & 0xF2FAADFF;
|
| 320 | + glRenderer_AddCommand(This, &tmp_cmd, TRUE, FALSE);
|
245 | 321 | // Set render target
|
246 | 322 | // Set viewport
|
247 | 323 | // Generate vertices
|
— | — | @@ -338,6 +414,15 @@ |
339 | 415 | case OP_INITTEXTURESTAGE: // Initializes a texture stage.
|
340 | 416 | error = DDERR_CURRENTLYNOTAVAIL;
|
341 | 417 | break;
|
| 418 | + case OP_SETTEXTURESURFACEDESC:
|
| 419 | + error = DDERR_CURRENTLYNOTAVAIL;
|
| 420 | + break;
|
| 421 | + case OP_SETSHADER2D:
|
| 422 | + error = DDERR_CURRENTLYNOTAVAIL;
|
| 423 | + break;
|
| 424 | + case OP_SETSHADER:
|
| 425 | + error = DDERR_CURRENTLYNOTAVAIL;
|
| 426 | + break;
|
342 | 427 | default:
|
343 | 428 | error = DDERR_INVALIDPARAMS;
|
344 | 429 | break;
|
Index: ddraw/glRenderer.h |
— | — | @@ -92,6 +92,9 @@ |
93 | 93 | #define OP_MAKETEXTUREPRIMARY 25
|
94 | 94 | #define OP_ENDCOMMAND 26
|
95 | 95 | #define OP_INITTEXTURESTAGE 27
|
| 96 | +#define OP_SETTEXTURESURFACEDESC 28
|
| 97 | +#define OP_SETSHADER2D 29
|
| 98 | +#define OP_SETSHADER 30
|
96 | 99 |
|
97 | 100 | extern const DWORD renderstate_default[153];
|
98 | 101 | extern const TEXTURESTAGE texstagedefault0;
|
— | — | @@ -145,7 +148,7 @@ |
146 | 149 | size_t scenesize, scenesizevertex, scenesizeindex;
|
147 | 150 | } glRenderer;
|
148 | 151 |
|
149 | | -HRESULT glRenderer_AddCommand(glRenderer *This, QueueCmd *command, BOOL inner);
|
| 152 | +HRESULT glRenderer_AddCommand(glRenderer *This, QueueCmd *command, BOOL inner, BOOL wait);
|
150 | 153 | void glRenderer_Init(glRenderer *This, int width, int height, int bpp, BOOL fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd);
|
151 | 154 | void glRenderer_Delete(glRenderer *This);
|
152 | 155 | DWORD glRenderer_GetBPP(glRenderer *This);
|
Index: ddraw/struct_command.h |
— | — | @@ -223,6 +223,28 @@ |
224 | 224 | DWORD count;
|
225 | 225 | DWORD stage[1];
|
226 | 226 | } InitTextureStageCmd;
|
| 227 | +typedef struct SetTextureSurfaceDescCmd
|
| 228 | +{
|
| 229 | + DWORD opcode;
|
| 230 | + DWORD size;
|
| 231 | + GLint level;
|
| 232 | + DDSURFACEDESC2 desc;
|
| 233 | +} SetTextureSurfaceDescCmd;
|
| 234 | +typedef struct SetShader2DCmd
|
| 235 | +{
|
| 236 | + DWORD opcode;
|
| 237 | + DWORD size;
|
| 238 | + int type; // 0 for builtin, 1 for 2D, 2 for 3D (INVALID, use full command)
|
| 239 | + __int64 id;
|
| 240 | +};
|
| 241 | +typedef struct SetShaderCmd
|
| 242 | +{
|
| 243 | + DWORD opcode;
|
| 244 | + DWORD size;
|
| 245 | + int type; // 0 for builtin, 1 for 2D, 2 for 3D
|
| 246 | + __int64 id;
|
| 247 | + __int64 texstate[8];
|
| 248 | +};
|
227 | 249 |
|
228 | 250 | typedef struct MIN_STORAGE_Cmd
|
229 | 251 | {
|
— | — | @@ -256,6 +278,9 @@ |
257 | 279 | MakeTexturePrimaryCmd MakeTexturePrimary;
|
258 | 280 | DXGLBreakCmd DXGLBreak;
|
259 | 281 | InitTextureStageCmd InitTextureStage;
|
| 282 | + SetTextureSurfaceDescCmd SetTextureSurfaceDesc;
|
| 283 | + SetShader2DCmd SetShader2D;
|
| 284 | + SetShaderCmd SetShader;
|
260 | 285 | MIN_STORAGE_CMD MIN_STORAGE;
|
261 | 286 | } QueueCmd;
|
262 | 287 |
|