| Index: ddraw/ShaderManager.cpp |
| — | — | @@ -47,49 +47,6 @@ |
| 48 | 48 | gl_FragColor = texel; \n\
|
| 49 | 49 | } ";
|
| 50 | 50 |
|
| 51 | | -const char frag_ColorKey[] = "\
|
| 52 | | -#version 110\n\
|
| 53 | | -uniform sampler2D tex0;\n\
|
| 54 | | -uniform ivec3 ckey;\n\
|
| 55 | | -void main (void)\n\
|
| 56 | | -{\n\
|
| 57 | | - vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
|
| 58 | | - ivec3 comp = ivec3(texture2D(tex0, vec2(gl_TexCoord[0]))*255.5);\n\
|
| 59 | | - if (comp == ckey)\n\
|
| 60 | | - discard;\n\
|
| 61 | | - gl_FragColor = value;\n\
|
| 62 | | -} ";
|
| 63 | | -
|
| 64 | | -const char frag_ColorKeyMask[] = "\
|
| 65 | | -#version 110\n\
|
| 66 | | -uniform sampler2D tex0;\n\
|
| 67 | | -uniform ivec4 ckey;\n\
|
| 68 | | -void main (void)\n\
|
| 69 | | -{\n\
|
| 70 | | - vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
|
| 71 | | - ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.5);\n\
|
| 72 | | - if (comp == ckey)\n\
|
| 73 | | - gl_FragColor[0] = 1.0;\n\
|
| 74 | | - else gl_FragColor[0] = 0.0;\n\
|
| 75 | | -} ";
|
| 76 | | -
|
| 77 | | -const char frag_2ColorKey[] = "\
|
| 78 | | -#version 110\n\
|
| 79 | | -uniform sampler2D tex0;\n\
|
| 80 | | -uniform sampler2D tex1;\n\
|
| 81 | | -uniform ivec4 ckey;\n\
|
| 82 | | -void main (void)\n\
|
| 83 | | -{\n\
|
| 84 | | - vec4 value = texture2D(tex0, vec2(gl_TexCoord[0]));\n\
|
| 85 | | - ivec4 comp = ivec4(texture2D(tex0, vec2(gl_TexCoord[0]))*255.5);\n\
|
| 86 | | - if (comp == ckey)\n\
|
| 87 | | - discard;\n\
|
| 88 | | - ivec4 comp2 = ivec4(texture2D(tex1,vec2(gl_TexCoord[1]))*255.5);\n\
|
| 89 | | - if(comp2[0] == 0)\n\
|
| 90 | | - discard;\n\
|
| 91 | | - gl_FragColor = value;\n\
|
| 92 | | -} ";
|
| 93 | | -
|
| 94 | 51 | const char frag_clipstencil[] = "\
|
| 95 | 52 | #version 110\n\
|
| 96 | 53 | void main (void)\n\
|
| — | — | @@ -123,9 +80,6 @@ |
| 124 | 81 | {
|
| 125 | 82 | {0,0, vert_ortho, frag_Texture, 0,-1,-1,-1},
|
| 126 | 83 | {0,0, vert_ortho, frag_Pal256, 0,-1,-1,-1},
|
| 127 | | - {0,0, vert_ortho, frag_ColorKey, 0,-1,-1,-1},
|
| 128 | | - {0,0, vert_ortho, frag_ColorKeyMask, 0,-1,-1,-1},
|
| 129 | | - {0,0, vert_ortho, frag_2ColorKey, 0,-1,-1,-1},
|
| 130 | 84 | {0,0, vert_ortho, frag_clipstencil, 0,-1,-1,-1}
|
| 131 | 85 | };
|
| 132 | 86 | const int SHADER_END = __LINE__ - 4;
|
| Index: ddraw/ShaderManager.h |
| — | — | @@ -27,10 +27,7 @@ |
| 28 | 28 |
|
| 29 | 29 | #define PROG_TEXTURE 0
|
| 30 | 30 | #define PROG_PAL256 1
|
| 31 | | -#define PROG_CKEY 2
|
| 32 | | -#define PROG_CKEYMASK 3
|
| 33 | | -#define PROG_2CKEY 4
|
| 34 | | -#define PROG_CLIPSTENCIL 5
|
| | 31 | +#define PROG_CLIPSTENCIL 2
|
| 35 | 32 |
|
| 36 | 33 | struct TEXTURESTAGE;
|
| 37 | 34 | struct ShaderGen3D;
|
| Index: ddraw/glRenderer.cpp |
| — | — | @@ -203,20 +203,62 @@ |
| 204 | 204 | break;
|
| 205 | 205 | case OP_BLT: // Perform a Blt() operation, issuing necessary commands to set it
|
| 206 | 206 | // up.
|
| | 207 | + // Compare last command minus rotation
|
| 207 | 208 | if (This->state.last_cmd == OP_BLT)
|
| 208 | 209 | {
|
| 209 | | -
|
| | 210 | + // Generate vertices
|
| | 211 | + // Rotate vertices if necessary
|
| | 212 | + // Write vertices to VBO
|
| | 213 | + // Update command in buffer
|
| 210 | 214 | }
|
| 211 | 215 | if(restart_cmd)
|
| 212 | 216 | {
|
| 213 | | -
|
| | 217 | + // Run backbuffer if using dest
|
| | 218 | + // Set Src texture (Unit 8)
|
| | 219 | + // Set Dest texture (Unit 9)
|
| | 220 | + // Set Pattern texture (Unit 10)
|
| | 221 | + // Set clipper texture (Unit 11)
|
| | 222 | + // Set shader mode and params
|
| | 223 | + // Set render target
|
| | 224 | + // Set viewport
|
| | 225 | + // Generate vertices
|
| | 226 | + // Rotate vertices if necessary
|
| | 227 | + // Write vertices to VBO
|
| | 228 | + // Write command to buffer
|
| 214 | 229 | }
|
| 215 | 230 | error = DDERR_CURRENTLYNOTAVAIL;
|
| 216 | 231 | break;
|
| 217 | 232 | case OP_DRAWSCREEN: // Draws the screen. Flip command buffer after executing.
|
| | 233 | + // If 8 bit scaled linear:
|
| | 234 | + // Set Src texture (Unit 8) to primary
|
| | 235 | + // Set Palette texture (Unit 9) to palette
|
| | 236 | + // Set shader mode and params
|
| | 237 | + // Set render target to backbuffer
|
| | 238 | + // Set viewport to backbuffer
|
| | 239 | + // Generate vertices
|
| | 240 | + // Write vertices to FBO
|
| | 241 | + // Write Palette draw command to buffer
|
| | 242 | + // Set Src texture (Unit 8) to backbuffer
|
| | 243 | + // Set shader mode and params
|
| | 244 | + // Set render target to null
|
| | 245 | + // Set viewport to window buffer
|
| | 246 | + // Generate vertices
|
| | 247 | + // Write vertices to VBO
|
| | 248 | + // Write Draw command to buffer
|
| | 249 | + // If 8-bit unscaled or scaled nearest:
|
| | 250 | + // Set Src texture (Unit 8) to primary
|
| | 251 | + // Set Palette texture (Unit 9) to palette
|
| | 252 | + // Set shader mode and params
|
| | 253 | + // Set render target to null
|
| | 254 | + // Set viewport to window buffer
|
| | 255 | + // Generate vertices
|
| | 256 | + // Write vertices to VBO
|
| | 257 | + // Write Palette Draw command to buffer
|
| 218 | 258 | error = DDERR_UNSUPPORTED;
|
| 219 | 259 | break;
|
| 220 | 260 | case OP_INITD3D: // Initialize renderer for Direct3D rendering.
|
| | 261 | + // Set initial viewport
|
| | 262 | + // Post InitD3D command
|
| 221 | 263 | error = DDERR_CURRENTLYNOTAVAIL;
|
| 222 | 264 | break;
|
| 223 | 265 | case OP_CLEAR: // Clears full renderbuffer or one or more rects.
|
| — | — | @@ -562,6 +604,11 @@ |
| 563 | 605 | */
|
| 564 | 606 | HRESULT glRenderer_Blt(glRenderer *This, BltCommand *cmd)
|
| 565 | 607 | {
|
| | 608 | + /*BltCmd bltcmd;
|
| | 609 | + bltcmd.opcode = OP_DELETE;
|
| | 610 | + bltcmd.zise = sizeof(BltCmd) - 8;
|
| | 611 | + bltcmd.cmd = *cmd;
|
| | 612 | + glRenderer_AddCommand(This, (BYTE*)&bltcmd);*/
|
| 566 | 613 | EnterCriticalSection(&This->cs);
|
| 567 | 614 | RECT r,r2;
|
| 568 | 615 | if(((cmd->dest->levels[0].ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
| — | — | @@ -590,15 +637,21 @@ |
| 591 | 638 | * Texture to use as the primary
|
| 592 | 639 | * @param paltex
|
| 593 | 640 | * Texture that contains the color palette for 8-bit modes
|
| 594 | | - * @param dest
|
| 595 | | - * Destination surface to be updated
|
| 596 | | - * @param src
|
| 597 | | - * Source surface to be updated
|
| 598 | 641 | * @param vsync
|
| 599 | 642 | * Vertical sync count
|
| | 643 | + * @param previous
|
| | 644 | + * Texture previously used as primary before a flip
|
| 600 | 645 | */
|
| 601 | 646 | void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, glTexture *previous)
|
| 602 | 647 | {
|
| | 648 | + /*DrawScreenCmd cmd;
|
| | 649 | + cmd.opcode = OP_DRAWSCREEN;
|
| | 650 | + cmd.size = sizeof(DrawScreenCmd)-8;
|
| | 651 | + cmd.texture = texture;
|
| | 652 | + cmd.paltex =paltex;
|
| | 653 | + cmd.vsync = vsync;
|
| | 654 | + cmd.previous = previous;
|
| | 655 | + glRenderer_AddCommand(This, (BYTE*)&cmd);*/
|
| 603 | 656 | EnterCriticalSection(&This->cs);
|
| 604 | 657 | This->inputs[0] = texture;
|
| 605 | 658 | This->inputs[1] = paltex;
|
| — | — | @@ -616,9 +669,21 @@ |
| 617 | 670 | * Pointer to glRenderer object
|
| 618 | 671 | * @param zbuffer
|
| 619 | 672 | * Nonzero if a Z buffer is present.
|
| | 673 | + * @param x
|
| | 674 | + * Width of the initial viewport
|
| | 675 | + * @param y
|
| | 676 | + * Height of the initial viewport
|
| 620 | 677 | */
|
| 621 | 678 | void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y)
|
| 622 | 679 | {
|
| | 680 | + /*
|
| | 681 | + InitD3DCmd cmd;
|
| | 682 | + cmd.opcode = OP_INITD3D;
|
| | 683 | + cmd.size = sizeof(InitD3DCmd)-8;
|
| | 684 | + cmd.zbuffer = zbuffer;
|
| | 685 | + cmd.x = x;
|
| | 686 | + cmd.y = y;
|
| | 687 | + glRenderer_AddCommand(This, (BYTE*)&bltcmd);*/
|
| 623 | 688 | EnterCriticalSection(&This->cs);
|
| 624 | 689 | This->inputs[0] = (void*)zbuffer;
|
| 625 | 690 | This->inputs[1] = (void*)x;
|
| — | — | @@ -640,6 +705,12 @@ |
| 641 | 706 | */
|
| 642 | 707 | HRESULT glRenderer_Clear(glRenderer *This, ClearCommand *cmd)
|
| 643 | 708 | {
|
| | 709 | + /*
|
| | 710 | + ClearCmd cmd;
|
| | 711 | + clearcmd.opcode = OP_CLEAR;
|
| | 712 | + clearcmd.size = sizeof(ClearCmd) - 8;
|
| | 713 | + clearcmd.cmd = *cmd;
|
| | 714 | + glRenderer_AddCommand(This, (BYTE*)&clearcmd); */
|
| 644 | 715 | EnterCriticalSection(&This->cs);
|
| 645 | 716 | This->inputs[0] = cmd;
|
| 646 | 717 | This->opcode = OP_CLEAR;
|
| — | — | @@ -651,7 +722,7 @@ |
| 652 | 723 |
|
| 653 | 724 | /**
|
| 654 | 725 | * Instructs the OpenGL driver to send all queued commands to the GPU.
|
| 655 | | - * @param Thisf
|
| | 726 | + * @param This
|
| 656 | 727 | * Pointer to glRenderer object
|
| 657 | 728 | */
|
| 658 | 729 | void glRenderer_Flush(glRenderer *This)
|
| — | — | @@ -1404,12 +1475,12 @@ |
| 1405 | 1476 | }
|
| 1406 | 1477 | BufferObject_Create(&This->pbo, This->ext, This->util);
|
| 1407 | 1478 | BufferObject_SetData(This->pbo, GL_PIXEL_PACK_BUFFER, width*height * 4, NULL, GL_STREAM_READ);
|
| 1408 | | - /*ZeroMemory(&This->state, sizeof(RenderState));
|
| | 1479 | + ZeroMemory(&This->state, sizeof(RenderState));
|
| 1409 | 1480 | This->state.cmd = &This->cmd1;
|
| 1410 | 1481 | glRenderer__InitCommandBuffer(This, &This->cmd1, width * height * (NextMultipleOf8(bpp) / 8));
|
| 1411 | 1482 | glRenderer__InitCommandBuffer(This, &This->cmd2, width * height * (NextMultipleOf8(bpp) / 8));
|
| 1412 | 1483 | BufferObject_Map(This->cmd1.vertices, GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
| 1413 | | - BufferObject_Map(This->cmd1.indices, GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);*/
|
| | 1484 | + BufferObject_Map(This->cmd1.indices, GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
|
| 1414 | 1485 | TRACE_SYSINFO();
|
| 1415 | 1486 | return TRUE;
|
| 1416 | 1487 | }
|
| — | — | @@ -1987,10 +2058,10 @@ |
| 1988 | 2059 | ShaderManager_SetShader(This->shaders,PROG_PAL256,NULL,0);
|
| 1989 | 2060 | progtype = PROG_PAL256;
|
| 1990 | 2061 | glTexture__Upload(paltex, 0);
|
| 1991 | | - This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
|
| 1992 | | - This->ext->glUniform1i(This->shaders->shaders[progtype].pal,1);
|
| 1993 | | - glUtil_SetTexture(This->util,0,texture);
|
| 1994 | | - glUtil_SetTexture(This->util,1,paltex);
|
| | 2062 | + This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,8);
|
| | 2063 | + This->ext->glUniform1i(This->shaders->shaders[progtype].pal,9);
|
| | 2064 | + glUtil_SetTexture(This->util,8,texture);
|
| | 2065 | + glUtil_SetTexture(This->util,9,paltex);
|
| 1995 | 2066 | if(dxglcfg.scalingfilter)
|
| 1996 | 2067 | {
|
| 1997 | 2068 | glRenderer__DrawBackbuffer(This,&texture,texture->bigwidth,texture->bigheight,progtype);
|
| — | — | @@ -2001,8 +2072,8 @@ |
| 2002 | 2073 | }
|
| 2003 | 2074 | if(This->ext->GLEXT_ARB_sampler_objects)
|
| 2004 | 2075 | {
|
| 2005 | | - glTexture__SetFilter(NULL, 0, GL_NEAREST, GL_NEAREST, This);
|
| 2006 | | - glTexture__SetFilter(NULL, 1, GL_NEAREST, GL_NEAREST, This);
|
| | 2076 | + glTexture__SetFilter(NULL, 8, GL_NEAREST, GL_NEAREST, This);
|
| | 2077 | + glTexture__SetFilter(NULL, 9, GL_NEAREST, GL_NEAREST, This);
|
| 2007 | 2078 | }
|
| 2008 | 2079 | }
|
| 2009 | 2080 | else
|
| — | — | @@ -2009,8 +2080,8 @@ |
| 2010 | 2081 | {
|
| 2011 | 2082 | ShaderManager_SetShader(This->shaders,PROG_TEXTURE,NULL,0);
|
| 2012 | 2083 | progtype = PROG_TEXTURE;
|
| 2013 | | - glUtil_SetTexture(This->util,0,texture);
|
| 2014 | | - This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,0);
|
| | 2084 | + glUtil_SetTexture(This->util,8,texture);
|
| | 2085 | + This->ext->glUniform1i(This->shaders->shaders[progtype].tex0,8);
|
| 2015 | 2086 | }
|
| 2016 | 2087 | if (dxglcfg.scalingfilter && This->ext->GLEXT_ARB_sampler_objects)
|
| 2017 | 2088 | glTexture__SetFilter(NULL, 0, GL_LINEAR, GL_LINEAR, This);
|
| — | — | @@ -2198,7 +2269,8 @@ |
| 2199 | 2270 | memcpy(&This->renderstate, &renderstate_default, 153 * sizeof(DWORD));
|
| 2200 | 2271 | This->texstages[0] = texstagedefault0;
|
| 2201 | 2272 | This->texstages[1] = This->texstages[2] = This->texstages[3] = This->texstages[4] =
|
| 2202 | | - This->texstages[5] = This->texstages[6] = This->texstages[7] = texstagedefault1;
|
| | 2273 | + This->texstages[5] = This->texstages[6] = This->texstages[7] = This->texstages[8] =
|
| | 2274 | + This->texstages[9] = This->texstages[10] = This->texstages[11] = texstagedefault1;
|
| 2203 | 2275 | This->viewport.dwX = 0;
|
| 2204 | 2276 | This->viewport.dwY = 0;
|
| 2205 | 2277 | This->viewport.dwWidth = x;
|
| Index: ddraw/glRenderer.h |
| — | — | @@ -152,7 +152,7 @@ |
| 153 | 153 | ShaderManager *shaders;
|
| 154 | 154 | DWORD renderstate[153];
|
| 155 | 155 | SHADERSTATE shaderstate3d;
|
| 156 | | - TEXTURESTAGE texstages[8];
|
| | 156 | + TEXTURESTAGE texstages[12];
|
| 157 | 157 | D3DMATERIAL7 material;
|
| 158 | 158 | D3DLIGHT7 lights[8];
|
| 159 | 159 | D3DMATRIX transform[24];
|
| Index: ddraw/struct_command.h |
| — | — | @@ -53,8 +53,28 @@ |
| 54 | 54 | DWORD opcode;
|
| 55 | 55 | DWORD size;
|
| 56 | 56 | BltCommand cmd;
|
| 57 | | - DWORD count;
|
| 58 | | - GLsizeiptr vertex_start;
|
| 59 | | - GLsizeiptr index_start;
|
| 60 | 57 | } BltCmd;
|
| | 58 | +typedef struct DrawScreenCmd
|
| | 59 | +{
|
| | 60 | + DWORD opcode;
|
| | 61 | + DWORD size;
|
| | 62 | + glTexture *texture;
|
| | 63 | + glTexture *paltex;
|
| | 64 | + GLint vsync;
|
| | 65 | + glTexture *previous;
|
| | 66 | +};
|
| | 67 | +typedef struct InitD3DCmd
|
| | 68 | +{
|
| | 69 | + DWORD opcode;
|
| | 70 | + DWORD size;
|
| | 71 | + int zbuffer;
|
| | 72 | + int x;
|
| | 73 | + int y;
|
| | 74 | +};
|
| | 75 | +typedef struct ClearCmd
|
| | 76 | +{
|
| | 77 | + DWORD opcode;
|
| | 78 | + DWORD size;
|
| | 79 | + ClearCommand cmd;
|
| | 80 | +};
|
| 61 | 81 | #endif //__STRUCT_COMMAND_H |
| \ No newline at end of file |