DXGL r674 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r673‎ | r674 | r675 >
Date:00:55, 27 July 2016
Author:admin
Status:new
Tags:
Comment:
Re-enable clippers.
Isolate clipper update from API interfaces.
Remove some interface headers from glRenderer.
Modified paths:
  • /ddraw/glDirectDrawClipper.cpp (modified) (history)
  • /ddraw/glDirectDrawClipper.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/glRenderer.h (modified) (history)

Diff [purge]

Index: ddraw/glDirectDrawClipper.cpp
@@ -434,7 +434,7 @@
435435 if(!This->cliplist) memfail = true;
436436 if(!memfail) This->vertices = (BltVertex*)malloc(This->maxsize*4*sizeof(BltVertex));
437437 if(!This->vertices) memfail = true;
438 - if(!memfail) This->indices = (GLshort*)malloc(This->maxsize*6*sizeof(GLshort));
 438+ if(!memfail) This->indices = (GLushort*)malloc(This->maxsize*6*sizeof(GLushort));
439439 if(!This->indices) memfail = true;
440440 if(memfail)
441441 {
@@ -457,7 +457,7 @@
458458 memfail = false;
459459 RGNDATA *newcliplist = NULL;
460460 BltVertex *newvertices = NULL;
461 - GLshort *newindices = NULL;
 461+ GLushort *newindices = NULL;
462462 newcliplist = (RGNDATA*)realloc(This->cliplist,sizeof(RGNDATAHEADER)+(lpClipList->rdh.nCount*sizeof(RECT)));
463463 if(!newcliplist) memfail = true;
464464 else This->cliplist = newcliplist;
@@ -464,7 +464,7 @@
465465 if(!memfail) newvertices = (BltVertex*)realloc(This->vertices,lpClipList->rdh.nCount*4*sizeof(BltVertex));
466466 if(!newvertices) memfail = true;
467467 else This->vertices = newvertices;
468 - if(!memfail) newindices = (GLshort*)realloc(This->indices,lpClipList->rdh.nCount*6*sizeof(GLshort));
 468+ if(!memfail) newindices = (GLushort*)realloc(This->indices,lpClipList->rdh.nCount*6*sizeof(GLushort));
469469 if(!newindices) memfail = true;
470470 else This->indices = newindices;
471471 if(memfail) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
Index: ddraw/glDirectDrawClipper.h
@@ -33,7 +33,7 @@
3434 HWND hWnd;
3535 RGNDATA *cliplist;
3636 BltVertex *vertices;
37 - GLshort *indices;
 37+ GLushort *indices;
3838 size_t clipsize;
3939 size_t maxsize;
4040 bool hascliplist;
Index: ddraw/glDirectDrawSurface.cpp
@@ -698,7 +698,7 @@
699699 cmd.flags |= 0x40000000;
700700 }
701701 glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
702 -/* if (clipper)
 702+ if (clipper)
703703 {
704704 if (!clipper->hWnd)
705705 {
@@ -705,12 +705,13 @@
706706 if (!clipper->clipsize) TRACE_RET(HRESULT, 23, DDERR_NOCLIPLIST);
707707 if (clipper->dirty)
708708 {
709 - glRenderer_UpdateClipper(ddInterface->renderer, this);
 709+ glRenderer_UpdateClipper(ddInterface->renderer, this->clipper->texture, this->clipper->indices,
 710+ this->clipper->vertices,this->clipper->clipsize, this->ddsd.dwWidth, this->ddsd.dwHeight);
710711 clipper->dirty = false;
711712 }
712713 dwFlags |= 0x10000000;
713714 }
714 - }*/
 715+ }
715716 if (this->clipper && !(this->clipper->hWnd)) cmd.flags |= 0x10000000;
716717 if (lpDDBltFx) cmd.bltfx = *lpDDBltFx;
717718 if (dwFlags & DDBLT_DEPTHFILL)
Index: ddraw/glRenderer.cpp
@@ -22,12 +22,9 @@
2323 #include "timer.h"
2424 #include "glDirectDraw.h"
2525 #include "glDirectDrawSurface.h"
26 -#include "glDirectDrawPalette.h"
2726 #include "glRenderWindow.h"
2827 #include "glRenderer.h"
2928 #include "glDirect3DDevice.h"
30 -#include "glDirect3DLight.h"
31 -#include "glDirectDrawClipper.h"
3229 #include "ddraw.h"
3330 #include "ShaderGen3D.h"
3431 #include "matrix.h"
@@ -602,16 +599,32 @@
603600 }
604601
605602 /**
606 - * Updates the clipper stencil for a surface.
 603+ * Updates a clipping stencil.
607604 * @param This
608605 * Pointer to glRenderer object
609 - * @param surface
610 - * Surface to update clipper stencil on
 606+ * @param stencil
 607+ * Stencil texture to update
 608+ * @param indices
 609+ * Pointer to array of indices representing the clip list
 610+ * @param vertices
 611+ * Pointer to array of vertices representing the clip list
 612+ * @param count
 613+ * Number of entries in the clip list
 614+ * @param width
 615+ * Width of surface the stencil is attached to
 616+ * @param height
 617+ * Height of surface the stencil is attached to
611618 */
612 -void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface)
 619+void glRenderer_UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
 620+ GLsizei count, GLsizei width, GLsizei height)
613621 {
614622 EnterCriticalSection(&This->cs);
615 - This->inputs[0] = surface;
 623+ This->inputs[0] = stencil;
 624+ This->inputs[1] = indices;
 625+ This->inputs[2] = vertices;
 626+ This->inputs[3] = (void*)count;
 627+ This->inputs[4] = (void*)width;
 628+ This->inputs[5] = (void*)height;
616629 This->opcode = OP_UPDATECLIPPER;
617630 SetEvent(This->start);
618631 WaitForSingleObject(This->busy,INFINITE);
@@ -967,7 +980,8 @@
968981 glRenderer__DeleteFBO(This,(FBO*)This->inputs[0]);
969982 break;
970983 case OP_UPDATECLIPPER:
971 - glRenderer__UpdateClipper(This,(glDirectDrawSurface7*)This->inputs[0]);
 984+ glRenderer__UpdateClipper(This,(glTexture*)This->inputs[0], (GLushort*)This->inputs[1],
 985+ (BltVertex*)This->inputs[2], (GLsizei)This->inputs[3], (GLsizei)This->inputs[4], (GLsizei)This->inputs[5]);
972986 break;
973987 case OP_DEPTHFILL:
974988 glRenderer__DepthFill(This, (BltCommand*)This->inputs[0], (glTexture*)This->inputs[1], (GLint)This->inputs[2]);
@@ -2411,35 +2425,35 @@
24122426 SetEvent(This->busy);
24132427 }
24142428
2415 -void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface)
 2429+void glRenderer__UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
 2430+ GLsizei count, GLsizei width, GLsizei height)
24162431 {
24172432 GLfloat view[4];
24182433 DDSURFACEDESC2 ddsd;
2419 - if ((surface->ddsd.dwWidth != surface->texture->stencil->levels[0].ddsd.dwWidth) ||
2420 - (surface->ddsd.dwHeight != surface->texture->stencil->levels[0].ddsd.dwHeight))
 2434+ if ((width != stencil->levels[0].ddsd.dwWidth) || (height != stencil->levels[0].ddsd.dwHeight))
24212435 {
24222436 ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
24232437 ddsd.dwSize = sizeof(DDSURFACEDESC2);
2424 - ddsd.dwWidth = surface->ddsd.dwWidth;
2425 - ddsd.dwHeight = surface->ddsd.dwHeight;
 2438+ ddsd.dwWidth = width;
 2439+ ddsd.dwHeight = height;
24262440 ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
2427 - glTexture__SetSurfaceDesc(surface->texture->stencil, &ddsd);
 2441+ glTexture__SetSurfaceDesc(stencil, &ddsd);
24282442 }
2429 - glUtil_SetFBOTextures(This->util, &surface->texture->stencil->levels[0].fbo, surface->texture->stencil, NULL, 0, 0, FALSE);
 2443+ glUtil_SetFBOTextures(This->util, &stencil->levels[0].fbo, stencil, NULL, 0, 0, FALSE);
24302444 view[0] = view[2] = 0;
2431 - view[1] = (GLfloat)surface->ddsd.dwWidth;
2432 - view[3] = (GLfloat)surface->ddsd.dwHeight;
2433 - glUtil_SetViewport(This->util, 0, 0, surface->ddsd.dwWidth, surface->ddsd.dwHeight);
 2445+ view[1] = width;
 2446+ view[3] = height;
 2447+ glUtil_SetViewport(This->util, 0, 0, width, height);
24342448 glClear(GL_COLOR_BUFFER_BIT);
24352449 ShaderManager_SetShader(This->shaders,PROG_CLIPSTENCIL,NULL,0);
24362450 This->ext->glUniform4f(This->shaders->shaders[PROG_CLIPSTENCIL].view,view[0],view[1],view[2],view[3]);
24372451 glUtil_EnableArray(This->util, This->shaders->shaders[PROG_CLIPSTENCIL].pos, TRUE);
24382452 This->ext->glVertexAttribPointer(This->shaders->shaders[PROG_CLIPSTENCIL].pos,
2439 - 2,GL_FLOAT,false,sizeof(BltVertex),&surface->clipper->vertices[0].x);
 2453+ 2,GL_FLOAT,false,sizeof(BltVertex),&vertices[0].x);
24402454 glUtil_SetCull(This->util, D3DCULL_NONE);
24412455 glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
2442 - This->ext->glDrawRangeElements(GL_TRIANGLES, 0, (6 * surface->clipper->clipsize) - 1,
2443 - 6 * surface->clipper->clipsize, GL_UNSIGNED_SHORT, surface->clipper->indices);
 2456+ This->ext->glDrawRangeElements(GL_TRIANGLES, 0, (6 * count) - 1,
 2457+ 6 * count, GL_UNSIGNED_SHORT, indices);
24442458 glUtil_SetFBO(This->util, NULL);
24452459 SetEvent(This->busy);
24462460 }
Index: ddraw/glRenderer.h
@@ -172,7 +172,8 @@
173173 HRESULT glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
174174 DWORD indexcount, DWORD flags);
175175 void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo);
176 -void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
 176+void glRenderer_UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
 177+ GLsizei count, GLsizei width, GLsizei height);
177178 unsigned int glRenderer_GetScanLine(glRenderer *This);
178179 HRESULT glRenderer_DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel);
179180 void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
@@ -203,7 +204,8 @@
204205 void glRenderer__Flush(glRenderer *This);
205206 void glRenderer__SetWnd(glRenderer *This, int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd, BOOL devwnd);
206207 void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo);
207 -void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
 208+void glRenderer__UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
 209+ GLsizei count, GLsizei width, GLsizei height);
208210 void glRenderer__DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel);
209211 void glRenderer__SetFogColor(glRenderer *This, DWORD color);
210212 void glRenderer__SetFogStart(glRenderer *This, GLfloat start);