DXGL r463 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r462‎ | r463 | r464 >
Date:23:47, 13 July 2014
Author:admin
Status:new
Tags:
Comment:
Some ShaderGen2D work towards ROP support.
Add ROP test to dxgltest.
Modified paths:
  • /common/x16.ico (modified) (history)
  • /ddraw/ShaderGen2D.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /dxgltest/MultiDD.cpp (modified) (history)
  • /dxgltest/Tests2D.cpp (modified) (history)
  • /dxgltest/Tests3D.cpp (modified) (history)
  • /dxgltest/dxgltest.cpp (modified) (history)
  • /dxgltest/surfacegen.cpp (modified) (history)
  • /dxgltest/surfacegen.h (modified) (history)
  • /dxgltest/tests.h (modified) (history)

Diff [purge]

Index: common/x16.ico
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: ddraw/ShaderGen2D.cpp
@@ -116,14 +116,14 @@
117117 };
118118
119119 const DWORD supported_rops[8] = {
 120+ 0x00000001,
120121 0x00000000,
121122 0x00000000,
122123 0x00000000,
123124 0x00000000,
124125 0x00000000,
125 - 0x00000000,
126126 0x00001000,
127 - 0x00000000
 127+ 0x80000000
128128 };
129129
130130 const DWORD supported_rops_gl2[8] = {
@@ -196,7 +196,7 @@
197197
198198 // ROP Operations
199199 static const char *op_ROP[256] = {
200 -"dest = ivec4(0);",//00 BLACKNESS
 200+"pixel = ivec4(0);",//00 BLACKNESS
201201 "",
202202 "",
203203 "",
@@ -400,7 +400,7 @@
401401 "",
402402 "",
403403 "",
404 -"dest = src;\n",//CC SRCCOPY
 404+"",//CC SRCCOPY pixel=pixel
405405 "",
406406 "",
407407 "",//CF
@@ -451,11 +451,11 @@
452452 "",
453453 "",
454454 "",
455 -"dest = ivec4(255);\n",//FF WHITENESS
 455+"pixel = ivec4(255);\n",//FF WHITENESS
456456 };
457457
458458 static const char *op_ROP_float[256] = {
459 -"gl_FragColor = vec4(0.0);",//00 BLACKNESS
 459+"pixel = ivec4(0);",//00 BLACKNESS
460460 "",
461461 "",
462462 "",
@@ -659,7 +659,7 @@
660660 "",
661661 "",
662662 "",
663 -"gl_FragColor = pixel;\n",//CC SRCCOPY
 663+"",//CC SRCCOPY pixel=pixel
664664 "",
665665 "",
666666 "",//CF
@@ -710,12 +710,12 @@
711711 "",
712712 "",
713713 "",
714 -"gl_FragColor = vec4(1.0);\n",//FF WHITENESS
 714+"pixel = ivec4(255);\n",//FF WHITENESS
715715 };
716716
717717 DWORD PackROPBits(DWORD rop, DWORD flags)
718718 {
719 - DWORD out = rop & 0xF2FAADFF;
 719+ DWORD out = flags & 0xF2FAADFF;
720720 if (rop & 0x10000) out |= 1 << 9;
721721 if (rop & 0x20000) out |= 1 << 12;
722722 if (rop & 0x40000) out |= 1 << 14;
@@ -727,6 +727,20 @@
728728 return out;
729729 }
730730
 731+DWORD UnpackROPBits(DWORD flags)
 732+{
 733+ DWORD out = 0;
 734+ if (flags & (1 << 9)) out |= 1;
 735+ if (flags & (1 << 12)) out |= 2;
 736+ if (flags & (1 << 14)) out |= 4;
 737+ if (flags & (1 << 16)) out |= 8;
 738+ if (flags & (1 << 18)) out |= 16;
 739+ if (flags & (1 << 24)) out |= 32;
 740+ if (flags & (1 << 26)) out |= 64;
 741+ if (flags & (1 << 27)) out |= 128;
 742+ return out;
 743+}
 744+
731745 void ShaderGen2D_Init(ShaderGen2D *gen, glExtensions *ext, ShaderManager *shaderman)
732746 {
733747 gen->ext = ext;
@@ -759,6 +773,7 @@
760774 void ShaderGen2D_CreateShader2D(ShaderGen2D *gen, int index, DWORD id)
761775 {
762776 STRING tmp;
 777+ DWORD rop;
763778 tmp.ptr = NULL;
764779 BOOL intproc = FALSE;
765780 gen->genshaders2D[index].shader.vsrc.ptr = NULL;
@@ -775,13 +790,13 @@
776791 if (gen->ext->glver_major >= 3)
777792 {
778793 String_Append(vsrc, version_130);
779 - intproc = true;
 794+ intproc = TRUE;
780795 }
781796 else if (gen->ext->GLEXT_EXT_gpu_shader4)
782797 {
783798 String_Append(vsrc, version_110);
784799 String_Append(vsrc, ext_shader4);
785 - intproc = true;
 800+ intproc = TRUE;
786801 }
787802 else String_Append(vsrc, version_110);
788803 }
@@ -788,7 +803,7 @@
789804 else String_Append(vsrc, version_110);
790805 String_Append(vsrc, idheader);
791806 String_Append(vsrc, idstring);
792 -
 807+
793808 // Attributes
794809 String_Append(vsrc, attr_xy);
795810 if (id & DDBLT_COLORFILL) String_Append(vsrc, attr_rgb);
@@ -856,7 +871,7 @@
857872 if (!(id & DDBLT_COLORFILL)) String_Append(fsrc, unif_srctex);
858873 if (id & 0x10000000) String_Append(fsrc, unif_stenciltex);
859874 if (id & DDBLT_KEYSRC) String_Append(fsrc, unif_ckeysrc);
860 -
 875+
861876 // Variables
862877 String_Append(fsrc, var_pixel);
863878
@@ -866,6 +881,12 @@
867882 if (id & DDBLT_COLORFILL) String_Append(fsrc, op_color);
868883 else String_Append(fsrc, op_src);
869884 if (id & DDBLT_KEYSRC) String_Append(fsrc, op_ckeysrc);
 885+ if (id & DDBLT_ROP)
 886+ {
 887+ rop = UnpackROPBits(id);
 888+ if (intproc) String_Append(fsrc, op_ROP[rop]);
 889+ else String_Append(fsrc, op_ROP_float[rop]);
 890+ }
870891
871892 String_Append(fsrc, op_destout);
872893 String_Append(fsrc, mainend);
Index: ddraw/glDirectDrawSurface.cpp
@@ -612,6 +612,7 @@
613613 TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,26,lpSrcRect,9,dwFlags,14,lpDDBltFx);
614614 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
615615 if((dwFlags & DDBLT_COLORFILL) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
 616+ if((dwFlags & DDBLT_ROP) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
616617 glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
617618 if(dirty & 1)
618619 {
Index: dxgltest/MultiDD.cpp
@@ -153,6 +153,24 @@
154154 return error;
155155 }
156156
 157+HRESULT MultiDirectDraw::GetCaps(LPDDCAPS lpDDDriverCaps, LPDDCAPS lpDDHELCaps)
 158+{
 159+ switch (version)
 160+ {
 161+ case 1:
 162+ return dd1->GetCaps(lpDDDriverCaps, lpDDHELCaps);
 163+ case 2:
 164+ case 3:
 165+ return dd2->GetCaps(lpDDDriverCaps, lpDDHELCaps);
 166+ case 4:
 167+ return dd4->GetCaps(lpDDDriverCaps, lpDDHELCaps);
 168+ case 7:
 169+ return dd7->GetCaps(lpDDDriverCaps, lpDDHELCaps);
 170+ default:
 171+ return DDERR_GENERIC;
 172+ }
 173+}
 174+
157175 HRESULT MultiDirectDraw::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)
158176 {
159177 switch(version)
Index: dxgltest/Tests2D.cpp
@@ -16,9 +16,9 @@
1717 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919 #include "common.h"
 20+#include "MultiDD.h"
2021 #include "tests.h"
2122 #include "surfacegen.h"
22 -#include "MultiDD.h"
2323 #include "timer.h"
2424 #include "misc.h"
2525
@@ -41,20 +41,6 @@
4242 static unsigned int randnum;
4343 static int testtypes[] = {0,1,0,1,0,1,2};
4444
45 -typedef struct
46 -{
47 - MultiDirectDrawSurface *surface;
48 - DDSURFACEDESC2 ddsd;
49 - float width;
50 - float height;
51 - float x;
52 - float y;
53 - float xvelocity;
54 - float yvelocity;
55 - DWORD bltflags;
56 - RECT rect;
57 -} DDSPRITE;
58 -
5945 static DDSPRITE sprites[16];
6046
6147 LRESULT CALLBACK DDWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
@@ -378,6 +364,8 @@
379365 ddsd.dwWidth = width;
380366 ddsd.dwHeight = height;
381367 error = ddinterface->CreateSurface(&ddsd,&ddsrender,NULL);
 368+ ddsrender->GetSurfaceDesc(&ddsd);
 369+ ::bpp = ddsd.ddpfPixelFormat.dwRGBBitCount;
382370 }
383371 else
384372 {
@@ -448,145 +436,145 @@
449437 if(ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
450438 else ddsd.dwSize = sizeof(DDSURFACEDESC);
451439 error = ddsrender->GetSurfaceDesc(&ddsd);
452 - switch(test)
 440+ switch (test)
453441 {
454442 case 0:
455 - if(!fullscreen) backbuffers = 0;
 443+ if (!fullscreen) backbuffers = 0;
456444 buffer = (unsigned char *)malloc(ddsd.lPitch*ddsd.dwHeight);
457 - DrawPalette(ddsd,buffer);
458 - error = ddsrender->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
459 - memcpy(ddsd.lpSurface,buffer,ddsd.lPitch*ddsd.dwHeight);
 445+ DrawPalette(ddsd, buffer);
 446+ error = ddsrender->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 447+ memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
460448 error = ddsrender->Unlock(NULL);
461449 ddsrender->GetPalette(&palette);
462 - if(backbuffers > 0)
 450+ if (backbuffers > 0)
463451 {
464452 ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
465 - error = ddsrender->GetAttachedSurface(&ddscaps,&temp1);
466 - DrawGradients(ddsd,buffer,hWnd,palette,1,0);
467 - error = temp1->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
468 - memcpy(ddsd.lpSurface,buffer,ddsd.lPitch*ddsd.dwHeight);
 453+ error = ddsrender->GetAttachedSurface(&ddscaps, &temp1);
 454+ DrawGradients(ddsd, buffer, hWnd, palette, 1, 0);
 455+ error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 456+ memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
469457 error = temp1->Unlock(NULL);
470458 }
471 - if(backbuffers > 1)
 459+ if (backbuffers > 1)
472460 {
473461 ddscaps.dwCaps = DDSCAPS_FLIP;
474 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 462+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
475463 temp1->Release();
476464 temp1 = temp2;
477 - DrawGradients(ddsd,buffer,hWnd,palette,0,0x0000FF);
478 - error = temp1->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
479 - memcpy(ddsd.lpSurface,buffer,ddsd.lPitch*ddsd.dwHeight);
 465+ DrawGradients(ddsd, buffer, hWnd, palette, 0, 0x0000FF);
 466+ error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 467+ memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
480468 error = temp1->Unlock(NULL);
481469 }
482 - if(backbuffers > 2)
 470+ if (backbuffers > 2)
483471 {
484472 ddscaps.dwCaps = DDSCAPS_FLIP;
485 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 473+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
486474 temp1->Release();
487475 temp1 = temp2;
488 - DrawGradients(ddsd,buffer,hWnd,palette,0,0x00FF00);
489 - error = temp1->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
490 - memcpy(ddsd.lpSurface,buffer,ddsd.lPitch*ddsd.dwHeight);
 476+ DrawGradients(ddsd, buffer, hWnd, palette, 0, 0x00FF00);
 477+ error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 478+ memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
491479 error = temp1->Unlock(NULL);
492480 }
493 - if(backbuffers > 3)
 481+ if (backbuffers > 3)
494482 {
495483 ddscaps.dwCaps = DDSCAPS_FLIP;
496 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 484+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
497485 temp1->Release();
498486 temp1 = temp2;
499 - DrawGradients(ddsd,buffer,hWnd,palette,0,0xFF0000);
500 - error = temp1->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
501 - memcpy(ddsd.lpSurface,buffer,ddsd.lPitch*ddsd.dwHeight);
 487+ DrawGradients(ddsd, buffer, hWnd, palette, 0, 0xFF0000);
 488+ error = temp1->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 489+ memcpy(ddsd.lpSurface, buffer, ddsd.lPitch*ddsd.dwHeight);
502490 error = temp1->Unlock(NULL);
503491 }
504 - if(temp1) temp1->Release();
 492+ if (temp1) temp1->Release();
505493 free(buffer);
506 - if(palette) palette->Release();
 494+ if (palette) palette->Release();
507495 break;
508496 case 2:
509 - if(!fullscreen) backbuffers=0;
 497+ if (!fullscreen) backbuffers = 0;
510498 error = ddsrender->GetDC(&hRenderDC);
511 - DrawGDIPatterns(ddsd,hRenderDC,0);
 499+ DrawGDIPatterns(ddsd, hRenderDC, 0);
512500 ddsrender->ReleaseDC(hRenderDC);
513 - if(backbuffers > 0)
 501+ if (backbuffers > 0)
514502 {
515503 ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
516 - error = ddsrender->GetAttachedSurface(&ddscaps,&temp1);
 504+ error = ddsrender->GetAttachedSurface(&ddscaps, &temp1);
517505 temp1->GetDC(&hRenderDC);
518 - DrawGDIPatterns(ddsd,hRenderDC,1);
 506+ DrawGDIPatterns(ddsd, hRenderDC, 1);
519507 temp1->ReleaseDC(hRenderDC);
520508 }
521 - if(backbuffers > 1)
 509+ if (backbuffers > 1)
522510 {
523511 ddscaps.dwCaps = DDSCAPS_FLIP;
524 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 512+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
525513 temp1->Release();
526514 temp1 = temp2;
527515 temp1->GetDC(&hRenderDC);
528 - DrawGDIPatterns(ddsd,hRenderDC,2);
 516+ DrawGDIPatterns(ddsd, hRenderDC, 2);
529517 temp1->ReleaseDC(hRenderDC);
530518 }
531 - if(backbuffers > 2)
 519+ if (backbuffers > 2)
532520 {
533521 ddscaps.dwCaps = DDSCAPS_FLIP;
534 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 522+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
535523 temp1->Release();
536524 temp1 = temp2;
537525 temp1->GetDC(&hRenderDC);
538 - DrawGDIPatterns(ddsd,hRenderDC,3);
 526+ DrawGDIPatterns(ddsd, hRenderDC, 3);
539527 temp1->ReleaseDC(hRenderDC);
540528 }
541 - if(backbuffers > 3)
 529+ if (backbuffers > 3)
542530 {
543531 ddscaps.dwCaps = DDSCAPS_FLIP;
544 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 532+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
545533 temp1->Release();
546534 temp1 = temp2;
547535 temp1->GetDC(&hRenderDC);
548 - DrawGDIPatterns(ddsd,hRenderDC,4);
 536+ DrawGDIPatterns(ddsd, hRenderDC, 4);
549537 temp1->ReleaseDC(hRenderDC);
550538 }
551 - if(backbuffers > 4)
 539+ if (backbuffers > 4)
552540 {
553541 ddscaps.dwCaps = DDSCAPS_FLIP;
554 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 542+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
555543 temp1->Release();
556544 temp1 = temp2;
557545 temp1->GetDC(&hRenderDC);
558 - DrawGDIPatterns(ddsd,hRenderDC,5);
 546+ DrawGDIPatterns(ddsd, hRenderDC, 5);
559547 temp1->ReleaseDC(hRenderDC);
560548 }
561 - if(backbuffers > 5)
 549+ if (backbuffers > 5)
562550 {
563551 ddscaps.dwCaps = DDSCAPS_FLIP;
564 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 552+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
565553 temp1->Release();
566554 temp1 = temp2;
567555 temp1->GetDC(&hRenderDC);
568 - DrawGDIPatterns(ddsd,hRenderDC,6);
 556+ DrawGDIPatterns(ddsd, hRenderDC, 6);
569557 temp1->ReleaseDC(hRenderDC);
570558 }
571 - if(backbuffers > 6)
 559+ if (backbuffers > 6)
572560 {
573561 ddscaps.dwCaps = DDSCAPS_FLIP;
574 - error = temp1->GetAttachedSurface(&ddscaps,&temp2);
 562+ error = temp1->GetAttachedSurface(&ddscaps, &temp2);
575563 temp1->Release();
576564 temp1 = temp2;
577565 temp1->GetDC(&hRenderDC);
578 - DrawGDIPatterns(ddsd,hRenderDC,7);
 566+ DrawGDIPatterns(ddsd, hRenderDC, 7);
579567 temp1->ReleaseDC(hRenderDC);
580568 }
581 - if(temp1) temp1->Release();
 569+ if (temp1) temp1->Release();
582570 break;
583571 case 4:
584572 ddsrender->GetSurfaceDesc(&ddsd);
585573 ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
586574 ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
587 - ddinterface->CreateSurface(&ddsd,&sprites[0].surface,NULL);
 575+ ddinterface->CreateSurface(&ddsd, &sprites[0].surface, NULL);
588576 ddsrender->GetPalette(&palette);
589 - error = sprites[0].surface->Lock(NULL,&ddsd,DDLOCK_WAIT,NULL);
590 - DrawGradients(ddsd,(unsigned char *)ddsd.lpSurface,hWnd,palette,1,0);
 577+ error = sprites[0].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 578+ DrawGradients(ddsd, (unsigned char *)ddsd.lpSurface, hWnd, palette, 1, 0);
591579 error = sprites[0].surface->Unlock(NULL);
592580 sprites[0].width = (float)ddsd.dwWidth;
593581 sprites[0].height = (float)ddsd.dwHeight;
@@ -593,21 +581,21 @@
594582 sprites[0].rect.left = sprites[0].rect.top = 0;
595583 sprites[0].rect.right = ddsd.dwWidth;
596584 sprites[0].rect.bottom = ddsd.dwHeight;
597 - for(int i = 1; i < 16; i++)
 585+ for (int i = 1; i < 16; i++)
598586 {
599 - switch((i-1 & 3))
 587+ switch ((i - 1 & 3))
600588 {
601589 case 0:
602590 sprites[i].width = sprites[i].height = 64.f;
603 - sprites[i].ddsd.dwWidth = sprites[i].ddsd.dwHeight =
 591+ sprites[i].ddsd.dwWidth = sprites[i].ddsd.dwHeight =
604592 sprites[i].rect.right = sprites[i].rect.bottom = 64;
605593 sprites[i].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
606 - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
607 - if(ddver > 3) sprites[i].ddsd.dwSize = sizeof(DDSURFACEDESC2);
 594+ sprites[i].ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 595+ if (ddver > 3) sprites[i].ddsd.dwSize = sizeof(DDSURFACEDESC2);
608596 else sprites[i].ddsd.dwSize = sizeof(DDSURFACEDESC);
609 - ddinterface->CreateSurface(&sprites[i].ddsd,&sprites[i].surface,NULL);
610 - error = sprites[i].surface->Lock(NULL,&sprites[i].ddsd,DDLOCK_WAIT,NULL);
611 - DrawPalette(sprites[i].ddsd,(unsigned char *)sprites[i].ddsd.lpSurface);
 597+ ddinterface->CreateSurface(&sprites[i].ddsd, &sprites[i].surface, NULL);
 598+ error = sprites[i].surface->Lock(NULL, &sprites[i].ddsd, DDLOCK_WAIT, NULL);
 599+ DrawPalette(sprites[i].ddsd, (unsigned char *)sprites[i].ddsd.lpSurface);
612600 sprites[i].surface->Unlock(NULL);
613601 break;
614602 case 1:
@@ -621,13 +609,13 @@
622610 }
623611 DDCOLORKEY ckey;
624612 ckey.dwColorSpaceHighValue = ckey.dwColorSpaceLowValue = 0;
625 - if(i < 5) sprites[i].bltflags = 0;
626 - else if(i < 9)
 613+ if (i < 5) sprites[i].bltflags = 0;
 614+ else if (i < 9)
627615 {
628616 sprites[i].bltflags = DDBLTFAST_SRCCOLORKEY;
629 - if(sprites[i].surface) sprites[i].surface->SetColorKey(DDCKEY_SRCBLT,&ckey);
 617+ if (sprites[i].surface) sprites[i].surface->SetColorKey(DDCKEY_SRCBLT, &ckey);
630618 }
631 - else if(i < 13) sprites[i].bltflags = DDBLTFAST_DESTCOLORKEY;
 619+ else if (i < 13) sprites[i].bltflags = DDBLTFAST_DESTCOLORKEY;
632620 else sprites[i].bltflags = DDBLTFAST_SRCCOLORKEY | DDBLTFAST_DESTCOLORKEY;
633621 sprites[i].x = randfloat((float)ddsd.dwWidth);
634622 sprites[i].y = randfloat((float)ddsd.dwHeight);
@@ -634,7 +622,47 @@
635623 sprites[i].xvelocity = randfloat(5);
636624 sprites[i].yvelocity = randfloat(5);
637625 }
638 -
 626+ break;
 627+ case 7:
 628+ if (!fullscreen) backbuffers = 0;
 629+ ddsrender->GetSurfaceDesc(&ddsd);
 630+ ddsrender->GetPalette(&palette);
 631+ sprites[0].ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH;
 632+ ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
 633+ if (ddver > 3) sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC2);
 634+ else sprites[0].ddsd.dwSize = sizeof(DDSURFACEDESC);
 635+ memcpy(&sprites[1], &sprites[0], sizeof(DDSPRITE));
 636+ memcpy(&sprites[2], &sprites[0], sizeof(DDSPRITE));
 637+ memcpy(&sprites[3], &sprites[0], sizeof(DDSPRITE));
 638+ memcpy(&sprites[4], &sprites[0], sizeof(DDSPRITE));
 639+ memcpy(&sprites[5], &sprites[0], sizeof(DDSPRITE));
 640+ sprites[0].width = sprites[0].height = 256.0f;
 641+ sprites[1].width = sprites[1].height = 256.0f;
 642+ sprites[2].width = sprites[2].height = 16.0f;
 643+ sprites[3].width = sprites[3].height = 16.0f;
 644+ sprites[4].width = sprites[4].height = 8.0f;
 645+ sprites[5].width = sprites[4].height = 6.0f;
 646+ sprites[0].ddsd.dwWidth = sprites[0].ddsd.dwHeight =
 647+ sprites[0].rect.right = sprites[0].rect.bottom = 256;
 648+ sprites[1].ddsd.dwWidth = sprites[1].ddsd.dwHeight =
 649+ sprites[1].rect.right = sprites[1].rect.bottom = 256;
 650+ sprites[2].ddsd.dwWidth = sprites[2].ddsd.dwHeight =
 651+ sprites[2].rect.right = sprites[2].rect.bottom = 16;
 652+ sprites[3].ddsd.dwWidth = sprites[3].ddsd.dwHeight =
 653+ sprites[3].rect.right = sprites[3].rect.bottom = 16;
 654+ sprites[4].ddsd.dwWidth = sprites[4].ddsd.dwHeight =
 655+ sprites[4].rect.right = sprites[4].rect.bottom = 8;
 656+ sprites[5].ddsd.dwWidth = sprites[5].ddsd.dwHeight =
 657+ sprites[5].rect.right = sprites[5].rect.bottom = 6;
 658+ ddinterface->CreateSurface(&sprites[0].ddsd, &sprites[0].surface, NULL);
 659+ ddinterface->CreateSurface(&sprites[1].ddsd, &sprites[1].surface, NULL);
 660+ ddinterface->CreateSurface(&sprites[2].ddsd, &sprites[2].surface, NULL);
 661+ ddinterface->CreateSurface(&sprites[3].ddsd, &sprites[3].surface, NULL);
 662+ ddinterface->CreateSurface(&sprites[4].ddsd, &sprites[4].surface, NULL);
 663+ ddinterface->CreateSurface(&sprites[5].ddsd, &sprites[5].surface, NULL);
 664+ DDCAPS ddcaps;
 665+ ddinterface->GetCaps(&ddcaps, NULL);
 666+ DrawROPPatterns(ddsrender, sprites, backbuffers, ddver, bpp, ddcaps.dwRops,hWnd,palette);
639667 }
640668 }
641669
Index: dxgltest/Tests3D.cpp
@@ -16,9 +16,9 @@
1717 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919 #include "common.h"
 20+#include "MultiDD.h"
2021 #include "tests.h"
2122 #include "surfacegen.h"
22 -#include "MultiDD.h"
2323 #include "timer.h"
2424 #include "misc.h"
2525 #define D3D_OVERLOADS
Index: dxgltest/dxgltest.cpp
@@ -17,6 +17,7 @@
1818
1919 #include "common.h"
2020 #include "dxgltest.h"
 21+#include "MultiDD.h"
2122 #include "tests.h"
2223
2324 HINSTANCE hinstance;
@@ -224,7 +225,8 @@
225226 {1, 7, 0, 0, false, 0.0, false, false, _T("Random GDI patterns (does not clear screen between paints)")},
226227 {1, 7, 0, 1, true, 60.0, false, false, _T("BltFast background and sprites")},
227228 {1, 7, 0, 0, false, 0.0, false, false, _T("Random color fill Blt() paterns")},
228 - {1, 7, 0, 0, false, 0.0, false, false, _T("Mouse pointer event test")}
 229+ {1, 7, 0, 0, false, 0.0, false, false, _T("Mouse pointer event test")},
 230+ {1, 7, 1, 1, true, 1.0, false, false, _T("Raster Operation Blt() test")}
229231 };
230232 const int END_2D = __LINE__ - 4;
231233 const int numtests2d = END_2D - START_2D;
Index: dxgltest/surfacegen.cpp
@@ -16,6 +16,8 @@
1717 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919 #include "common.h"
 20+#include "MultiDD.h"
 21+#include "tests.h"
2022 #include "surfacegen.h"
2123
2224 #ifndef GRADIENT_FILL_RECT_H
@@ -30,7 +32,178 @@
3133 0x81,0xe1
3234 };
3335
 36+const unsigned char blt_pattern_8[] = {
 37+ 0xED, 0xED, 0xED, 0xF8, 0xF8, 0xF8,
 38+ 0xED, 0xED, 0xED, 0xF8, 0xF8, 0xF8,
 39+ 0xED, 0xED, 0xED, 0xF8, 0xF8, 0xF8,
 40+ 0xF8, 0xF8, 0xF8, 0xED, 0xED, 0xED,
 41+ 0xF8, 0xF8, 0xF8, 0xED, 0xED, 0xED,
 42+ 0xF8, 0xF8, 0xF8, 0xED, 0xED, 0xED
 43+};
3444
 45+const unsigned short blt_pattern_15[] = {
 46+ 0x7DFF, 0x7DFF, 0x7DFF, 0x3DEF, 0x3DEF, 0x3DEF,
 47+ 0x7DFF, 0x7DFF, 0x7DFF, 0x3DEF, 0x3DEF, 0x3DEF,
 48+ 0x7DFF, 0x7DFF, 0x7DFF, 0x3DEF, 0x3DEF, 0x3DEF,
 49+ 0x3DEF, 0x3DEF, 0x3DEF, 0x7DFF, 0x7DFF, 0x7DFF,
 50+ 0x3DEF, 0x3DEF, 0x3DEF, 0x7DFF, 0x7DFF, 0x7DFF,
 51+ 0x3DEF, 0x3DEF, 0x3DEF, 0x7DFF, 0x7DFF, 0x7DFF
 52+};
 53+
 54+const unsigned short blt_pattern_16[] = {
 55+ 0xFBFF, 0xFBFF, 0xFBFF, 0x7BEF, 0x7BEF, 0x7BEF,
 56+ 0xFBFF, 0xFBFF, 0xFBFF, 0x7BEF, 0x7BEF, 0x7BEF,
 57+ 0xFBFF, 0xFBFF, 0xFBFF, 0x7BEF, 0x7BEF, 0x7BEF,
 58+ 0x7BEF, 0x7BEF, 0x7BEF, 0xFBFF, 0xFBFF, 0xFBFF,
 59+ 0x7BEF, 0x7BEF, 0x7BEF, 0xFBFF, 0xFBFF, 0xFBFF,
 60+ 0x7BEF, 0x7BEF, 0x7BEF, 0xFBFF, 0xFBFF, 0xFBFF
 61+};
 62+
 63+const unsigned char blt_pattern_24[] = {
 64+ 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
 65+ 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
 66+ 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
 67+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF,
 68+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF,
 69+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFF
 70+};
 71+
 72+const unsigned long blt_pattern_32[] = {
 73+ 0xFF7FFF, 0xFF7FFF, 0xFF7FFF, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F,
 74+ 0xFF7FFF, 0xFF7FFF, 0xFF7FFF, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F,
 75+ 0xFF7FFF, 0xFF7FFF, 0xFF7FFF, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F,
 76+ 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0xFF7FFF, 0xFF7FFF, 0xFF7FFF,
 77+ 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0xFF7FFF, 0xFF7FFF, 0xFF7FFF,
 78+ 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0xFF7FFF, 0xFF7FFF, 0xFF7FFF
 79+};
 80+
 81+const unsigned char back_pattern_8[] = {
 82+ 0xF8, 0xF8, 0xF8, 0xF8, 0x07, 0x07, 0x07, 0x07,
 83+ 0xF8, 0xF8, 0xF8, 0xF8, 0x07, 0x07, 0x07, 0x07,
 84+ 0xF8, 0xF8, 0xF8, 0xF8, 0x07, 0x07, 0x07, 0x07,
 85+ 0xF8, 0xF8, 0xF8, 0xF8, 0x07, 0x07, 0x07, 0x07,
 86+ 0x07, 0x07, 0x07, 0x07, 0xF8, 0xF8, 0xF8, 0xF8,
 87+ 0x07, 0x07, 0x07, 0x07, 0xF8, 0xF8, 0xF8, 0xF8,
 88+ 0x07, 0x07, 0x07, 0x07, 0xF8, 0xF8, 0xF8, 0xF8,
 89+ 0x07, 0x07, 0x07, 0x07, 0xF8, 0xF8, 0xF8, 0xF8
 90+};
 91+
 92+const unsigned short back_pattern_15[] = {
 93+ 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF, 0x6318, 0x6318, 0x6318, 0x6318,
 94+ 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF, 0x6318, 0x6318, 0x6318, 0x6318,
 95+ 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF, 0x6318, 0x6318, 0x6318, 0x6318,
 96+ 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF, 0x6318, 0x6318, 0x6318, 0x6318,
 97+ 0x6318, 0x6318, 0x6318, 0x6318, 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF,
 98+ 0x6318, 0x6318, 0x6318, 0x6318, 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF,
 99+ 0x6318, 0x6318, 0x6318, 0x6318, 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF,
 100+ 0x6318, 0x6318, 0x6318, 0x6318, 0x3DEF, 0x3DEF, 0x3DEF, 0x3DEF
 101+};
 102+
 103+const unsigned short back_pattern_16[] = {
 104+ 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF, 0xC618, 0xC618, 0xC618, 0xC618,
 105+ 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF, 0xC618, 0xC618, 0xC618, 0xC618,
 106+ 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF, 0xC618, 0xC618, 0xC618, 0xC618,
 107+ 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF, 0xC618, 0xC618, 0xC618, 0xC618,
 108+ 0xC618, 0xC618, 0xC618, 0xC618, 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF,
 109+ 0xC618, 0xC618, 0xC618, 0xC618, 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF,
 110+ 0xC618, 0xC618, 0xC618, 0xC618, 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF,
 111+ 0xC618, 0xC618, 0xC618, 0xC618, 0x7BEF, 0x7BEF, 0x7BEF, 0x7BEF
 112+};
 113+
 114+const unsigned short back_pattern_24[] = {
 115+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
 116+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
 117+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
 118+ 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0,
 119+ 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
 120+ 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
 121+ 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,
 122+ 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F
 123+};
 124+
 125+const unsigned long back_pattern_32[] = {
 126+ 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0,
 127+ 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0,
 128+ 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0,
 129+ 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0,
 130+ 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F,
 131+ 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F,
 132+ 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F,
 133+ 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0xC0C0C0, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F, 0x7F7F7F
 134+};
 135+
 136+static const DWORD rop_codes[256] = {
 137+ 0x00000042, 0x00010289, 0x00020C89, 0x000300AA, 0x00040C88, 0x000500A9, 0x00060865, 0x000702C5,
 138+ 0x00080F08, 0x00090245, 0x000A0329, 0x000B0B2A, 0x000C0324, 0x000D0B25, 0x000E08A5, 0x000F0001,
 139+ 0x00100C85, 0x001100A6, 0x00120868, 0x001302C8, 0x00140869, 0x001502C9, 0x00165CCA, 0x00171D54,
 140+ 0x00180D59, 0x00191CC8, 0x001A06C5, 0x001B0768, 0x001C06CA, 0x001D0766, 0x001E01A5, 0x001F0385,
 141+ 0x00200F09, 0x00210248, 0x00220326, 0x00230B24, 0x00240D55, 0x00251CC5, 0x002606C8, 0x00271868,
 142+ 0x00280369, 0x002916CA, 0x002A0CC9, 0x002B1D58, 0x002C0784, 0x002D060A, 0x002E064A, 0x002F0E2A,
 143+ 0x0030032A, 0x00310B28, 0x00320688, 0x00330008, 0x003406C4, 0x00351864, 0x003601A8, 0x00370388,
 144+ 0x0038078A, 0x00390604, 0x003A0644, 0x003B0E24, 0x003C004A, 0x003D18A4, 0x003E1B24, 0x003F00EA,
 145+ 0x00400F0A, 0x00410249, 0x00420D5D, 0x00431CC4, 0x00440328, 0x00450B29, 0x004606C6, 0x0047076A,
 146+ 0x00480368, 0x004916C5, 0x004A0789, 0x004B0605, 0x004C0CC8, 0x004D1954, 0x004E0645, 0x004F0E25,
 147+ 0x00500325, 0x00510B26, 0x005206C9, 0x00530764, 0x005408A9, 0x00550009, 0x005601A9, 0x00570389,
 148+ 0x00580785, 0x00590609, 0x005A0049, 0x005B18A9, 0x005C0649, 0x005D0E29, 0x005E1B29, 0x005F00E9,
 149+ 0x00600365, 0x006116C6, 0x00620786, 0x00630608, 0x00640788, 0x00650606, 0x00660046, 0x006718A8,
 150+ 0x006858A6, 0x00690145, 0x006A01E9, 0x006B178A, 0x006C01E8, 0x006D1785, 0x006E1E28, 0x006F0C65,
 151+ 0x00700CC5, 0x00711D5C, 0x00720648, 0x00730E28, 0x00740646, 0x00750E26, 0x00761B28, 0x007700E6,
 152+ 0x007801E5, 0x00791786, 0x007A1E29, 0x007B0C68, 0x007C1E24, 0x007D0C69, 0x007E0955, 0x007F03C9,
 153+ 0x008003E9, 0x00810975, 0x00820C49, 0x00831E04, 0x00840C48, 0x00851E05, 0x008617A6, 0x008701C5,
 154+ 0x008800C6, 0x00891B08, 0x008A0E06, 0x008B0666, 0x008C0E08, 0x008D0668, 0x008E1D7C, 0x008F0CE5,
 155+ 0x00900C45, 0x00911E08, 0x009217A9, 0x009301C4, 0x009417AA, 0x009501C9, 0x00960169, 0x0097588A,
 156+ 0x00981888, 0x00990066, 0x009A0709, 0x009B07A8, 0x009C0704, 0x009D07A6, 0x009E16E6, 0x009F0345,
 157+ 0x00A000C9, 0x00A11B05, 0x00A20E09, 0x00A30669, 0x00A41885, 0x00A50065, 0x00A60706, 0x00A707A5,
 158+ 0x00A803A9, 0x00A90189, 0x00AA0029, 0x00AB0889, 0x00AC0744, 0x00AD06E9, 0x00AE0B06, 0x00AF0229,
 159+ 0x00B00E05, 0x00B10665, 0x00B21974, 0x00B30CE8, 0x00B4070A, 0x00B507A9, 0x00B616E9, 0x00B70348,
 160+ 0x00B8074A, 0x00B906E6, 0x00BA0B09, 0x00BB0226, 0x00BC1CE4, 0x00BD0D7D, 0x00BE0269, 0x00BF08C9,
 161+ 0x00C000CA, 0x00C11B04, 0x00C21884, 0x00C3006A, 0x00C40E04, 0x00C50664, 0x00C60708, 0x00C707AA,
 162+ 0x00C803A8, 0x00C90184, 0x00CA0749, 0x00CB06E4, 0x00CC0020, 0x00CD0888, 0x00CE0B08, 0x00CF0224,
 163+ 0x00D00E0A, 0x00D1066A, 0x00D20705, 0x00D307A4, 0x00D41D78, 0x00D50CE9, 0x00D616EA, 0x00D70349,
 164+ 0x00D80745, 0x00D906E8, 0x00DA1CE9, 0x00DB0D75, 0x00DC0B04, 0x00DD0228, 0x00DE0268, 0x00DF08C8,
 165+ 0x00E003A5, 0x00E10185, 0x00E20746, 0x00E306EA, 0x00E40748, 0x00E506E5, 0x00E61CE8, 0x00E70D79,
 166+ 0x00E81D74, 0x00E95CE6, 0x00EA02E9, 0x00EB0849, 0x00EC02E8, 0x00ED0848, 0x00EE0086, 0x00EF0A08,
 167+ 0x00F00021, 0x00F10885, 0x00F20B05, 0x00F3022A, 0x00F40B0A, 0x00F50225, 0x00F60265, 0x00F708C5,
 168+ 0x00F802E5, 0x00F90845, 0x00FA0089, 0x00FB0A09, 0x00FC008A, 0x00FD0A0A, 0x00FE02A9, 0x00FF0062
 169+};
 170+
 171+/*
 172+1 - Source
 173+2 - Dest
 174+4 - Pattern */
 175+const DWORD rop_texture_usage[256] = {
 176+ 0, 7, 7, 5, 7, 6, 7, 7, 7, 7, 6, 7, 5, 7, 7, 4,
 177+ 7, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
 178+ 7, 7, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
 179+ 5, 7, 7, 1, 7, 7, 7, 7, 7, 7, 7, 7, 5, 7, 7, 5,
 180+ 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
 181+ 6, 7, 7, 7, 7, 2, 7, 7, 7, 7, 6, 7, 7, 7, 7, 6,
 182+ 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7, 7, 7, 7,
 183+ 7, 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7, 7, 7,
 184+ 7, 7, 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7, 7,
 185+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 7, 7, 7,
 186+ 6, 7, 7, 7, 7, 6, 7, 7, 7, 7, 2, 7, 7, 7, 7, 6,
 187+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 7, 7, 7, 7,
 188+ 5, 7, 7, 5, 7, 7, 7, 7, 7, 7, 7, 7, 1, 7, 7, 5,
 189+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 7, 7,
 190+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 3, 7,
 191+ 4, 7, 7, 5, 7, 6, 7, 7, 7, 7, 6, 7, 5, 7, 7, 0
 192+};
 193+
 194+BOOL IsRopCodeSupported(DWORD rop, DWORD *ropcaps)
 195+{
 196+ DWORD rop32 = rop & 0xFFFFFF;
 197+ DWORD ropindex = (rop >> 16) & 0xFF;
 198+ DWORD ropword = ropindex >> 5;
 199+ DWORD ropbit = ropindex & 0x1F;
 200+ if (rop_codes[ropindex] != rop32) return FALSE;
 201+ if ((ropcaps[ropword] >> ropbit) & 1)
 202+ {
 203+ return TRUE;
 204+ }
 205+ else return FALSE;
 206+}
 207+
35208 void DrawPalette(DDSURFACEDESC2 ddsd, unsigned char *buffer) // Palette test
36209 {
37210 DWORD x,y;
@@ -152,7 +325,7 @@
153326 void DrawGradients(DDSURFACEDESC2 ddsd, unsigned char *buffer, HWND hwnd, LPDIRECTDRAWPALETTE palette, int type, DWORD color) // Gradients
154327 {
155328 HDC hdcwin = GetDC(hwnd);
156 - DWORD colors[1024];
 329+ DWORD colors[256];
157330 int bitmode = BI_RGB;
158331 DWORD bitmasks[3];
159332 LPBYTE bits;
@@ -735,3 +908,211 @@
736909 break;
737910 }
738911 }
 912+
 913+void DrawROPPatterns(MultiDirectDrawSurface *primary, DDSPRITE *sprites, int backbuffers, int ddver, int bpp, DWORD *ropcaps,
 914+ HWND hwnd, LPDIRECTDRAWPALETTE palette)
 915+{
 916+ HICON ico_dxglsm;
 917+ HICON ico_x16;
 918+ HDC hdc;
 919+ DDSURFACEDESC2 ddsd;
 920+ ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
 921+ if (ddver > 3)ddsd.dwSize = sizeof(DDSURFACEDESC2);
 922+ else ddsd.dwSize = sizeof(DDSURFACEDESC);
 923+ ico_dxglsm = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_DXGLSM), IMAGE_ICON, 16, 16, 0);
 924+ ico_x16 = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_X16), IMAGE_ICON, 16, 16, 0);
 925+ sprites[2].surface->GetDC(&hdc);
 926+ DrawIconEx(hdc, 0, 0, ico_dxglsm, 16, 16, 0, NULL, DI_NORMAL);
 927+ sprites[2].surface->ReleaseDC(hdc);
 928+ sprites[3].surface->GetDC(&hdc);
 929+ DrawIconEx(hdc, 0, 0, ico_x16, 16, 16, 0, NULL, DI_NORMAL);
 930+ sprites[3].surface->ReleaseDC(hdc);
 931+ DestroyIcon(ico_x16);
 932+ sprites[4].surface->GetSurfaceDesc(&ddsd);
 933+ sprites[4].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 934+ switch (bpp)
 935+ {
 936+ case 8:
 937+ default:
 938+ for (int i = 0; i < 8; i++)
 939+ memcpy((unsigned char*)ddsd.lpSurface + (i*ddsd.lPitch), &back_pattern_8[8 * i], 8);
 940+ break;
 941+ case 15:
 942+ for (int i = 0; i < 8; i++)
 943+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &back_pattern_15[8 * i], 16);
 944+ break;
 945+ case 16:
 946+ for (int i = 0; i < 8; i++)
 947+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &back_pattern_16[8 * i], 16);
 948+ break;
 949+ case 24:
 950+ for (int i = 0; i < 8; i++)
 951+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &back_pattern_24[24 * i], 24);
 952+ break;
 953+ case 32:
 954+ for (int i = 0; i < 8; i++)
 955+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &back_pattern_32[8 * i], 32);
 956+ break;
 957+ }
 958+ sprites[4].surface->Unlock(NULL);
 959+ sprites[5].surface->GetSurfaceDesc(&ddsd);
 960+ sprites[5].surface->Lock(NULL, &ddsd, DDLOCK_WAIT, NULL);
 961+ switch (bpp)
 962+ {
 963+ case 8:
 964+ default:
 965+ for (int i = 0; i < 6; i++)
 966+ memcpy((unsigned char*)ddsd.lpSurface + (i*ddsd.lPitch), &blt_pattern_8[6 * i], 6);
 967+ break;
 968+ case 15:
 969+ for (int i = 0; i < 6; i++)
 970+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &blt_pattern_15[6 * i], 12);
 971+ break;
 972+ case 16:
 973+ for (int i = 0; i < 6; i++)
 974+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &blt_pattern_16[6 * i], 12);
 975+ break;
 976+ case 24:
 977+ for (int i = 0; i < 6; i++)
 978+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &blt_pattern_24[18 * i], 18);
 979+ break;
 980+ case 32:
 981+ for (int i = 0; i < 6; i++)
 982+ memcpy((unsigned char *)ddsd.lpSurface + (i*ddsd.lPitch), &blt_pattern_32[6 * i], 24);
 983+ break;
 984+ }
 985+ sprites[5].surface->Unlock(NULL);
 986+ int bltx, blty;
 987+ RECT bltrect;
 988+ DDBLTFX bltfx;
 989+ ZeroMemory(&bltfx, sizeof(DDBLTFX));
 990+ bltfx.dwSize = sizeof(DDBLTFX);
 991+ for (int y = 0; y < 32; y++)
 992+ {
 993+ for (int x = 0; x < 32; x++)
 994+ {
 995+ bltx = x * 8;
 996+ blty = y * 8;
 997+ bltrect.left = bltx;
 998+ bltrect.right = bltx + 8;
 999+ bltrect.top = blty;
 1000+ bltrect.bottom = blty + 8;
 1001+ sprites[0].surface->Blt(&bltrect, sprites[4].surface, NULL, DDBLT_WAIT, NULL);
 1002+ sprites[1].surface->Blt(&bltrect, sprites[4].surface, NULL, DDBLT_WAIT, NULL);
 1003+ }
 1004+ }
 1005+ for (int i = 0; i < 256; i++)
 1006+ {
 1007+ bltx = (i & 0xF) * 16;
 1008+ blty = (i >> 4) * 16;
 1009+ bltrect.left = bltx;
 1010+ bltrect.right = bltx + 16;
 1011+ bltrect.top = blty;
 1012+ bltrect.bottom = blty + 16;
 1013+ if (IsRopCodeSupported(rop_codes[i], ropcaps))
 1014+ {
 1015+ if (rop_texture_usage[i] & 4) bltfx.lpDDSPattern = (LPDIRECTDRAWSURFACE)sprites[5].surface->GetSurface();
 1016+ else bltfx.lpDDSPattern = NULL;
 1017+ sprites[0].surface->Blt(&bltrect, sprites[2].surface, NULL, DDBLT_ROP | DDBLT_WAIT, &bltfx);
 1018+ }
 1019+ else
 1020+ {
 1021+ sprites[0].surface->Blt(&bltrect, sprites[3].surface, NULL, DDBLT_WAIT, NULL);
 1022+ }
 1023+ }
 1024+ HDC hdcwin = GetDC(hwnd);
 1025+ DWORD colors[256];
 1026+ int bitmode = BI_RGB;
 1027+ DWORD bitmasks[3];
 1028+ LPBYTE bits;
 1029+ BITMAPINFO *bmi = (BITMAPINFO*)malloc(sizeof(BITMAPINFOHEADER)+1024);
 1030+ if (!bmi) return;
 1031+ ZeroMemory(bmi, sizeof(BITMAPINFOHEADER)+1024);
 1032+ if (ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
 1033+ {
 1034+ palette->GetEntries(0, 0, 256, (LPPALETTEENTRY)colors);
 1035+ for (int i = 0; i < 256; i++)
 1036+ colors[i] = ((colors[i] & 0x0000FF) << 16) | (colors[i] & 0x00FF00) | ((colors[i] & 0xFF0000) >> 16);
 1037+ memcpy(bmi->bmiColors, colors, 1024);
 1038+ }
 1039+ if (ddsd.ddpfPixelFormat.dwRGBBitCount == 16)
 1040+ {
 1041+ bitmode = BI_BITFIELDS;
 1042+ bitmasks[0] = ddsd.ddpfPixelFormat.dwRBitMask;
 1043+ bitmasks[1] = ddsd.ddpfPixelFormat.dwGBitMask;
 1044+ bitmasks[2] = ddsd.ddpfPixelFormat.dwBBitMask;
 1045+ memcpy(bmi->bmiColors, bitmasks, 3 * sizeof(DWORD));
 1046+ }
 1047+ bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 1048+ bmi->bmiHeader.biWidth = 16;
 1049+ bmi->bmiHeader.biHeight = -16;
 1050+ bmi->bmiHeader.biPlanes = 1;
 1051+ bmi->bmiHeader.biCompression = bitmode;
 1052+ bmi->bmiHeader.biBitCount = (WORD)ddsd.ddpfPixelFormat.dwRGBBitCount;
 1053+ HBITMAP bmpicon = CreateDIBSection(hdcwin, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
 1054+ HDC hdcicon = CreateCompatibleDC(hdcwin);
 1055+ HGDIOBJ hbmiconold = SelectObject(hdcicon, bmpicon);
 1056+ DrawIconEx(hdcicon, 0, 0, ico_dxglsm, 16, 16, 0, NULL, DI_NORMAL);
 1057+ DestroyIcon(ico_dxglsm);
 1058+ bmi->bmiHeader.biWidth = 6;
 1059+ bmi->bmiHeader.biHeight = -6;
 1060+ HBITMAP bmppattern = CreateDIBSection(hdcwin, bmi, DIB_RGB_COLORS, (void**)&bits, NULL, 0);
 1061+ int bmpwidth = NextMultipleOf4((bmi->bmiHeader.biBitCount*bmi->bmiHeader.biWidth) / 8);
 1062+ switch (bpp)
 1063+ {
 1064+ case 8:
 1065+ default:
 1066+ for (int i = 0; i < 6; i++)
 1067+ memcpy((unsigned char*)bits + (i*bmpwidth), &blt_pattern_8[6 * i], 6);
 1068+ break;
 1069+ case 15:
 1070+ for (int i = 0; i < 6; i++)
 1071+ memcpy((unsigned char *)bits + (i*bmpwidth), &blt_pattern_15[6 * i], 12);
 1072+ break;
 1073+ case 16:
 1074+ for (int i = 0; i < 6; i++)
 1075+ memcpy((unsigned char *)bits + (i*bmpwidth), &blt_pattern_16[6 * i], 12);
 1076+ break;
 1077+ case 24:
 1078+ for (int i = 0; i < 6; i++)
 1079+ memcpy((unsigned char *)bits + (i*bmpwidth), &blt_pattern_24[18 * i], 18);
 1080+ break;
 1081+ case 32:
 1082+ for (int i = 0; i < 6; i++)
 1083+ memcpy((unsigned char *)bits + (i*bmpwidth), &blt_pattern_32[6 * i], 24);
 1084+ break;
 1085+ }
 1086+ HBRUSH hbrpattern = CreatePatternBrush(bmppattern);
 1087+ HDC hdcblt;
 1088+ sprites[1].surface->GetDC(&hdcblt);
 1089+ HGDIOBJ hbrold = SelectObject(hdcblt, hbrpattern);
 1090+ for (int i = 0; i < 256; i++)
 1091+ {
 1092+ bltx = (i & 0xF) * 16;
 1093+ blty = (i >> 4) * 16;
 1094+ BitBlt(hdcblt, bltx, blty, 16, 16, hdcicon, 0, 0, rop_codes[i]);
 1095+ }
 1096+ SelectObject(hdcblt, hbrold);
 1097+ sprites[1].surface->ReleaseDC(hdcblt);
 1098+ primary->GetDC(&hdcblt);
 1099+ SetBkColor(hdcblt, RGB(0, 0, 255));
 1100+ SetTextColor(hdcblt, RGB(255, 255, 255));
 1101+ TextOut(hdcblt, 0, 0, _T("Screen 0: DDraw Blt"),20);
 1102+ primary->ReleaseDC(hdcblt);
 1103+ primary->BltFast(0, 16, sprites[0].surface, NULL, DDBLTFAST_WAIT);
 1104+ if (backbuffers)
 1105+ {
 1106+ MultiDirectDrawSurface *back;
 1107+ DDSCAPS2 ddscaps;
 1108+ ZeroMemory(&ddscaps, sizeof(DDSCAPS2));
 1109+ ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
 1110+ primary->GetAttachedSurface(&ddscaps, &back);
 1111+ back->GetDC(&hdcblt);
 1112+ SetBkColor(hdcblt, RGB(0, 0, 255));
 1113+ SetTextColor(hdcblt, RGB(255, 255, 255));
 1114+ TextOut(hdcblt, 0, 0, _T("Screen 0: GDI Blt"), 18);
 1115+ back->ReleaseDC(hdcblt);
 1116+ back->BltFast(0, 16, sprites[1].surface, NULL, DDBLTFAST_WAIT);
 1117+ back->Release();
 1118+ }
 1119+}
\ No newline at end of file
Index: dxgltest/surfacegen.h
@@ -22,5 +22,7 @@
2323 void DrawPalette(DDSURFACEDESC2 ddsd, unsigned char *buffer); // Palette test
2424 void DrawGradients(DDSURFACEDESC2 ddsd, unsigned char *buffer, HWND hwnd, LPDIRECTDRAWPALETTE palette, int type, DWORD color); // Gradients
2525 void DrawGDIPatterns(DDSURFACEDESC2 ddsd, HDC hDC, int type); // GDI pattern test
 26+void DrawROPPatterns(MultiDirectDrawSurface *primary, DDSPRITE *sprites, int backbuffers, int ddver, int bpp, DWORD *ropcaps,
 27+ HWND hwnd, LPDIRECTDRAWPALETTE palette); // ROP pattern test
2628
2729 #endif //_SURFACEGEN_H
\ No newline at end of file
Index: dxgltest/tests.h
@@ -19,6 +19,19 @@
2020 #ifndef _TESTS_H
2121 #define _TESTS_H
2222
 23+typedef struct
 24+{
 25+ MultiDirectDrawSurface *surface;
 26+ DDSURFACEDESC2 ddsd;
 27+ float width;
 28+ float height;
 29+ float x;
 30+ float y;
 31+ float xvelocity;
 32+ float yvelocity;
 33+ DWORD bltflags;
 34+ RECT rect;
 35+} DDSPRITE;
2336
2437 void RunTest2D(int testnum, int width, int height, int bpp, int refresh, int backbuffers, int apiver,
2538 double fps, bool fullscreen, bool resizable);