mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-12-01 00:21:35 +00:00
- Moved the pixel shaders' color information out of the constant registers
and into the vertex data. - Added functions for doing line drawing with Direct3D, including a new pair of functions to do batched line drawing so that the map can actually be drawn faster in hardware than in software (instead of an order of magnitude slower). SVN r663 (trunk)
This commit is contained in:
parent
5d9d2a9088
commit
5cbb2bd472
9 changed files with 401 additions and 263 deletions
|
@ -1,3 +1,11 @@
|
|||
January 3, 2008
|
||||
- Moved the pixel shaders' color information out of the constant registers
|
||||
and into the vertex data.
|
||||
- Added functions for doing line drawing with Direct3D, including a new pair
|
||||
of functions to do batched line drawing so that the map can actually be
|
||||
drawn faster in hardware than in software (instead of an order of magnitude
|
||||
slower).
|
||||
|
||||
January 2, 2008
|
||||
- Tried adding bilinear filtering support for paletted textures, but the
|
||||
shader seems to be producing crappy output, so it's disabled for now.
|
||||
|
@ -11,7 +19,7 @@ January 2, 2008
|
|||
the device.
|
||||
- Fixed: R_DrawTopBorder() must clip itself around the 3D view, since it's
|
||||
now drawn later.
|
||||
- With full software rendering, palette flashes once again effect the whole
|
||||
- With full software rendering, palette flashes once again affect the whole
|
||||
screen.
|
||||
|
||||
January 1, 2008
|
||||
|
|
|
@ -1802,6 +1802,8 @@ void AM_Drawer ()
|
|||
}
|
||||
AM_activateNewScale();
|
||||
|
||||
screen->BeginLineDrawing();
|
||||
|
||||
if (grid)
|
||||
AM_drawGrid(GridColor);
|
||||
|
||||
|
@ -1809,6 +1811,9 @@ void AM_Drawer ()
|
|||
AM_drawPlayers();
|
||||
if (am_cheat >= 2 || allthings)
|
||||
AM_drawThings();
|
||||
|
||||
screen->EndLineDrawing();
|
||||
|
||||
AM_drawAuthorMarkers();
|
||||
|
||||
if (!viewactive)
|
||||
|
|
|
@ -558,17 +558,20 @@ void D_Display ()
|
|||
R_DetailDouble (); // [RH] Apply detail mode expansion
|
||||
// [RH] Let cameras draw onto textures that were visible this frame.
|
||||
FCanvasTextureInfo::UpdateAll ();
|
||||
if (automapactive)
|
||||
{
|
||||
AM_Drawer ();
|
||||
}
|
||||
if ((hw2d = screen->Begin2D(true)))
|
||||
if ((hw2d = screen->Begin2D(viewactive)))
|
||||
{
|
||||
// Redraw everything every frame when using 2D accel
|
||||
SB_state = screen->GetPageCount();
|
||||
BorderNeedRefresh = screen->GetPageCount();
|
||||
}
|
||||
R_RefreshViewBorder ();
|
||||
if (automapactive)
|
||||
{
|
||||
AM_Drawer ();
|
||||
}
|
||||
if (!automapactive || viewactive)
|
||||
{
|
||||
R_RefreshViewBorder ();
|
||||
}
|
||||
if (realviewheight == SCREENHEIGHT && viewactive)
|
||||
{
|
||||
StatusBar->Draw (DrawFSHUD ? HUD_Fullscreen : HUD_None);
|
||||
|
|
|
@ -689,6 +689,14 @@ void DCanvas::PUTTRANSDOT (int xx, int yy, int basecolor, int level)
|
|||
*spot = RGB32k[0][0][bg&(bg>>15)];
|
||||
}
|
||||
|
||||
void DCanvas::BeginLineDrawing()
|
||||
{
|
||||
}
|
||||
|
||||
void DCanvas::EndLineDrawing()
|
||||
{
|
||||
}
|
||||
|
||||
void DCanvas::DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor)
|
||||
//void DrawTransWuLine (int x0, int y0, int x1, int y1, BYTE palColor)
|
||||
{
|
||||
|
|
|
@ -165,10 +165,16 @@ public:
|
|||
// Set an area to a specified color
|
||||
virtual void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);
|
||||
|
||||
// draws a line
|
||||
// Call before drawing any lines
|
||||
virtual void BeginLineDrawing();
|
||||
|
||||
// Draws a line
|
||||
virtual void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor);
|
||||
|
||||
// draws a single pixel
|
||||
// Call after you've finished drawing a batch of lines
|
||||
virtual void EndLineDrawing();
|
||||
|
||||
// Draws a single pixel
|
||||
virtual void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor);
|
||||
|
||||
// Calculate gamma table
|
||||
|
|
|
@ -73,6 +73,9 @@
|
|||
// The number of vertices the vertex buffer should hold.
|
||||
#define NUM_VERTS 12
|
||||
|
||||
// The number of line endpoints for the line vertex buffer.
|
||||
#define NUM_LINE_VERTS 10240
|
||||
|
||||
// TYPES -------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(D3DFB)
|
||||
|
@ -162,7 +165,7 @@ D3DFB::D3DFB (int width, int height, bool fullscreen)
|
|||
D3DPRESENT_PARAMETERS d3dpp;
|
||||
|
||||
D3DDevice = NULL;
|
||||
VertexBuffer = NULL;
|
||||
LineBuffer = NULL;
|
||||
FBTexture = NULL;
|
||||
TempRenderTexture = NULL;
|
||||
InitialWipeScreen = NULL;
|
||||
|
@ -174,7 +177,7 @@ D3DFB::D3DFB (int width, int height, bool fullscreen)
|
|||
PalTexBilinearShader = NULL;
|
||||
PlainShader = NULL;
|
||||
PlainStencilShader = NULL;
|
||||
DimShader = NULL;
|
||||
ColorOnlyShader = NULL;
|
||||
GammaFixerShader = NULL;
|
||||
BurnShader = NULL;
|
||||
FBFormat = D3DFMT_UNKNOWN;
|
||||
|
@ -193,8 +196,8 @@ D3DFB::D3DFB (int width, int height, bool fullscreen)
|
|||
InScene = false;
|
||||
|
||||
Gamma = 1.0;
|
||||
FlashConstants[0][3] = FlashConstants[0][2] = FlashConstants[0][1] = FlashConstants[0][0] = 0;
|
||||
FlashConstants[1][3] = FlashConstants[1][2] = FlashConstants[1][1] = FlashConstants[1][0] = 1;
|
||||
FlashColor0 = 0;
|
||||
FlashColor1 = 0xFFFFFFFF;
|
||||
FlashColor = 0;
|
||||
FlashAmount = 0;
|
||||
|
||||
|
@ -279,6 +282,8 @@ void D3DFB::SetInitialState()
|
|||
D3DDevice->SetSamplerState(1, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP);
|
||||
D3DDevice->SetSamplerState(1, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
|
||||
|
||||
D3DDevice->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, TRUE);
|
||||
|
||||
SetGamma (Gamma);
|
||||
OldRenderTarget = NULL;
|
||||
}
|
||||
|
@ -337,7 +342,7 @@ bool D3DFB::CreateResources ()
|
|||
}
|
||||
if (FAILED(D3DDevice->CreatePixelShader (PlainShaderDef, &PlainShader)) ||
|
||||
FAILED(D3DDevice->CreatePixelShader (PlainStencilDef, &PlainStencilShader)) ||
|
||||
FAILED(D3DDevice->CreatePixelShader (DimShaderDef, &DimShader)))
|
||||
FAILED(D3DDevice->CreatePixelShader (ColorOnlyDef, &ColorOnlyShader)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -413,10 +418,10 @@ void D3DFB::ReleaseResources ()
|
|||
PlainStencilShader->Release();
|
||||
PlainStencilShader = NULL;
|
||||
}
|
||||
if (DimShader != NULL)
|
||||
if (ColorOnlyShader != NULL)
|
||||
{
|
||||
DimShader->Release();
|
||||
DimShader = NULL;
|
||||
ColorOnlyShader->Release();
|
||||
ColorOnlyShader = NULL;
|
||||
}
|
||||
if (GammaFixerShader != NULL)
|
||||
{
|
||||
|
@ -462,10 +467,10 @@ void D3DFB::ReleaseDefaultPoolItems()
|
|||
InitialWipeScreen->Release();
|
||||
InitialWipeScreen = NULL;
|
||||
}
|
||||
if (VertexBuffer != NULL)
|
||||
if (LineBuffer != NULL)
|
||||
{
|
||||
VertexBuffer->Release();
|
||||
VertexBuffer = NULL;
|
||||
LineBuffer->Release();
|
||||
LineBuffer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -604,59 +609,86 @@ bool D3DFB::CreateShadedPaletteTexture()
|
|||
|
||||
bool D3DFB::CreateVertexes ()
|
||||
{
|
||||
if (FAILED(D3DDevice->CreateVertexBuffer (sizeof(FBVERTEX)*NUM_VERTS, D3DUSAGE_WRITEONLY, D3DFVF_FBVERTEX, D3DPOOL_DEFAULT, &VertexBuffer, NULL)) ||
|
||||
!UploadVertices())
|
||||
if (FAILED(D3DDevice->CreateVertexBuffer(sizeof(FBVERTEX)*NUM_LINE_VERTS,
|
||||
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_FBVERTEX, D3DPOOL_DEFAULT, &LineBuffer, NULL)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
LineBatchPos = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool D3DFB::UploadVertices()
|
||||
void D3DFB::CalcFullscreenCoords (FBVERTEX verts[4], bool viewarea_only, D3DCOLOR color0, D3DCOLOR color1) const
|
||||
{
|
||||
float top = LBOffset - 0.5f;
|
||||
float right = float(Width) - 0.5f;
|
||||
float bot = float(Height) + top;
|
||||
float offset = OldRenderTarget != NULL ? 0 : LBOffset;
|
||||
float top = offset - 0.5f;
|
||||
float texright = float(Width) / float(FBWidth);
|
||||
float texbot = float(Height) / float(FBHeight);
|
||||
void *pverts;
|
||||
float mxl, mxr, myt, myb, tmxl, tmxr, tmyt, tmyb;
|
||||
|
||||
float mxl = float(BlendingRect.left) - 0.5f;
|
||||
float mxr = float(BlendingRect.right) - 0.5f;
|
||||
float myt = float(BlendingRect.top) + top;
|
||||
float myb = float(BlendingRect.bottom) + top;
|
||||
float tmxl = float(BlendingRect.left) / float(Width) * texright;
|
||||
float tmxr = float(BlendingRect.right) / float(Width) * texright;
|
||||
float tmyt = float(BlendingRect.top) / float(Height) * texbot;
|
||||
float tmyb = float(BlendingRect.bottom) / float(Height) * texbot;
|
||||
|
||||
FBVERTEX verts[NUM_VERTS] =
|
||||
{
|
||||
// The whole screen
|
||||
{ -0.5f, top, 0.5f, 1.f, 0.f, 0.f }, // 0
|
||||
{ right, top, 0.5f, 1.f, texright, 0.f },
|
||||
{ right, bot, 0.5f, 1.f, texright, texbot },
|
||||
{ -0.5f, bot, 0.5f, 1.f, 0.f, texbot },
|
||||
|
||||
// 3D view part of the screen
|
||||
{ mxl, myt, 0.5f, 1.f, tmxl, tmyt }, // 4
|
||||
{ mxr, myt, 0.5f, 1.f, tmxr, tmyt },
|
||||
{ mxr, myb, 0.5f, 1.f, tmxr, tmyb },
|
||||
{ mxl, myb, 0.5f, 1.f, tmxl, tmyb },
|
||||
|
||||
// Used when getting the end screen for wipes
|
||||
{ -0.5f, -0.5f, 0.5f, 1.f, 0.f, 0.f }, // 8
|
||||
{ right, -0.5f, 0.5f, 1.f, texright, 0.f },
|
||||
{ right, float(Height) - 0.5f, 0.5f, 1.f, texright, texbot },
|
||||
{ -0.5f, float(Height) - 0.5f, 0.5f, 1.f, 0.f, texbot },
|
||||
};
|
||||
if (SUCCEEDED(VertexBuffer->Lock(0, sizeof(verts), &pverts, 0)))
|
||||
{
|
||||
memcpy (pverts, verts, sizeof(verts));
|
||||
VertexBuffer->Unlock();
|
||||
return true;
|
||||
if (viewarea_only)
|
||||
{ // Just calculate vertices for the viewarea/BlendingRect
|
||||
mxl = float(BlendingRect.left) - 0.5f;
|
||||
mxr = float(BlendingRect.right) - 0.5f;
|
||||
myt = float(BlendingRect.top) + top;
|
||||
myb = float(BlendingRect.bottom) + top;
|
||||
tmxl = float(BlendingRect.left) / float(Width) * texright;
|
||||
tmxr = float(BlendingRect.right) / float(Width) * texright;
|
||||
tmyt = float(BlendingRect.top) / float(Height) * texbot;
|
||||
tmyb = float(BlendingRect.bottom) / float(Height) * texbot;
|
||||
}
|
||||
return false;
|
||||
else
|
||||
{ // Calculate vertices for the whole screen
|
||||
mxl = -0.5f;
|
||||
mxr = float(Width) - 0.5f;
|
||||
myt = top;
|
||||
myb = float(Height) + top;
|
||||
tmxl = 0;
|
||||
tmxr = texright;
|
||||
tmyt = 0;
|
||||
tmyb = texbot;
|
||||
}
|
||||
|
||||
//{ mxl, myt, 0, 1, 0, 0xFFFFFFFF, tmxl, tmyt },
|
||||
//{ mxr, myt, 0, 1, 0, 0xFFFFFFFF, tmxr, tmyt },
|
||||
//{ mxr, myb, 0, 1, 0, 0xFFFFFFFF, tmxr, tmyb },
|
||||
//{ mxl, myb, 0, 1, 0, 0xFFFFFFFF, tmxl, tmyb },
|
||||
|
||||
verts[0].x = mxl;
|
||||
verts[0].y = myt;
|
||||
verts[0].z = 0;
|
||||
verts[0].rhw = 1;
|
||||
verts[0].color0 = color0;
|
||||
verts[0].color1 = color1;
|
||||
verts[0].tu = tmxl;
|
||||
verts[0].tv = tmyt;
|
||||
|
||||
verts[1].x = mxr;
|
||||
verts[1].y = myt;
|
||||
verts[1].z = 0;
|
||||
verts[1].rhw = 1;
|
||||
verts[1].color0 = color0;
|
||||
verts[1].color1 = color1;
|
||||
verts[1].tu = tmxr;
|
||||
verts[1].tv = tmyt;
|
||||
|
||||
verts[2].x = mxr;
|
||||
verts[2].y = myb;
|
||||
verts[2].z = 0;
|
||||
verts[2].rhw = 1;
|
||||
verts[2].color0 = color0;
|
||||
verts[2].color1 = color1;
|
||||
verts[2].tu = tmxr;
|
||||
verts[2].tv = tmyb;
|
||||
|
||||
verts[3].x = mxl;
|
||||
verts[3].y = myb;
|
||||
verts[3].z = 0;
|
||||
verts[3].rhw = 1;
|
||||
verts[3].color0 = color0;
|
||||
verts[3].color1 = color1;
|
||||
verts[3].tu = tmxl;
|
||||
verts[3].tv = tmyb;
|
||||
}
|
||||
|
||||
int D3DFB::GetPageCount ()
|
||||
|
@ -886,14 +918,14 @@ void D3DFB::Draw3DPart(bool copy3d)
|
|||
|
||||
SetTexture (0, FBTexture);
|
||||
SetPaletteTexture(PaletteTexture, 256, false);
|
||||
D3DDevice->SetStreamSource (0, VertexBuffer, 0, sizeof(FBVERTEX));
|
||||
D3DDevice->SetFVF (D3DFVF_FBVERTEX);
|
||||
D3DDevice->SetPixelShaderConstantF (0, FlashConstants[0], 2);
|
||||
memcpy(Constant, FlashConstants, sizeof(FlashConstants));
|
||||
memset(Constant, 0, sizeof(Constant));
|
||||
SetAlphaBlend(FALSE);
|
||||
if (copy3d)
|
||||
{
|
||||
D3DDevice->DrawPrimitive (D3DPT_TRIANGLEFAN, !test2d ? 0 : OldRenderTarget != NULL ? 8 : 4, 2);
|
||||
FBVERTEX verts[4];
|
||||
CalcFullscreenCoords(verts, test2d, FlashColor0, FlashColor1);
|
||||
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -928,13 +960,15 @@ void D3DFB::DoWindowedGamma()
|
|||
{
|
||||
if (OldRenderTarget != NULL)
|
||||
{
|
||||
FBVERTEX verts[4];
|
||||
|
||||
CalcFullscreenCoords(verts, false, 0, 0xFFFFFFFF);
|
||||
D3DDevice->SetRenderTarget(0, OldRenderTarget);
|
||||
D3DDevice->SetStreamSource(0, VertexBuffer, 0, sizeof(FBVERTEX));
|
||||
D3DDevice->SetFVF(D3DFVF_FBVERTEX);
|
||||
SetTexture(0, TempRenderTexture);
|
||||
SetPixelShader((Windowed && GammaFixerShader != NULL) ? GammaFixerShader : PlainShader);
|
||||
SetAlphaBlend(FALSE);
|
||||
D3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
|
||||
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX));
|
||||
OldRenderTarget->Release();
|
||||
OldRenderTarget = NULL;
|
||||
}
|
||||
|
@ -985,13 +1019,9 @@ bool D3DFB::SetFlash (PalEntry rgb, int amount)
|
|||
|
||||
// Fill in the constants for the pixel shader to do linear interpolation between the palette and the flash:
|
||||
float r = rgb.r / 255.f, g = rgb.g / 255.f, b = rgb.b / 255.f, a = amount / 256.f;
|
||||
FlashConstants[0][0] = r * a;
|
||||
FlashConstants[0][1] = g * a;
|
||||
FlashConstants[0][2] = b * a;
|
||||
FlashColor0 = D3DCOLOR_COLORVALUE(r * a, g * a, b * a, 0);
|
||||
a = 1 - a;
|
||||
FlashConstants[1][0] = a;
|
||||
FlashConstants[1][1] = a;
|
||||
FlashConstants[1][2] = a;
|
||||
FlashColor1 = D3DCOLOR_COLORVALUE(a, a, a, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1026,18 +1056,10 @@ void D3DFB::Blank ()
|
|||
|
||||
void D3DFB::SetBlendingRect(int x1, int y1, int x2, int y2)
|
||||
{
|
||||
if (BlendingRect.left != x1 ||
|
||||
BlendingRect.top != y1 ||
|
||||
BlendingRect.right != x2 ||
|
||||
BlendingRect.bottom != y2)
|
||||
{
|
||||
BlendingRect.left = x1;
|
||||
BlendingRect.top = y1;
|
||||
BlendingRect.right = x2;
|
||||
BlendingRect.bottom = y2;
|
||||
|
||||
UploadVertices();
|
||||
}
|
||||
BlendingRect.left = x1;
|
||||
BlendingRect.top = y1;
|
||||
BlendingRect.right = x2;
|
||||
BlendingRect.bottom = y2;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
|
@ -1473,20 +1495,140 @@ void D3DFB::Dim (PalEntry color, float amount, int x1, int y1, int w, int h)
|
|||
{
|
||||
float x = float(x1) - 0.5f;
|
||||
float y = float(y1) - 0.5f + (GatheringWipeScreen ? 0 : LBOffset);
|
||||
D3DCOLOR d3dcolor = color | (int(amount * 255) << 24);
|
||||
FBVERTEX verts[4] =
|
||||
{
|
||||
{ x, y, 0.5f, 1, 0, 0 },
|
||||
{ x+w, y, 0.5f, 1, 0, 0 },
|
||||
{ x+w, y+h, 0.5f, 1, 0, 0 },
|
||||
{ x, y+h, 0.5f, 1, 0, 0 }
|
||||
{ x, y, 0, 1, d3dcolor },
|
||||
{ x+w, y, 0, 1, d3dcolor },
|
||||
{ x+w, y+h, 0, 1, d3dcolor },
|
||||
{ x, y+h, 0, 1, d3dcolor }
|
||||
};
|
||||
SetAlphaBlend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
|
||||
SetPixelShader(DimShader);
|
||||
SetConstant(1, color.r/255.f, color.g/255.f, color.b/255.f, amount);
|
||||
SetPixelShader(ColorOnlyShader);
|
||||
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, &verts, sizeof(FBVERTEX));
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D3DFB :: BeginLineDrawing
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void D3DFB::BeginLineDrawing()
|
||||
{
|
||||
if (In2D < 2 || !InScene || LineBatchPos >= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LineBuffer->Lock(0, 0, (void **)&LineData, D3DLOCK_DISCARD);
|
||||
LineBatchPos = 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D3DFB :: EndLineDrawing
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void D3DFB::EndLineDrawing()
|
||||
{
|
||||
if (In2D < 2 || !InScene || LineBatchPos < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LineBuffer->Unlock();
|
||||
if (LineBatchPos > 0)
|
||||
{
|
||||
SetPixelShader(ColorOnlyShader);
|
||||
SetAlphaBlend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
|
||||
D3DDevice->SetStreamSource(0, LineBuffer, 0, sizeof(FBVERTEX));
|
||||
D3DDevice->DrawPrimitive(D3DPT_LINELIST, 0, LineBatchPos / 2);
|
||||
}
|
||||
LineBatchPos = -1;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D3DFB :: DrawLine
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void D3DFB::DrawLine(int x0, int y0, int x1, int y1, int palcolor, uint32 color)
|
||||
{
|
||||
if (In2D < 2)
|
||||
{
|
||||
Super::DrawLine(x0, y0, x1, y1, palcolor, color);
|
||||
return;
|
||||
}
|
||||
if (!InScene)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (LineBatchPos == NUM_LINE_VERTS)
|
||||
{ // flush the buffer and refill it
|
||||
EndLineDrawing();
|
||||
BeginLineDrawing();
|
||||
}
|
||||
if (LineBatchPos >= 0)
|
||||
{ // Batched drawing: Add the endpoints to the vertex buffer.
|
||||
LineData[LineBatchPos].x = float(x0);
|
||||
LineData[LineBatchPos].y = float(y0) + LBOffset;
|
||||
LineData[LineBatchPos].z = 0;
|
||||
LineData[LineBatchPos].rhw = 1;
|
||||
LineData[LineBatchPos].color0 = color;
|
||||
LineData[LineBatchPos].color1 = 0;
|
||||
LineData[LineBatchPos].tu = 0;
|
||||
LineData[LineBatchPos].tv = 0;
|
||||
LineData[LineBatchPos+1].x = float(x1);
|
||||
LineData[LineBatchPos+1].y = float(y1) + LBOffset;
|
||||
LineData[LineBatchPos+1].z = 0;
|
||||
LineData[LineBatchPos+1].rhw = 1;
|
||||
LineData[LineBatchPos+1].color0 = color;
|
||||
LineData[LineBatchPos+1].color1 = 0;
|
||||
LineData[LineBatchPos+1].tu = 0;
|
||||
LineData[LineBatchPos+1].tv = 0;
|
||||
LineBatchPos += 2;
|
||||
}
|
||||
else
|
||||
{ // Unbatched drawing: Draw it right now.
|
||||
FBVERTEX endpts[2] =
|
||||
{
|
||||
{ float(x0), float(y0), 0, 1, color },
|
||||
{ float(x1), float(y1), 0, 1, color }
|
||||
};
|
||||
SetPixelShader(ColorOnlyShader);
|
||||
SetAlphaBlend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
|
||||
D3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, endpts, sizeof(FBVERTEX));
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D3DFB :: DrawPixel
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void D3DFB::DrawPixel(int x, int y, int palcolor, uint32 color)
|
||||
{
|
||||
if (In2D < 2)
|
||||
{
|
||||
Super::DrawPixel(x, y, palcolor, color);
|
||||
return;
|
||||
}
|
||||
if (!InScene)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FBVERTEX pt =
|
||||
{
|
||||
float(x), float(y), 0, 1, color
|
||||
};
|
||||
SetPixelShader(ColorOnlyShader);
|
||||
SetAlphaBlend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
|
||||
D3DDevice->DrawPrimitiveUP(D3DPT_POINTLIST, 1, &pt, sizeof(FBVERTEX));
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// D3DFB :: DrawTextureV
|
||||
|
@ -1571,20 +1713,21 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
|||
x1 -= 0.5f;
|
||||
y1 -= yoffs;
|
||||
|
||||
FBVERTEX verts[4] =
|
||||
{
|
||||
{ x0, y0, 0.5f, 1.f, u0, v0 },
|
||||
{ x1, y0, 0.5f, 1.f, u1, v0 },
|
||||
{ x1, y1, 0.5f, 1.f, u1, v1 },
|
||||
{ x0, y1, 0.5f, 1.f, u0, v1 }
|
||||
};
|
||||
|
||||
D3DCOLOR color0, color1;
|
||||
parms.bilinear = false;
|
||||
if (!SetStyle(tex, parms))
|
||||
if (!SetStyle(tex, parms, color0, color1))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
FBVERTEX verts[4] =
|
||||
{
|
||||
{ x0, y0, 0, 1, color0, color1, u0, v0 },
|
||||
{ x1, y0, 0, 1, color0, color1, u1, v0 },
|
||||
{ x1, y1, 0, 1, color0, color1, u1, v1 },
|
||||
{ x0, y1, 0, 1, color0, color1, u0, v1 }
|
||||
};
|
||||
|
||||
SetTexture(0, tex->Tex);
|
||||
D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, &verts, sizeof(FBVERTEX));
|
||||
}
|
||||
|
@ -1597,7 +1740,7 @@ void STACK_ARGS D3DFB::DrawTextureV (FTexture *img, int x, int y, uint32 tags_fi
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms)
|
||||
bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1)
|
||||
{
|
||||
D3DFORMAT fmt = tex->GetTexFormat();
|
||||
ERenderStyle style = parms.style;
|
||||
|
@ -1632,7 +1775,8 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms)
|
|||
case STYLE_Shaded:
|
||||
if (alpha > 0)
|
||||
{
|
||||
SetConstant(1, RPART(parms.fillcolor)/255.f, GPART(parms.fillcolor)/255.f, BPART(parms.fillcolor)/255.f, alpha);
|
||||
color0 = 0;
|
||||
color1 = parms.fillcolor | (D3DCOLOR(alpha * 255) << 24);
|
||||
SetPaletteTexture(ShadedPaletteTexture, 256, parms.bilinear);
|
||||
if (parms.bilinear)
|
||||
{
|
||||
|
@ -1681,7 +1825,7 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms)
|
|||
if (!parms.masked && style == STYLE_Normal)
|
||||
{
|
||||
SetAlphaBlend(FALSE);
|
||||
SetColorOverlay(parms.colorOverlay, 1);
|
||||
SetColorOverlay(parms.colorOverlay, 1, color0, color1);
|
||||
if (fmt == D3DFMT_L8 && !tex->IsGray)
|
||||
{
|
||||
SetPaletteTexture(PaletteTexture, 256, parms.bilinear);
|
||||
|
@ -1729,14 +1873,12 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms)
|
|||
{
|
||||
SetPixelShader(PlainShader);
|
||||
}
|
||||
SetColorOverlay(parms.colorOverlay, alpha);
|
||||
SetColorOverlay(parms.colorOverlay, alpha, color0, color1);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetConstant(1,
|
||||
RPART(parms.fillcolor)/255.f,
|
||||
GPART(parms.fillcolor)/255.f,
|
||||
BPART(parms.fillcolor)/255.f, alpha);
|
||||
color0 = 0;
|
||||
color1 = parms.fillcolor | (D3DCOLOR(alpha * 255) << 24);
|
||||
if (fmt == D3DFMT_L8)
|
||||
{
|
||||
// Doesn't seem to be much point in allowing bilinear with a stencil
|
||||
|
@ -1751,22 +1893,23 @@ bool D3DFB::SetStyle(D3DTex *tex, DrawParms &parms)
|
|||
return true;
|
||||
}
|
||||
|
||||
void D3DFB::SetColorOverlay(DWORD color, float alpha)
|
||||
void D3DFB::SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1)
|
||||
{
|
||||
if (APART(color) != 0)
|
||||
{
|
||||
float a = APART(color) / (255.f * 255.f);
|
||||
float r = RPART(color) * a;
|
||||
float g = GPART(color) * a;
|
||||
float b = BPART(color) * a;
|
||||
SetConstant(0, r, g, b, 0);
|
||||
a = 1 - a * 255;
|
||||
SetConstant(1, a, a, a, alpha);
|
||||
int a = APART(color) * 256 / 255;
|
||||
color0 = D3DCOLOR_RGBA(
|
||||
(RPART(color) * a) >> 8,
|
||||
(GPART(color) * a) >> 8,
|
||||
(BPART(color) * a) >> 8,
|
||||
0);
|
||||
a = 256 - a;
|
||||
color1 = D3DCOLOR_RGBA(a, a, a, int(alpha * 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetConstant(0, 0, 0, 0, 0);
|
||||
SetConstant(1, 1, 1, 1, alpha);
|
||||
color0 = 0;
|
||||
color1 = D3DCOLOR_COLORVALUE(1, 1, 1, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,36 +4,28 @@
|
|||
// A paletted texture shader ------------------------------------------------
|
||||
|
||||
#if HLSL_SOURCE_CODE
|
||||
// Technically, Palette only needs to be a sampler1D, but that
|
||||
// produces assembly code to copy index.x to index.y, which is
|
||||
// totally unnecessary.
|
||||
|
||||
sampler2D Image : register(s0);
|
||||
sampler2D Palette : register(s1);
|
||||
float4 Flash : register(c0);
|
||||
float4 InvFlash : register(c1);
|
||||
sampler1D Palette : register(s1);
|
||||
float4 PaletteMod : register(c2);
|
||||
|
||||
float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
||||
float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR
|
||||
{
|
||||
float4 index = tex2D (Image, texCoord);
|
||||
index.x = index.x * PaletteMod.x + PaletteMod.y;
|
||||
float4 rgb = tex2D (Palette, index);
|
||||
float index = tex2D (Image, texCoord).x;
|
||||
index = index * PaletteMod.x + PaletteMod.y;
|
||||
float4 rgb = tex1D (Palette, index);
|
||||
return Flash + rgb * InvFlash;
|
||||
}
|
||||
#elif SHADER_ASSEMBLY_CODE
|
||||
//
|
||||
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000
|
||||
//
|
||||
// fxc paltex.ps /Tps_1_4 /VnPalTexShader14Def /Fh
|
||||
// fxc paltex.ps /Tps_1_4 /LD /VnPalTexShader14Def /Fhpaltex.h
|
||||
//
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// float4 Flash;
|
||||
// sampler2D Image;
|
||||
// float4 InvFlash;
|
||||
// sampler2D Palette;
|
||||
// sampler1D Palette;
|
||||
// float4 PaletteMod;
|
||||
//
|
||||
//
|
||||
|
@ -41,8 +33,6 @@ float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
|||
//
|
||||
// Name Reg Size
|
||||
// ------------ ----- ----
|
||||
// Flash c0 1
|
||||
// InvFlash c1 1
|
||||
// PaletteMod c2 1
|
||||
// Image s0 1
|
||||
// Palette s1 1
|
||||
|
@ -50,43 +40,43 @@ float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
|||
|
||||
ps_1_4
|
||||
texld r0, t0
|
||||
mad r0.x, r0.x, c2.x, c2.y
|
||||
mad r0.xy, r0.x, c2.x, c2.y
|
||||
phase
|
||||
texld r1, r0
|
||||
mad r0, r1, c1, c0
|
||||
mad r0, r1, v1, v0
|
||||
|
||||
// approximately 4 instruction slots used (2 texture, 2 arithmetic)
|
||||
#endif
|
||||
|
||||
const DWORD PalTexShader14Def[] =
|
||||
{
|
||||
0xffff0104, 0x0043fffe, 0x42415443, 0x0000001c, 0x000000d3, 0xffff0104,
|
||||
0x00000005, 0x0000001c, 0x00000100, 0x000000cc, 0x00000080, 0x00000002,
|
||||
0x00020001, 0x00000088, 0x00000000, 0x00000098, 0x00000003, 0x00000001,
|
||||
0x000000a0, 0x00000000, 0x000000b0, 0x00010002, 0x00020001, 0x00000088,
|
||||
0x00000000, 0x000000b9, 0x00010003, 0x00000001, 0x000000a0, 0x00000000,
|
||||
0x000000c1, 0x00020002, 0x00020001, 0x00000088, 0x00000000, 0x73616c46,
|
||||
0xabab0068, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x67616d49,
|
||||
0xabab0065, 0x000c0004, 0x00010001, 0x00000001, 0x00000000, 0x46766e49,
|
||||
0x6873616c, 0x6c615000, 0x65747465, 0x6c615000, 0x65747465, 0x00646f4d,
|
||||
0x315f7370, 0x4d00345f, 0x6f726369, 0x74666f73, 0x29522820, 0x44334420,
|
||||
0x53203958, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e35312e,
|
||||
0x2e393737, 0x30303030, 0xababab00, 0x00000042, 0x800f0000, 0xb0e40000,
|
||||
0x00000004, 0x80010000, 0x80000000, 0xa0000002, 0xa0550002, 0x0000fffd,
|
||||
0x00000042, 0x800f0001, 0x80e40000, 0x00000004, 0x800f0000, 0x80e40001,
|
||||
0xa0e40001, 0xa0e40000, 0x0000ffff
|
||||
0xffff0104, 0x0039fffe, 0x42415443, 0x0000001c, 0x000000ab, 0xffff0104,
|
||||
0x00000003, 0x0000001c, 0x00000100, 0x000000a4, 0x00000058, 0x00000003,
|
||||
0x00000001, 0x00000060, 0x00000000, 0x00000070, 0x00010003, 0x00000001,
|
||||
0x00000078, 0x00000000, 0x00000088, 0x00020002, 0x00020001, 0x00000094,
|
||||
0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001,
|
||||
0x00000000, 0x656c6150, 0x00657474, 0x000b0004, 0x00010001, 0x00000001,
|
||||
0x00000000, 0x656c6150, 0x4d657474, 0xab00646f, 0x00030001, 0x00040001,
|
||||
0x00000001, 0x00000000, 0x315f7370, 0x4d00345f, 0x6f726369, 0x74666f73,
|
||||
0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072, 0x6c69706d,
|
||||
0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00, 0x00000042,
|
||||
0x800f0000, 0xb0e40000, 0x00000004, 0x80030000, 0x80000000, 0xa0000002,
|
||||
0xa0550002, 0x0000fffd, 0x00000042, 0x800f0001, 0x80e40000, 0x00000004,
|
||||
0x800f0000, 0x80e40001, 0x90e40001, 0x90e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
#if SHADER_ASSEMBLY_CODE
|
||||
ps_2_0
|
||||
dcl t0.xy
|
||||
dcl v0
|
||||
dcl v1
|
||||
dcl_2d s0
|
||||
dcl_2d s1
|
||||
texld r0, t0, s0
|
||||
mad r0.x, r0.x, c2.x, c2.y
|
||||
mad r0.xy, r0.x, c2.x, c2.y
|
||||
texld r0, r0, s1
|
||||
mov r1, c1
|
||||
mad r0, r0, r1, c0
|
||||
mov r1, v1
|
||||
mad r0, r0, r1, v0
|
||||
mov oC0, r0
|
||||
|
||||
// approximately 6 instruction slots used (2 texture, 4 arithmetic)
|
||||
|
@ -94,24 +84,23 @@ const DWORD PalTexShader14Def[] =
|
|||
|
||||
const DWORD PalTexShader20Def[] =
|
||||
{
|
||||
0xffff0200, 0x0043fffe, 0x42415443, 0x0000001c, 0x000000d3, 0xffff0200,
|
||||
0x00000005, 0x0000001c, 0x00000100, 0x000000cc, 0x00000080, 0x00000002,
|
||||
0x00020001, 0x00000088, 0x00000000, 0x00000098, 0x00000003, 0x00000001,
|
||||
0x000000a0, 0x00000000, 0x000000b0, 0x00010002, 0x00020001, 0x00000088,
|
||||
0x00000000, 0x000000b9, 0x00010003, 0x00000001, 0x000000a0, 0x00000000,
|
||||
0x000000c1, 0x00020002, 0x00020001, 0x00000088, 0x00000000, 0x73616c46,
|
||||
0xabab0068, 0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x67616d49,
|
||||
0xabab0065, 0x000c0004, 0x00010001, 0x00000001, 0x00000000, 0x46766e49,
|
||||
0x6873616c, 0x6c615000, 0x65747465, 0x6c615000, 0x65747465, 0x00646f4d,
|
||||
0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820, 0x44334420,
|
||||
0x53203958, 0x65646168, 0x6f432072, 0x6c69706d, 0x39207265, 0x2e35312e,
|
||||
0x2e393737, 0x30303030, 0xababab00, 0x0200001f, 0x80000000, 0xb0030000,
|
||||
0x0200001f, 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801,
|
||||
0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x04000004, 0x80010000,
|
||||
0x80000000, 0xa0000002, 0xa0550002, 0x03000042, 0x800f0000, 0x80e40000,
|
||||
0xa0e40801, 0x02000001, 0x800f0001, 0xa0e40001, 0x04000004, 0x800f0000,
|
||||
0x80e40000, 0x80e40001, 0xa0e40000, 0x02000001, 0x800f0800, 0x80e40000,
|
||||
0x0000ffff
|
||||
0xffff0200, 0x0039fffe, 0x42415443, 0x0000001c, 0x000000ab, 0xffff0200,
|
||||
0x00000003, 0x0000001c, 0x00000100, 0x000000a4, 0x00000058, 0x00000003,
|
||||
0x00000001, 0x00000060, 0x00000000, 0x00000070, 0x00010003, 0x00000001,
|
||||
0x00000078, 0x00000000, 0x00000088, 0x00020002, 0x00020001, 0x00000094,
|
||||
0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001,
|
||||
0x00000000, 0x656c6150, 0x00657474, 0x000b0004, 0x00010001, 0x00000001,
|
||||
0x00000000, 0x656c6150, 0x4d657474, 0xab00646f, 0x00030001, 0x00040001,
|
||||
0x00000001, 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73,
|
||||
0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072, 0x6c69706d,
|
||||
0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00, 0x0200001f,
|
||||
0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f,
|
||||
0x80000000, 0x900f0001, 0x0200001f, 0x90000000, 0xa00f0800, 0x0200001f,
|
||||
0x90000000, 0xa00f0801, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
|
||||
0x04000004, 0x80030000, 0x80000000, 0xa0000002, 0xa0550002, 0x03000042,
|
||||
0x800f0000, 0x80e40000, 0xa0e40801, 0x02000001, 0x800f0001, 0x90e40001,
|
||||
0x04000004, 0x800f0000, 0x80e40000, 0x80e40001, 0x90e40000, 0x02000001,
|
||||
0x800f0800, 0x80e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
// A paletted texture shader that does bilinear filtering -------------------
|
||||
|
@ -265,10 +254,8 @@ const DWORD PalTexBilinearDef[] =
|
|||
|
||||
#if HLSL_SOURCE_CODE
|
||||
sampler2D Image : register(s0);
|
||||
float4 Flash : register(c0);
|
||||
float4 InvFlash : register(c1);
|
||||
|
||||
float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
||||
float4 main (float2 texCoord : TEXCOORD0, float4 Flash : COLOR0, float4 InvFlash : COLOR1) : COLOR
|
||||
{
|
||||
float4 index = tex2D (Image, texCoord);
|
||||
return Flash + index * InvFlash;
|
||||
|
@ -277,55 +264,46 @@ float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
|||
//
|
||||
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000
|
||||
//
|
||||
// fxc shadetex.ps /Tps_1_4 /VnPlainShaderDef /Fh
|
||||
// fxc plain.ps /Tps_1_1 /LD /VnPlainShaderDef /Fhplain.h
|
||||
//
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// float4 Flash;
|
||||
// sampler2D Image;
|
||||
// float4 InvFlash;
|
||||
//
|
||||
//
|
||||
// Registers:
|
||||
//
|
||||
// Name Reg Size
|
||||
// ------------ ----- ----
|
||||
// Flash c0 1
|
||||
// InvFlash c1 1
|
||||
// Image s0 1
|
||||
//
|
||||
|
||||
ps_1_4
|
||||
texld r0, t0
|
||||
mad r0, r0, c1, c0
|
||||
ps_1_1
|
||||
tex t0
|
||||
mad r0, t0, v1, v0
|
||||
|
||||
// approximately 2 instruction slots used (1 texture, 1 arithmetic)
|
||||
#endif
|
||||
|
||||
const DWORD PlainShaderDef[] =
|
||||
{
|
||||
0xffff0104, 0x0034fffe, 0x42415443, 0x0000001c, 0x00000098, 0xffff0104,
|
||||
0x00000003, 0x0000001c, 0x00000100, 0x00000091, 0x00000058, 0x00000002,
|
||||
0x00020001, 0x00000060, 0x00000000, 0x00000070, 0x00000003, 0x00000001,
|
||||
0x00000078, 0x00000000, 0x00000088, 0x00010002, 0x00020001, 0x00000060,
|
||||
0x00000000, 0x73616c46, 0xabab0068, 0x00030001, 0x00040001, 0x00000001,
|
||||
0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001,
|
||||
0x00000000, 0x46766e49, 0x6873616c, 0x5f737000, 0x00345f31, 0x7263694d,
|
||||
0x666f736f, 0x52282074, 0x33442029, 0x20395844, 0x64616853, 0x43207265,
|
||||
0x69706d6f, 0x2072656c, 0x35312e39, 0x3937372e, 0x3030302e, 0xabab0030,
|
||||
0x00000042, 0x800f0000, 0xb0e40000, 0x00000004, 0x800f0000, 0x80e40000,
|
||||
0xa0e40001, 0xa0e40000, 0x0000ffff
|
||||
0xffff0101, 0x0022fffe, 0x42415443, 0x0000001c, 0x0000004f, 0xffff0101,
|
||||
0x00000001, 0x0000001c, 0x00000100, 0x00000048, 0x00000030, 0x00000003,
|
||||
0x00000001, 0x00000038, 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004,
|
||||
0x00010001, 0x00000001, 0x00000000, 0x315f7370, 0x4d00315f, 0x6f726369,
|
||||
0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072,
|
||||
0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00,
|
||||
0x00000042, 0xb00f0000, 0x00000004, 0x800f0000, 0xb0e40000, 0x90e40001,
|
||||
0x90e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
// A shader that returns the value of c1 for color --------------------------
|
||||
// but keeps the texture's alpha.
|
||||
// A shader that uses vertex color and texture alpha ------------------------
|
||||
|
||||
#if HLSL_SOURCE_CODE
|
||||
sampler2D Image : register(s0);
|
||||
float4 StencilColor : register(c1);
|
||||
|
||||
float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
||||
float4 main (float2 texCoord : TEXCOORD0, float4 StencilColor : COLOR1) : COLOR
|
||||
{
|
||||
float4 color = tex2D (Image, texCoord);
|
||||
color.rgb = StencilColor.rgb;
|
||||
|
@ -335,26 +313,24 @@ float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
|||
//
|
||||
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000
|
||||
//
|
||||
// fxc plainstencil.ps /Tps_1_1 /VnPlainStencilDef /Fh
|
||||
// fxc plainstencil.ps /Tps_1_1 /LD /VnPlainStencilDef /Fhplainstencil.h
|
||||
//
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// sampler2D Image;
|
||||
// float4 StencilColor;
|
||||
//
|
||||
//
|
||||
// Registers:
|
||||
//
|
||||
// Name Reg Size
|
||||
// ------------ ----- ----
|
||||
// StencilColor c1 1
|
||||
// Image s0 1
|
||||
//
|
||||
|
||||
ps_1_1
|
||||
tex t0
|
||||
mov r0.xyz, c1
|
||||
mov r0.xyz, v1
|
||||
+ mov r0.w, t0.w
|
||||
|
||||
// approximately 2 instruction slots used (1 texture, 1 arithmetic)
|
||||
|
@ -362,61 +338,42 @@ float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
|||
|
||||
const DWORD PlainStencilDef[] =
|
||||
{
|
||||
0xffff0101, 0x002ffffe, 0x42415443, 0x0000001c, 0x00000083, 0xffff0101,
|
||||
0x00000002, 0x0000001c, 0x00000100, 0x0000007c, 0x00000044, 0x00000003,
|
||||
0x00000001, 0x0000004c, 0x00000000, 0x0000005c, 0x00010002, 0x00020001,
|
||||
0x0000006c, 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001,
|
||||
0x00000001, 0x00000000, 0x6e657453, 0x436c6963, 0x726f6c6f, 0xababab00,
|
||||
0x00030001, 0x00040001, 0x00000001, 0x00000000, 0x315f7370, 0x4d00315f,
|
||||
0x6f726369, 0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168,
|
||||
0x6f432072, 0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030,
|
||||
0xababab00, 0x00000042, 0xb00f0000, 0x00000001, 0x80070000, 0xa0e40001,
|
||||
0x40000001, 0x80080000, 0xb0ff0000, 0x0000ffff
|
||||
0xffff0101, 0x0022fffe, 0x42415443, 0x0000001c, 0x0000004f, 0xffff0101,
|
||||
0x00000001, 0x0000001c, 0x00000100, 0x00000048, 0x00000030, 0x00000003,
|
||||
0x00000001, 0x00000038, 0x00000000, 0x67616d49, 0xabab0065, 0x000c0004,
|
||||
0x00010001, 0x00000001, 0x00000000, 0x315f7370, 0x4d00315f, 0x6f726369,
|
||||
0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072,
|
||||
0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00,
|
||||
0x00000042, 0xb00f0000, 0x00000001, 0x80070000, 0x90e40001, 0x40000001,
|
||||
0x80080000, 0xb0ff0000, 0x0000ffff
|
||||
};
|
||||
|
||||
// A shader that just returns the value of c1 -------------------------------
|
||||
// A shader that just returns the first color component from the vertex -----
|
||||
|
||||
#if HLSL_SOURCE_CODE
|
||||
float4 Color : register(c1);
|
||||
|
||||
float4 main () : COLOR
|
||||
float4 main (float4 color : COLOR0) : COLOR
|
||||
{
|
||||
return Color;
|
||||
return color;
|
||||
}
|
||||
#elif SHADER_ASSEMBLY_CODE
|
||||
//
|
||||
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000
|
||||
//
|
||||
// fxc dimshader.ps /Tps_1_1 /VnDimShader /Fh
|
||||
// fxc coloronlyshader.ps /Tps_1_1 /LD /VnColorOnlyDef /Fhcoloronly.h
|
||||
//
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// float4 Color;
|
||||
//
|
||||
//
|
||||
// Registers:
|
||||
//
|
||||
// Name Reg Size
|
||||
// ------------ ----- ----
|
||||
// Color c1 1
|
||||
//
|
||||
|
||||
ps_1_1
|
||||
mov r0, c1
|
||||
mov r0, v0
|
||||
|
||||
// approximately 1 instruction slot used
|
||||
#endif
|
||||
|
||||
const DWORD DimShaderDef[] =
|
||||
const DWORD ColorOnlyDef[] =
|
||||
{
|
||||
0xffff0101, 0x0022fffe, 0x42415443, 0x0000001c, 0x0000004f, 0xffff0101,
|
||||
0x00000001, 0x0000001c, 0x00000100, 0x00000048, 0x00000030, 0x00010002,
|
||||
0x00020001, 0x00000038, 0x00000000, 0x6f6c6f43, 0xabab0072, 0x00030001,
|
||||
0x00040001, 0x00000001, 0x00000000, 0x315f7370, 0x4d00315f, 0x6f726369,
|
||||
0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168, 0x6f432072,
|
||||
0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030, 0xababab00,
|
||||
0x00000001, 0x800f0000, 0xa0e40001, 0x0000ffff
|
||||
0xffff0101, 0x0017fffe, 0x42415443, 0x0000001c, 0x00000023, 0xffff0101,
|
||||
0x00000000, 0x00000000, 0x00000100, 0x0000001c, 0x315f7370, 0x4d00315f,
|
||||
0x6f726369, 0x74666f73, 0x29522820, 0x44334420, 0x53203958, 0x65646168,
|
||||
0x6f432072, 0x6c69706d, 0x39207265, 0x2e35312e, 0x2e393737, 0x30303030,
|
||||
0xababab00, 0x00000001, 0x800f0000, 0x90e40000, 0x0000ffff
|
||||
};
|
||||
|
||||
// A shader that just corrects gamma for windowed mode ----------------------
|
||||
|
|
|
@ -460,14 +460,14 @@ bool D3DFB::Wiper_Crossfade::Run(int ticks, D3DFB *fb)
|
|||
}
|
||||
|
||||
// Draw the new screen on top of it.
|
||||
fb->D3DDevice->SetStreamSource(0, fb->VertexBuffer, 0, sizeof(FBVERTEX));
|
||||
FBVERTEX verts[4];
|
||||
|
||||
fb->CalcFullscreenCoords(verts, false, D3DCOLOR_COLORVALUE(0,0,0,Clock / 32.f), D3DCOLOR_RGBA(255,255,255,0));
|
||||
fb->D3DDevice->SetFVF(D3DFVF_FBVERTEX);
|
||||
fb->SetTexture(0, fb->FinalWipeScreen);
|
||||
fb->SetAlphaBlend(TRUE, D3DBLEND_SRCALPHA, D3DBLEND_INVSRCALPHA);
|
||||
fb->SetConstant(0, 0, 0, 0, clamp(Clock / 32.f, 0.f, 1.f));
|
||||
fb->SetConstant(1, 1, 1, 1, 0);
|
||||
fb->SetPixelShader(fb->PlainShader);
|
||||
fb->D3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
|
||||
fb->D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX));
|
||||
|
||||
return Clock >= 32;
|
||||
}
|
||||
|
@ -518,14 +518,14 @@ bool D3DFB::Wiper_Melt::Run(int ticks, D3DFB *fb)
|
|||
}
|
||||
|
||||
// Draw the new screen on the bottom.
|
||||
fb->D3DDevice->SetStreamSource(0, fb->VertexBuffer, 0, sizeof(FBVERTEX));
|
||||
FBVERTEX verts[4];
|
||||
|
||||
fb->CalcFullscreenCoords(verts, false, 0, 0xFFFFFFFF);
|
||||
fb->D3DDevice->SetFVF(D3DFVF_FBVERTEX);
|
||||
fb->SetTexture(0, fb->FinalWipeScreen);
|
||||
fb->SetAlphaBlend(FALSE);
|
||||
fb->SetConstant(0, 0, 0, 0, 0);
|
||||
fb->SetConstant(1, 1, 1, 1, 1);
|
||||
fb->SetPixelShader(fb->PlainShader);
|
||||
fb->D3DDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2);
|
||||
fb->D3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, verts, sizeof(FBVERTEX));
|
||||
|
||||
int i, dy;
|
||||
bool done;
|
||||
|
|
|
@ -242,6 +242,10 @@ public:
|
|||
void STACK_ARGS DrawTextureV (FTexture *img, int x, int y, uint32 tag, va_list tags);
|
||||
void Clear (int left, int top, int right, int bottom, int palcolor, uint32 color);
|
||||
void Dim (PalEntry color, float amount, int x1, int y1, int w, int h);
|
||||
void BeginLineDrawing();
|
||||
void EndLineDrawing();
|
||||
void DrawLine(int x0, int y0, int x1, int y1, int palColor, uint32 realcolor);
|
||||
void DrawPixel(int x, int y, int palcolor, uint32 rgbcolor);
|
||||
bool WipeStartScreen(int type);
|
||||
void WipeEndScreen();
|
||||
bool WipeDo(int ticks);
|
||||
|
@ -252,6 +256,14 @@ private:
|
|||
friend class D3DTex;
|
||||
friend class D3DPal;
|
||||
|
||||
struct FBVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw;
|
||||
D3DCOLOR color0, color1;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
#define D3DFVF_FBVERTEX (D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1)
|
||||
|
||||
void SetInitialState();
|
||||
bool CreateResources();
|
||||
void ReleaseResources();
|
||||
|
@ -263,15 +275,15 @@ private:
|
|||
bool CreateVertexes();
|
||||
void UploadPalette();
|
||||
void FillPresentParameters (D3DPRESENT_PARAMETERS *pp, bool fullscreen, bool vsync);
|
||||
bool UploadVertices();
|
||||
void CalcFullscreenCoords (FBVERTEX verts[4], bool viewarea_only, D3DCOLOR color0, D3DCOLOR color1) const;
|
||||
bool Reset();
|
||||
void ReleaseDefaultPoolItems();
|
||||
void KillNativePals();
|
||||
void KillNativeTexs();
|
||||
void DrawLetterbox();
|
||||
void Draw3DPart(bool copy3d);
|
||||
bool SetStyle(D3DTex *tex, DCanvas::DrawParms &parms);
|
||||
void SetColorOverlay(DWORD color, float alpha);
|
||||
bool SetStyle(D3DTex *tex, DCanvas::DrawParms &parms, D3DCOLOR &color0, D3DCOLOR &color1);
|
||||
static void SetColorOverlay(DWORD color, float alpha, D3DCOLOR &color0, D3DCOLOR &color1);
|
||||
void DoWindowedGamma();
|
||||
|
||||
// State
|
||||
|
@ -290,7 +302,7 @@ private:
|
|||
IDirect3DTexture9 *Texture[2];
|
||||
|
||||
PalEntry SourcePalette[256];
|
||||
float FlashConstants[2][4];
|
||||
D3DCOLOR FlashColor0, FlashColor1;
|
||||
PalEntry FlashColor;
|
||||
int FlashAmount;
|
||||
int TrueHeight;
|
||||
|
@ -313,17 +325,20 @@ private:
|
|||
D3DTex *Textures;
|
||||
|
||||
IDirect3DDevice9 *D3DDevice;
|
||||
IDirect3DVertexBuffer9 *VertexBuffer;
|
||||
IDirect3DTexture9 *FBTexture;
|
||||
IDirect3DTexture9 *TempRenderTexture;
|
||||
IDirect3DTexture9 *PaletteTexture;
|
||||
IDirect3DTexture9 *StencilPaletteTexture;
|
||||
IDirect3DTexture9 *ShadedPaletteTexture;
|
||||
|
||||
IDirect3DVertexBuffer9 *LineBuffer;
|
||||
int LineBatchPos;
|
||||
FBVERTEX *LineData;
|
||||
|
||||
IDirect3DPixelShader9 *PalTexShader, *PalTexBilinearShader;
|
||||
IDirect3DPixelShader9 *PlainShader;
|
||||
IDirect3DPixelShader9 *PlainStencilShader;
|
||||
IDirect3DPixelShader9 *DimShader;
|
||||
IDirect3DPixelShader9 *ColorOnlyShader;
|
||||
IDirect3DPixelShader9 *GammaFixerShader;
|
||||
IDirect3DPixelShader9 *BurnShader;
|
||||
|
||||
|
@ -346,13 +361,6 @@ private:
|
|||
Wiper *ScreenWipe;
|
||||
};
|
||||
|
||||
struct FBVERTEX
|
||||
{
|
||||
FLOAT x, y, z, rhw;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
#define D3DFVF_FBVERTEX (D3DFVF_XYZRHW|D3DFVF_TEX1)
|
||||
|
||||
#if 0
|
||||
#define STARTLOG do { if (!dbg) dbg = fopen ("k:/vid.log", "w"); } while(0)
|
||||
#define STOPLOG do { if (dbg) { fclose (dbg); dbg=NULL; } } while(0)
|
||||
|
|
Loading…
Reference in a new issue