2009-07-28 15:32:10 -06:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
2008-12-07 21:46:09 -07:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-07-26 03:52:35 -06:00
|
|
|
#ifndef GCOGL_PIXELSHADER_H
|
|
|
|
#define GCOGL_PIXELSHADER_H
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2010-06-14 08:36:01 -06:00
|
|
|
#include "VideoCommon.h"
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2009-07-26 03:52:35 -06:00
|
|
|
#define I_COLORS "color"
|
|
|
|
#define I_KCOLORS "k"
|
|
|
|
#define I_ALPHA "alphaRef"
|
|
|
|
#define I_TEXDIMS "texdim"
|
|
|
|
#define I_ZBIAS "czbias"
|
2008-12-07 21:46:09 -07:00
|
|
|
#define I_INDTEXSCALE "cindscale"
|
2009-07-26 03:52:35 -06:00
|
|
|
#define I_INDTEXMTX "cindmtx"
|
|
|
|
#define I_FOG "cfog"
|
2010-09-22 20:17:48 -06:00
|
|
|
#define I_PLIGHTS "cLights"
|
|
|
|
#define I_PMATERIALS "cmtrl"
|
|
|
|
|
|
|
|
#define C_COLORS 0
|
|
|
|
#define C_KCOLORS (C_COLORS + 4)
|
|
|
|
#define C_ALPHA (C_KCOLORS + 4)
|
|
|
|
#define C_TEXDIMS (C_ALPHA + 1)
|
|
|
|
#define C_ZBIAS (C_TEXDIMS + 8)
|
|
|
|
#define C_INDTEXSCALE (C_ZBIAS + 2)
|
|
|
|
#define C_INDTEXMTX (C_INDTEXSCALE + 2)
|
|
|
|
#define C_FOG (C_INDTEXMTX + 6)
|
|
|
|
#define C_COLORMATRIX (C_FOG + 2)
|
2010-12-19 14:09:29 -07:00
|
|
|
#define C_PLIGHTS (C_COLORMATRIX + 5)
|
2010-09-22 20:17:48 -06:00
|
|
|
#define C_PMATERIALS (C_PLIGHTS + 40)
|
|
|
|
#define C_PENVCONST_END (C_PMATERIALS + 4)
|
|
|
|
#define PIXELSHADERUID_MAX_VALUES (5 + 32 + 6 + 11 + 2)
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2010-01-17 10:44:09 -07:00
|
|
|
// DO NOT make anything in this class virtual.
|
2008-12-26 03:43:18 -07:00
|
|
|
class PIXELSHADERUID
|
|
|
|
{
|
|
|
|
public:
|
2009-04-11 01:05:57 -06:00
|
|
|
u32 values[PIXELSHADERUID_MAX_VALUES];
|
2008-12-26 03:43:18 -07:00
|
|
|
u16 tevstages, indstages;
|
|
|
|
|
2009-07-26 03:52:35 -06:00
|
|
|
PIXELSHADERUID()
|
|
|
|
{
|
2009-04-11 01:05:57 -06:00
|
|
|
memset(values, 0, PIXELSHADERUID_MAX_VALUES * 4);
|
2008-12-26 03:43:18 -07:00
|
|
|
tevstages = indstages = 0;
|
|
|
|
}
|
2009-07-26 03:52:35 -06:00
|
|
|
|
2008-12-26 03:43:18 -07:00
|
|
|
PIXELSHADERUID(const PIXELSHADERUID& r)
|
|
|
|
{
|
|
|
|
tevstages = r.tevstages;
|
|
|
|
indstages = r.indstages;
|
2009-04-11 01:05:57 -06:00
|
|
|
int N = GetNumValues();
|
|
|
|
_assert_(N <= PIXELSHADERUID_MAX_VALUES);
|
2008-12-26 03:43:18 -07:00
|
|
|
for (int i = 0; i < N; ++i)
|
|
|
|
values[i] = r.values[i];
|
|
|
|
}
|
2009-07-26 03:52:35 -06:00
|
|
|
|
|
|
|
int GetNumValues() const
|
|
|
|
{
|
2009-04-11 01:05:57 -06:00
|
|
|
return tevstages + indstages + 4;
|
2008-12-26 03:43:18 -07:00
|
|
|
}
|
2009-07-26 03:52:35 -06:00
|
|
|
|
2008-12-26 03:43:18 -07:00
|
|
|
bool operator <(const PIXELSHADERUID& _Right) const
|
|
|
|
{
|
|
|
|
if (values[0] < _Right.values[0])
|
|
|
|
return true;
|
|
|
|
else if (values[0] > _Right.values[0])
|
|
|
|
return false;
|
|
|
|
int N = GetNumValues();
|
2009-07-26 03:52:35 -06:00
|
|
|
for (int i = 1; i < N; ++i)
|
|
|
|
{
|
2008-12-26 03:43:18 -07:00
|
|
|
if (values[i] < _Right.values[i])
|
|
|
|
return true;
|
|
|
|
else if (values[i] > _Right.values[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2009-07-26 03:52:35 -06:00
|
|
|
|
2008-12-26 03:43:18 -07:00
|
|
|
bool operator ==(const PIXELSHADERUID& _Right) const
|
|
|
|
{
|
|
|
|
if (values[0] != _Right.values[0])
|
|
|
|
return false;
|
|
|
|
int N = GetNumValues();
|
2009-07-26 03:52:35 -06:00
|
|
|
for (int i = 1; i < N; ++i)
|
|
|
|
{
|
2008-12-26 03:43:18 -07:00
|
|
|
if (values[i] != _Right.values[i])
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-10-20 23:22:18 -06:00
|
|
|
// Different ways to achieve rendering with destination alpha
|
|
|
|
enum DSTALPHA_MODE
|
|
|
|
{
|
|
|
|
DSTALPHA_NONE, // Render normally, without destination alpha
|
|
|
|
DSTALPHA_ALPHA_PASS, // Render normally first, then render again for alpha
|
|
|
|
DSTALPHA_DUAL_SOURCE_BLEND // Use dual-source blending
|
|
|
|
};
|
|
|
|
|
2010-12-19 13:59:23 -07:00
|
|
|
const char *GeneratePixelShaderCode(DSTALPHA_MODE dstAlphaMode, API_TYPE ApiType,u32 maxUniforms, u32 components);
|
2010-10-20 23:22:18 -06:00
|
|
|
void GetPixelShaderId(PIXELSHADERUID *uid, DSTALPHA_MODE dstAlphaMode);
|
2010-01-17 10:44:09 -07:00
|
|
|
|
2009-09-09 21:36:32 -06:00
|
|
|
extern PIXELSHADERUID last_pixel_shader_uid;
|
2008-12-07 21:46:09 -07:00
|
|
|
|
2009-07-26 03:52:35 -06:00
|
|
|
#endif // GCOGL_PIXELSHADER_H
|