cleanup + some eolz

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5842 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
luisr142004 2010-07-06 13:14:51 +00:00
parent 5133793c6c
commit e9e12ff100
19 changed files with 1117 additions and 1141 deletions

View File

@ -66,7 +66,7 @@ bool Initialize()
return false;
}
if (0 < numPlatforms)
if (0 < numPlatforms)
{
cl_platform_id* platforms = new cl_platform_id[numPlatforms];
err = clGetPlatformIDs(numPlatforms, platforms, NULL);
@ -106,7 +106,7 @@ bool Initialize()
return false;
}
// Create a compute context
// Create a compute context
g_context = clCreateContext(cprops, 1, &device_id, NULL, NULL, &err);
if (!g_context)
{
@ -176,8 +176,8 @@ cl_kernel CompileKernel(cl_program program, const char *Function)
cl_kernel kernel = clCreateKernel(program, Function, &err);
if (!kernel || err != CL_SUCCESS)
{
char buffer[1024];
sprintf(buffer, "Failed to create compute kernel '%s' !", Function);
char buffer[1024];
sprintf(buffer, "Failed to create compute kernel '%s' !", Function);
HandleCLError(err, buffer);
return NULL;
}
@ -191,7 +191,7 @@ void Destroy()
#if defined(HAVE_OPENCL) && HAVE_OPENCL
if(!g_context)
return;
clReleaseCommandQueue(g_cmdq);
clReleaseCommandQueue(g_cmdq);
clReleaseContext(g_context);
g_context = NULL;
g_cmdq = NULL;

View File

@ -72,8 +72,8 @@ UDPWiimote::UDPWiimote(const char *_port) :
#ifdef _WIN32
u_long iMode = 1;
#endif
struct addrinfo hints, *servinfo, *p;
int rv;
struct addrinfo hints, *servinfo, *p;
int rv;
d->thread=NULL;
#ifdef _WIN32
@ -89,41 +89,41 @@ UDPWiimote::UDPWiimote(const char *_port) :
noinst++;
//PanicAlert("UDPWii instantiated");
memset(&hints, 0, sizeof hints);
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE; // use my IP
hints.ai_socktype = SOCK_DGRAM;
hints.ai_flags = AI_PASSIVE; // use my IP
if ((rv = getaddrinfo(NULL, _port, &hints, &servinfo)) != 0) {
if ((rv = getaddrinfo(NULL, _port, &hints, &servinfo)) != 0) {
cleanup;
err=-1;
err=-1;
return;
}
}
// loop through all the results and bind to everything we can
for(p = servinfo; p != NULL; p = p->ai_next) {
// loop through all the results and bind to everything we can
for(p = servinfo; p != NULL; p = p->ai_next) {
sock_t sock;
if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == BAD_SOCK) {
if ((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == BAD_SOCK) {
continue;
}
}
if (bind(sock, p->ai_addr, p->ai_addrlen) == -1) {
close(sock);
if (bind(sock, p->ai_addr, p->ai_addrlen) == -1) {
close(sock);
continue;
}
}
//NOTICE_LOG(WIIMOTE,"UDPWii new listening sock");
d->sockfds.push_back(sock);
}
}
if (d->sockfds.empty()) {
if (d->sockfds.empty()) {
cleanup;
err=-2;
return;
}
return;
}
freeaddrinfo(servinfo);
freeaddrinfo(servinfo);
err=0;
d->exit=false;
// NOTICE_LOG(WIIMOTE,"UDPWii thread starting");

View File

@ -103,7 +103,7 @@ public:
UDPConfigDiag::UDPConfigDiag(wxWindow * const parent, UDPWrapper * _wrp) :
wxDialog(parent, -1, wxT("UDP Wiimote"), wxDefaultPosition, wxDefaultSize),
wrp(_wrp)
wrp(_wrp)
{
wxBoxSizer * outer_sizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer * sizer1 = new wxBoxSizer(wxVERTICAL);

View File

@ -204,7 +204,7 @@ void ControlDialog::UpdateListContents()
{
// for inputs
std::vector<ControllerInterface::Device::Input*>::const_iterator
i = dev->Inputs().begin(),
i = dev->Inputs().begin(),
e = dev->Inputs().end();
for (; i!=e; ++i)
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
@ -213,7 +213,7 @@ void ControlDialog::UpdateListContents()
{
// for outputs
std::vector<ControllerInterface::Device::Output*>::const_iterator
i = dev->Outputs().begin(),
i = dev->Outputs().begin(),
e = dev->Outputs().end();
for (; i!=e; ++i)
control_lbox->Append(WXSTR_FROM_STR((*i)->GetName()));
@ -702,10 +702,10 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
switch ( group->type )
{
case GROUP_TYPE_STICK :
case GROUP_TYPE_TILT :
case GROUP_TYPE_CURSOR :
case GROUP_TYPE_FORCE :
case GROUP_TYPE_STICK:
case GROUP_TYPE_TILT:
case GROUP_TYPE_CURSOR:
case GROUP_TYPE_FORCE:
{
wxBitmap bitmap(64, 64);
dc.SelectObject(bitmap);
@ -733,7 +733,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add( h_szr, 0, wxEXPAND|wxLEFT|wxCENTER|wxTOP, 3 );
}
break;
case GROUP_TYPE_BUTTONS :
case GROUP_TYPE_BUTTONS:
{
wxBitmap bitmap(int(12*group->controls.size()+1), 12);
dc.SelectObject(bitmap);
@ -755,8 +755,8 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(static_bitmap, 0, wxALL|wxCENTER, 3);
}
break;
case GROUP_TYPE_MIXED_TRIGGERS :
case GROUP_TYPE_TRIGGERS :
case GROUP_TYPE_MIXED_TRIGGERS:
case GROUP_TYPE_TRIGGERS:
{
int height = (int)(6 * group->controls.size());
int width = 64+12+1;
@ -787,7 +787,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add( static_bitmap, 0, wxALL|wxCENTER, 3 );
}
break;
case GROUP_TYPE_EXTENSION :
case GROUP_TYPE_EXTENSION:
{
PadSettingExtension* const attachments = new PadSettingExtension( parent, (ControllerEmu::Extension*)group );
wxButton* const configure_btn = new ExtensionButton( parent, (ControllerEmu::Extension*)group );
@ -808,7 +808,7 @@ ControlGroupBox::ControlGroupBox( ControllerEmu::ControlGroup* const group, wxWi
Add(btn, 0, wxALL|wxEXPAND, 3);
}
break;
default :
default:
{
//options

View File

@ -357,8 +357,8 @@ void BPWritten(const BPCmd& bp)
// Bounding Box Control
// -------------------------
case BPMEM_CLEARBBOX1:
case BPMEM_CLEARBBOX2: {
case BPMEM_CLEARBBOX2:
{
#ifdef BBOX_SUPPORT
// which is which? these are GUESSES!
if (bp.address == BPMEM_CLEARBBOX1) {
@ -381,8 +381,8 @@ void BPWritten(const BPCmd& bp)
// WARN_LOG(VIDEO, "ClearBBox TB: %i, %08x - %i, %i", bp.address, bp.newvalue, top, bottom);
}
#endif
}
break;
}
case BPMEM_TEXINVALIDATE: // Used, if game has manual control the Texture Cache, which we don't allow
DEBUG_LOG(VIDEO, "BP Texture Invalid: %08x", bp.newvalue);
case BPMEM_ZCOMPARE: // Set the Z-Compare and EFB pixel format
@ -583,7 +583,7 @@ void BPWritten(const BPCmd& bp)
default:
WARN_LOG(VIDEO, "Unknown BP opcode: address = 0x%08x value = 0x%08x", bp.address, bp.newvalue);
break;
}
}
}
// FIXME: Hangs load-state, but should fix graphic-heavy games state loading

View File

@ -35,55 +35,56 @@ cl_program g_program;
struct sDecoderParameter
{
const char *name;
cl_kernel kernel;
float sizeOfSrc;
const char *name;
cl_kernel kernel;
float sizeOfSrc;
float sizeOfDst;
int xSkip;
int ySkip;
int xSkip;
int ySkip;
PC_TexFormat format;
};
sDecoderParameter g_DecodeParametersNative[] = {
/* GX_TF_I4 */ { "DecodeI4", NULL, 0.5f, 1, 8, 8, PC_TEX_FMT_I4_AS_I8 },
/* GX_TF_I8 */ { "DecodeI8", NULL, 1, 1, 8, 4, PC_TEX_FMT_I8 },
/* GX_TF_IA4 */ { "DecodeIA4", NULL, 1, 2, 8, 4, PC_TEX_FMT_IA4_AS_IA8 },
/* GX_TF_IA8 */ { "DecodeIA8", NULL, 2, 2, 4, 4, PC_TEX_FMT_IA8 },
/* GX_TF_RGB565 */ { "DecodeRGB565", NULL, 2, 2, 4, 4, PC_TEX_FMT_RGB565 },
/* GX_TF_RGB5A3 */ { "DecodeRGB5A3", NULL, 2, 4, 4, 4, PC_TEX_FMT_BGRA32 },
/* GX_TF_RGBA8 */ { "DecodeRGBA8", NULL, 4, 4, 4, 4, PC_TEX_FMT_BGRA32 },
/* 7 */ { NULL },
/* GX_TF_C4 */ { NULL },
/* GX_TF_C8 */ { NULL },
/* GX_TF_C14X2 */ { NULL },
/* B */ { NULL },
/* C */ { NULL },
/* D */ { NULL },
/* GX_TF_CMPR */ { "DecodeCMPR", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_BGRA32 },
/* GX_TF_I4 */ { "DecodeI4", NULL, 0.5f, 1, 8, 8, PC_TEX_FMT_I4_AS_I8 },
/* GX_TF_I8 */ { "DecodeI8", NULL, 1, 1, 8, 4, PC_TEX_FMT_I8 },
/* GX_TF_IA4 */ { "DecodeIA4", NULL, 1, 2, 8, 4, PC_TEX_FMT_IA4_AS_IA8 },
/* GX_TF_IA8 */ { "DecodeIA8", NULL, 2, 2, 4, 4, PC_TEX_FMT_IA8 },
/* GX_TF_RGB565 */ { "DecodeRGB565", NULL, 2, 2, 4, 4, PC_TEX_FMT_RGB565 },
/* GX_TF_RGB5A3 */ { "DecodeRGB5A3", NULL, 2, 4, 4, 4, PC_TEX_FMT_BGRA32 },
/* GX_TF_RGBA8 */ { "DecodeRGBA8", NULL, 4, 4, 4, 4, PC_TEX_FMT_BGRA32 },
/* 7 */ { NULL },
/* GX_TF_C4 */ { NULL },
/* GX_TF_C8 */ { NULL },
/* GX_TF_C14X2 */ { NULL },
/* B */ { NULL },
/* C */ { NULL },
/* D */ { NULL },
/* GX_TF_CMPR */ { "DecodeCMPR", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_BGRA32 },
};
sDecoderParameter g_DecodeParametersRGBA[] = {
/* GX_TF_I4 */ { "DecodeI4_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 },
/* GX_TF_I8 */ { "DecodeI8_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_IA4 */ { "DecodeIA4_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_IA8 */ { "DecodeIA8_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_RGB565 */ { "DecodeRGB565_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_RGB5A3 */ { "DecodeRGB5A3_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_RGBA8 */ { "DecodeRGBA8_RGBA", NULL, 4, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* 7 */ { NULL },
/* GX_TF_C4 */ { NULL },
/* GX_TF_C8 */ { NULL },
/* GX_TF_C14X2 */ { NULL },
/* B */ { NULL },
/* C */ { NULL },
/* D */ { NULL },
/* GX_TF_CMPR */ { "DecodeCMPR_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 },
/* GX_TF_I4 */ { "DecodeI4_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 },
/* GX_TF_I8 */ { "DecodeI8_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_IA4 */ { "DecodeIA4_RGBA", NULL, 1, 4, 8, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_IA8 */ { "DecodeIA8_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_RGB565 */ { "DecodeRGB565_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_RGB5A3 */ { "DecodeRGB5A3_RGBA", NULL, 2, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* GX_TF_RGBA8 */ { "DecodeRGBA8_RGBA", NULL, 4, 4, 4, 4, PC_TEX_FMT_RGBA32 },
/* 7 */ { NULL },
/* GX_TF_C4 */ { NULL },
/* GX_TF_C8 */ { NULL },
/* GX_TF_C14X2 */ { NULL },
/* B */ { NULL },
/* C */ { NULL },
/* D */ { NULL },
/* GX_TF_CMPR */ { "DecodeCMPR_RGBA", NULL, 0.5f, 4, 8, 8, PC_TEX_FMT_RGBA32 },
};
bool g_Inited = false;
cl_mem g_clsrc, g_cldst; // texture buffer memory objects
void TexDecoder_OpenCL_Initialize() {
void TexDecoder_OpenCL_Initialize()
{
#if defined(HAVE_OPENCL) && HAVE_OPENCL
if(!g_Inited)
{
@ -124,7 +125,8 @@ void TexDecoder_OpenCL_Initialize() {
#endif
}
void TexDecoder_OpenCL_Shutdown() {
void TexDecoder_OpenCL_Shutdown()
{
#if defined(HAVE_OPENCL) && HAVE_OPENCL && !defined(DEBUG_OPENCL)
clReleaseProgram(g_program);
@ -151,9 +153,9 @@ PC_TexFormat TexDecoder_Decode_OpenCL(u8 *dst, const u8 *src, int width, int hei
{
#if defined(HAVE_OPENCL) && HAVE_OPENCL
cl_int err;
sDecoderParameter& decoder = rgba ? g_DecodeParametersRGBA[texformat] : g_DecodeParametersNative[texformat];
if(!g_Inited || !decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE)
return PC_TEX_FMT_NONE;
sDecoderParameter& decoder = rgba ? g_DecodeParametersRGBA[texformat] : g_DecodeParametersNative[texformat];
if(!g_Inited || !decoder.name || !decoder.kernel || decoder.format == PC_TEX_FMT_NONE)
return PC_TEX_FMT_NONE;
#ifdef DEBUG_OPENCL
g_clsrc = clCreateBuffer(OpenCL::GetContext(), CL_MEM_READ_ONLY , 1024 * 1024 * sizeof(u32), NULL, NULL);

File diff suppressed because it is too large Load Diff

View File

@ -84,35 +84,35 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
{
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
text[sizeof(text) - 1] = 0x7C; // canary
DVSTARTPROFILE();
DVSTARTPROFILE();
_assert_(bpmem.genMode.numtexgens == xfregs.numTexGens);
_assert_(bpmem.genMode.numcolchans == xfregs.nNumChans);
_assert_(bpmem.genMode.numtexgens == xfregs.numTexGens);
_assert_(bpmem.genMode.numcolchans == xfregs.nNumChans);
bool is_d3d = (api_type == API_D3D9 || api_type == API_D3D11);
u32 lightMask = 0;
if (xfregs.nNumChans > 0)
u32 lightMask = 0;
if (xfregs.nNumChans > 0)
lightMask |= xfregs.colChans[0].color.GetFullLightMask() | xfregs.colChans[0].alpha.GetFullLightMask();
if (xfregs.nNumChans > 1)
lightMask |= xfregs.colChans[1].color.GetFullLightMask() | xfregs.colChans[1].alpha.GetFullLightMask();
if (xfregs.nNumChans > 1)
lightMask |= xfregs.colChans[1].color.GetFullLightMask() | xfregs.colChans[1].alpha.GetFullLightMask();
char *p = text;
WRITE(p, "//Vertex Shader: comp:%x, \n", components);
WRITE(p, "typedef struct { float4 T0, T1, T2; float4 N0, N1, N2; } s_"I_POSNORMALMATRIX";\n"
"typedef struct { float4 t; } FLT4;\n"
"typedef struct { FLT4 T[24]; } s_"I_TEXMATRICES";\n"
"typedef struct { FLT4 T[64]; } s_"I_TRANSFORMMATRICES";\n"
"typedef struct { FLT4 T[32]; } s_"I_NORMALMATRICES";\n"
"typedef struct { FLT4 T[64]; } s_"I_POSTTRANSFORMMATRICES";\n"
"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n"
"typedef struct { Light lights[8]; } s_"I_LIGHTS";\n"
"typedef struct { float4 C0,C1,C2,C3; } s_"I_MATERIALS";\n"
"typedef struct { float4 T0,T1,T2,T3; } s_"I_PROJECTION";\n"
);
char *p = text;
WRITE(p, "//Vertex Shader: comp:%x, \n", components);
WRITE(p, "typedef struct { float4 T0, T1, T2; float4 N0, N1, N2; } s_"I_POSNORMALMATRIX";\n"
"typedef struct { float4 t; } FLT4;\n"
"typedef struct { FLT4 T[24]; } s_"I_TEXMATRICES";\n"
"typedef struct { FLT4 T[64]; } s_"I_TRANSFORMMATRICES";\n"
"typedef struct { FLT4 T[32]; } s_"I_NORMALMATRICES";\n"
"typedef struct { FLT4 T[64]; } s_"I_POSTTRANSFORMMATRICES";\n"
"typedef struct { float4 col; float4 cosatt; float4 distatt; float4 pos; float4 dir; } Light;\n"
"typedef struct { Light lights[8]; } s_"I_LIGHTS";\n"
"typedef struct { float4 C0, C1, C2, C3; } s_"I_MATERIALS";\n"
"typedef struct { float4 T0, T1, T2, T3; } s_"I_PROJECTION";\n"
);
WRITE(p, "struct VS_OUTPUT {\n");
WRITE(p, " float4 pos : POSITION;\n");
WRITE(p, " float4 colors[2] : COLOR0;\n");
WRITE(p, "struct VS_OUTPUT {\n");
WRITE(p, " float4 pos : POSITION;\n");
WRITE(p, " float4 colors[2] : COLOR0;\n");
if (xfregs.numTexGens < 7) {
for (int i = 0; i < xfregs.numTexGens; ++i)
@ -123,46 +123,46 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
for (int i = 0; i < xfregs.numTexGens; ++i)
WRITE(p, " float%d tex%d : TEXCOORD%d;\n", i<4?4:3, i, i);
}
WRITE(p, "};\n");
WRITE(p, "};\n");
// uniforms
// uniforms
WRITE(p, "uniform s_"I_TRANSFORMMATRICES" "I_TRANSFORMMATRICES" : register(c%d);\n", C_TRANSFORMMATRICES);
WRITE(p, "uniform s_"I_TEXMATRICES" "I_TEXMATRICES" : register(c%d);\n", C_TEXMATRICES); // also using tex matrices
WRITE(p, "uniform s_"I_NORMALMATRICES" "I_NORMALMATRICES" : register(c%d);\n", C_NORMALMATRICES);
WRITE(p, "uniform s_"I_POSNORMALMATRIX" "I_POSNORMALMATRIX" : register(c%d);\n", C_POSNORMALMATRIX);
WRITE(p, "uniform s_"I_POSTTRANSFORMMATRICES" "I_POSTTRANSFORMMATRICES" : register(c%d);\n", C_POSTTRANSFORMMATRICES);
WRITE(p, "uniform s_"I_LIGHTS" "I_LIGHTS" : register(c%d);\n", C_LIGHTS);
WRITE(p, "uniform s_"I_MATERIALS" "I_MATERIALS" : register(c%d);\n", C_MATERIALS);
WRITE(p, "uniform s_"I_PROJECTION" "I_PROJECTION" : register(c%d);\n", C_PROJECTION);
WRITE(p, "uniform s_"I_TEXMATRICES" "I_TEXMATRICES" : register(c%d);\n", C_TEXMATRICES); // also using tex matrices
WRITE(p, "uniform s_"I_NORMALMATRICES" "I_NORMALMATRICES" : register(c%d);\n", C_NORMALMATRICES);
WRITE(p, "uniform s_"I_POSNORMALMATRIX" "I_POSNORMALMATRIX" : register(c%d);\n", C_POSNORMALMATRIX);
WRITE(p, "uniform s_"I_POSTTRANSFORMMATRICES" "I_POSTTRANSFORMMATRICES" : register(c%d);\n", C_POSTTRANSFORMMATRICES);
WRITE(p, "uniform s_"I_LIGHTS" "I_LIGHTS" : register(c%d);\n", C_LIGHTS);
WRITE(p, "uniform s_"I_MATERIALS" "I_MATERIALS" : register(c%d);\n", C_MATERIALS);
WRITE(p, "uniform s_"I_PROJECTION" "I_PROJECTION" : register(c%d);\n", C_PROJECTION);
WRITE(p, "VS_OUTPUT main(\n");
// inputs
if (components & VB_HAS_NRM0)
WRITE(p, " float3 rawnorm0 : NORMAL0,\n");
if (components & VB_HAS_NRM1) {
WRITE(p, "VS_OUTPUT main(\n");
// inputs
if (components & VB_HAS_NRM0)
WRITE(p, " float3 rawnorm0 : NORMAL0,\n");
if (components & VB_HAS_NRM1) {
if (is_d3d)
WRITE(p, " float3 rawnorm1 : NORMAL1,\n");
else
WRITE(p, " float3 rawnorm1 : ATTR%d,\n", SHADER_NORM1_ATTRIB);
}
if (components & VB_HAS_NRM2) {
if (is_d3d)
if (components & VB_HAS_NRM2) {
if (is_d3d)
WRITE(p, " float3 rawnorm2 : NORMAL2,\n");
else
WRITE(p, " float3 rawnorm2 : ATTR%d,\n", SHADER_NORM2_ATTRIB);
}
if (components & VB_HAS_COL0)
WRITE(p, " float4 color0 : COLOR0,\n");
if (components & VB_HAS_COL1)
WRITE(p, " float4 color1 : COLOR1,\n");
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx )
WRITE(p, " float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i,i);
}
if (components & VB_HAS_POSMTXIDX) {
if (components & VB_HAS_COL0)
WRITE(p, " float4 color0 : COLOR0,\n");
if (components & VB_HAS_COL1)
WRITE(p, " float4 color1 : COLOR1,\n");
for (int i = 0; i < 8; ++i) {
u32 hastexmtx = (components & (VB_HAS_TEXMTXIDX0<<i));
if ((components & (VB_HAS_UV0<<i)) || hastexmtx)
WRITE(p, " float%d tex%d : TEXCOORD%d,\n", hastexmtx ? 3 : 2, i, i);
}
if (components & VB_HAS_POSMTXIDX) {
if (is_d3d)
{
WRITE(p, " float4 blend_indices : BLENDINDICES,\n");
@ -170,11 +170,11 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
else
WRITE(p, " float fposmtx : ATTR%d,\n", SHADER_POSMTX_ATTRIB);
}
WRITE(p, " float4 rawpos : POSITION) {\n");
WRITE(p, "VS_OUTPUT o;\n");
WRITE(p, " float4 rawpos : POSITION) {\n");
WRITE(p, "VS_OUTPUT o;\n");
// transforms
if (components & VB_HAS_POSMTXIDX) {
// transforms
if (components & VB_HAS_POSMTXIDX) {
if (api_type == API_D3D9)
{
WRITE(p, "int4 indices = D3DCOLORtoUBYTE4(blend_indices);\n");
@ -189,239 +189,242 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "int posmtx = fposmtx;\n");
}
WRITE(p, "float4 pos = float4(dot("I_TRANSFORMMATRICES".T[posmtx].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+1].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+2].t, rawpos),1);\n");
if (components & VB_HAS_NRMALL) {
WRITE(p, "int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
WRITE(p, "float3 N0 = "I_NORMALMATRICES".T[normidx].t.xyz, N1 = "I_NORMALMATRICES".T[normidx+1].t.xyz, N2 = "I_NORMALMATRICES".T[normidx+2].t.xyz;\n");
}
WRITE(p, "float4 pos = float4(dot("I_TRANSFORMMATRICES".T[posmtx].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+1].t, rawpos), dot("I_TRANSFORMMATRICES".T[posmtx+2].t, rawpos), 1);\n");
if (components & VB_HAS_NRMALL) {
WRITE(p, "int normidx = posmtx >= 32 ? (posmtx-32) : posmtx;\n");
WRITE(p, "float3 N0 = "I_NORMALMATRICES".T[normidx].t.xyz, N1 = "I_NORMALMATRICES".T[normidx+1].t.xyz, N2 = "I_NORMALMATRICES".T[normidx+2].t.xyz;\n");
}
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n");
if (components & VB_HAS_NRM1)
WRITE(p, "float3 _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n");
if (components & VB_HAS_NRM2)
WRITE(p, "float3 _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n");
}
else {
WRITE(p, "float4 pos = float4(dot("I_POSNORMALMATRIX".T0, rawpos), dot("I_POSNORMALMATRIX".T1, rawpos), dot("I_POSNORMALMATRIX".T2, rawpos), 1.0f);\n");
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm0)));\n");
if (components & VB_HAS_NRM1)
WRITE(p, "float3 _norm1 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm1));\n");
if (components & VB_HAS_NRM2)
WRITE(p, "float3 _norm2 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm2));\n");
}
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot(N0, rawnorm0), dot(N1, rawnorm0), dot(N2, rawnorm0)));\n");
if (components & VB_HAS_NRM1)
WRITE(p, "float3 _norm1 = float3(dot(N0, rawnorm1), dot(N1, rawnorm1), dot(N2, rawnorm1));\n");
if (components & VB_HAS_NRM2)
WRITE(p, "float3 _norm2 = float3(dot(N0, rawnorm2), dot(N1, rawnorm2), dot(N2, rawnorm2));\n");
}
else
{
WRITE(p, "float4 pos = float4(dot("I_POSNORMALMATRIX".T0, rawpos), dot("I_POSNORMALMATRIX".T1, rawpos), dot("I_POSNORMALMATRIX".T2, rawpos), 1.0f);\n");
if (components & VB_HAS_NRM0)
WRITE(p, "float3 _norm0 = normalize(float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm0), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm0)));\n");
if (components & VB_HAS_NRM1)
WRITE(p, "float3 _norm1 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm1), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm1));\n");
if (components & VB_HAS_NRM2)
WRITE(p, "float3 _norm2 = float3(dot("I_POSNORMALMATRIX".N0.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N1.xyz, rawnorm2), dot("I_POSNORMALMATRIX".N2.xyz, rawnorm2));\n");
}
if (!(components & VB_HAS_NRM0))
WRITE(p, "float3 _norm0 = float3(0.0f,0.0f,0.0f);\n");
if (!(components & VB_HAS_NRM0))
WRITE(p, "float3 _norm0 = float3(0.0f, 0.0f, 0.0f);\n");
WRITE(p, "o.pos = float4(dot("I_PROJECTION".T0, pos), dot("I_PROJECTION".T1, pos), dot("I_PROJECTION".T2, pos), dot("I_PROJECTION".T3, pos));\n");
WRITE(p, "o.pos = float4(dot("I_PROJECTION".T0, pos), dot("I_PROJECTION".T1, pos), dot("I_PROJECTION".T2, pos), dot("I_PROJECTION".T3, pos));\n");
WRITE(p, "float4 mat,lacc;\n" // = half4(1,1,1,1), lacc = half4(0,0,0,0);\n"
"float3 ldir, h;\n"
"float dist, dist2, attn;\n");
WRITE(p, "float4 mat, lacc;\n" // = half4(1, 1, 1, 1), lacc = half4(0, 0, 0, 0);\n"
"float3 ldir, h;\n"
"float dist, dist2, attn;\n");
// lights/colors
for (int j = 0; j < xfregs.nNumChans; j++) {
// lights/colors
for (int j = 0; j < xfregs.nNumChans; j++)
{
// bool bColorAlphaSame = xfregs.colChans[j].color.hex == xfregs.colChans[j].alpha.hex; unused
const LitChannel& color = xfregs.colChans[j].color;
const LitChannel& alpha = xfregs.colChans[j].alpha;
// bool bColorAlphaSame = xfregs.colChans[j].color.hex == xfregs.colChans[j].alpha.hex; unused
const LitChannel& color = xfregs.colChans[j].color;
const LitChannel& alpha = xfregs.colChans[j].alpha;
WRITE(p, "{\n");
WRITE(p, "lacc = float4(1.0f,1.0f,1.0f,1.0f);\n");
if (color.matsource) {// from vertex
if (components & (VB_HAS_COL0 << j))
WRITE(p, "mat = color%d;\n", j);
else
WRITE(p, "mat = float4(1.0f,1.0f,1.0f,1.0f);\n");
}
else // from color
WRITE(p, "mat = "I_MATERIALS".C%d;\n", j+2);
WRITE(p, "{\n");
WRITE(p, "lacc = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
if (color.matsource) {// from vertex
if (components & (VB_HAS_COL0 << j))
WRITE(p, "mat = color%d;\n", j);
else
WRITE(p, "mat = float4(1.0f, 1.0f, 1.0f, 1.0f);\n");
}
else // from color
WRITE(p, "mat = "I_MATERIALS".C%d;\n", j+2);
if (color.enablelighting) {
if (color.ambsource) { // from vertex
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc = color%d;\n", j);
else
WRITE(p, "lacc = float4(0.0f,0.0f,0.0f,0.0f);\n");
}
else // from color
WRITE(p, "lacc = "I_MATERIALS".C%d;\n", j);
}
if (color.enablelighting) {
if (color.ambsource) { // from vertex
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc = color%d;\n", j);
else
WRITE(p, "lacc = float4(0.0f, 0.0f, 0.0f, 0.0f);\n");
}
else // from color
WRITE(p, "lacc = "I_MATERIALS".C%d;\n", j);
}
// check if alpha is different
if (alpha.matsource != color.matsource) {
if (alpha.matsource) {// from vertex
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "mat.w = color%d.w;\n", j);
else WRITE(p, "mat.w = 1;\n");
}
else // from color
WRITE(p, "mat.w = "I_MATERIALS".C%d.w;\n", j+2);
}
// check if alpha is different
if (alpha.matsource != color.matsource) {
if (alpha.matsource) {// from vertex
if (components & (VB_HAS_COL0<<j))
WRITE(p, "mat.w = color%d.w;\n", j);
else WRITE(p, "mat.w = 1;\n");
}
else // from color
WRITE(p, "mat.w = "I_MATERIALS".C%d.w;\n", j+2);
}
if (alpha.enablelighting && alpha.ambsource != color.ambsource) {
if (alpha.ambsource) {// from vertex
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc.w = color%d.w;\n", j);
else WRITE(p, "lacc.w = 0;\n");
}
else // from color
WRITE(p, "lacc.w = "I_MATERIALS".C%d.w;\n", j);
}
if (alpha.enablelighting && alpha.ambsource != color.ambsource) {
if (alpha.ambsource) {// from vertex
if (components & (VB_HAS_COL0<<j) )
WRITE(p, "lacc.w = color%d.w;\n", j);
else
WRITE(p, "lacc.w = 0;\n");
}
else // from color
WRITE(p, "lacc.w = "I_MATERIALS".C%d.w;\n", j);
}
if(color.enablelighting && alpha.enablelighting)
{
// both have lighting, test if they use the same lights
int mask = 0;
int mask = 0;
if(color.lightparams == alpha.lightparams)
{
mask = color.GetFullLightMask() & alpha.GetFullLightMask();
if(mask)
{
for (int i = 0; i < 8; ++i)
for (int i = 0; i < 8; ++i)
{
if (mask & (1<<i))
p = GenerateLightShader(p, i, color, "lacc", 3);
}
}
}
// no shared lights
for (int i = 0; i < 8; ++i)
// no shared lights
for (int i = 0; i < 8; ++i)
{
if (!(mask&(1<<i)) && (color.GetFullLightMask() & (1<<i)) )
p = GenerateLightShader(p, i, color, "lacc", 1);
if (!(mask&(1<<i)) && (alpha.GetFullLightMask() & (1<<i)) )
p = GenerateLightShader(p, i, alpha, "lacc", 2);
}
if (!(mask&(1<<i)) && (color.GetFullLightMask() & (1<<i)))
p = GenerateLightShader(p, i, color, "lacc", 1);
if (!(mask&(1<<i)) && (alpha.GetFullLightMask() & (1<<i)))
p = GenerateLightShader(p, i, alpha, "lacc", 2);
}
}
else if (color.enablelighting || alpha.enablelighting)
{
//ligths are disabled in one channel so proccess only te active
// lights are disabled on one channel so process only the active ones
LitChannel workingchannel = color.enablelighting ? color : alpha;
int coloralpha = color.enablelighting ? 1 : 2;
for (int i = 0; i < 8; ++i)
for (int i = 0; i < 8; ++i)
{
if (workingchannel.GetFullLightMask() & (1<<i))
p = GenerateLightShader(p, i, workingchannel, "lacc", coloralpha);
}
if (workingchannel.GetFullLightMask() & (1<<i))
p = GenerateLightShader(p, i, workingchannel, "lacc", coloralpha);
}
}
if (color.enablelighting != alpha.enablelighting) {
if (color.enablelighting)
WRITE(p, "o.colors[%d].xyz = mat.xyz * saturate(lacc.xyz);\n"
"o.colors[%d].w = mat.w;\n", j, j);
else
WRITE(p, "o.colors[%d].xyz = mat.xyz;\n"
"o.colors[%d].w = mat.w * saturate(lacc.w);\n", j, j);
}
else {
if (alpha.enablelighting)
WRITE(p, "o.colors[%d] = mat * saturate(lacc);\n", j);
else
if (color.enablelighting != alpha.enablelighting) {
if (color.enablelighting)
WRITE(p, "o.colors[%d].xyz = mat.xyz * saturate(lacc.xyz);\n"
"o.colors[%d].w = mat.w;\n", j, j);
else
WRITE(p, "o.colors[%d].xyz = mat.xyz;\n"
"o.colors[%d].w = mat.w * saturate(lacc.w);\n", j, j);
}
else
{
if (alpha.enablelighting)
WRITE(p, "o.colors[%d] = mat * saturate(lacc);\n", j);
else
WRITE(p, "o.colors[%d] = mat;\n", j);
}
WRITE(p, "}\n");
}
}
WRITE(p, "}\n");
}
// zero left over channels
for (int i = xfregs.nNumChans; i < 2; ++i)
WRITE(p, "o.colors[%d] = float4(0.0f,0.0f,0.0f,1.0f);\n", i);
// zero left over channels
for (int i = xfregs.nNumChans; i < 2; ++i)
WRITE(p, "o.colors[%d] = float4(0.0f, 0.0f, 0.0f, 1.0f);\n", i);
// special case if only pos and tex coord 0 and tex coord input is AB11
// special case if only pos and tex coord 0 and tex coord input is AB11
// donko - this has caused problems in some games. removed for now.
bool texGenSpecialCase = false;
/*bool texGenSpecialCase =
((g_VtxDesc.Hex & 0x60600L) == g_VtxDesc.Hex) && // only pos and tex coord 0
(g_VtxDesc.Tex0Coord != NOT_PRESENT) &&
(xfregs.texcoords[0].texmtxinfo.inputform == XF_TEXINPUT_AB11);
*/
*/
// transform texcoords
WRITE(p, "float4 coord = float4(0.0f,0.0f,1.0f,1.0f);\n");
for (int i = 0; i < xfregs.numTexGens; ++i) {
TexMtxInfo& texinfo = xfregs.texcoords[i].texmtxinfo;
// transform texcoords
WRITE(p, "float4 coord = float4(0.0f, 0.0f, 1.0f, 1.0f);\n");
for (int i = 0; i < xfregs.numTexGens; ++i) {
TexMtxInfo& texinfo = xfregs.texcoords[i].texmtxinfo;
WRITE(p, "{\n");
WRITE(p, "coord = float4(0.0f,0.0f,1.0f,1.0f);\n");
switch (texinfo.sourcerow) {
case XF_SRCGEOM_INROW:
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = rawpos;\n"); // pos.w is 1
break;
case XF_SRCNORMAL_INROW:
if (components & VB_HAS_NRM0) {
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = float4(rawnorm0.xyz, 1.0f);\n");
}
break;
case XF_SRCCOLORS_INROW:
_assert_( texinfo.texgentype == XF_TEXGEN_COLOR_STRGBC0 || texinfo.texgentype == XF_TEXGEN_COLOR_STRGBC1 );
break;
case XF_SRCBINORMAL_T_INROW:
if (components & VB_HAS_NRM1) {
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = float4(rawnorm1.xyz, 1.0f);\n");
}
break;
case XF_SRCBINORMAL_B_INROW:
if (components & VB_HAS_NRM2) {
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = float4(rawnorm2.xyz, 1.0f);\n");
}
break;
default:
_assert_(texinfo.sourcerow <= XF_SRCTEX7_INROW);
if (components & (VB_HAS_UV0<<(texinfo.sourcerow - XF_SRCTEX0_INROW)) )
WRITE(p, "coord = float4(tex%d.x, tex%d.y, 1.0f, 1.0f);\n", texinfo.sourcerow - XF_SRCTEX0_INROW, texinfo.sourcerow - XF_SRCTEX0_INROW);
break;
}
WRITE(p, "{\n");
WRITE(p, "coord = float4(0.0f, 0.0f, 1.0f, 1.0f);\n");
switch (texinfo.sourcerow) {
case XF_SRCGEOM_INROW:
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = rawpos;\n"); // pos.w is 1
break;
case XF_SRCNORMAL_INROW:
if (components & VB_HAS_NRM0) {
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = float4(rawnorm0.xyz, 1.0f);\n");
}
break;
case XF_SRCCOLORS_INROW:
_assert_( texinfo.texgentype == XF_TEXGEN_COLOR_STRGBC0 || texinfo.texgentype == XF_TEXGEN_COLOR_STRGBC1 );
break;
case XF_SRCBINORMAL_T_INROW:
if (components & VB_HAS_NRM1) {
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = float4(rawnorm1.xyz, 1.0f);\n");
}
break;
case XF_SRCBINORMAL_B_INROW:
if (components & VB_HAS_NRM2) {
_assert_( texinfo.inputform == XF_TEXINPUT_ABC1 );
WRITE(p, "coord = float4(rawnorm2.xyz, 1.0f);\n");
}
break;
default:
_assert_(texinfo.sourcerow <= XF_SRCTEX7_INROW);
if (components & (VB_HAS_UV0<<(texinfo.sourcerow - XF_SRCTEX0_INROW)) )
WRITE(p, "coord = float4(tex%d.x, tex%d.y, 1.0f, 1.0f);\n", texinfo.sourcerow - XF_SRCTEX0_INROW, texinfo.sourcerow - XF_SRCTEX0_INROW);
break;
}
// firs transformation
switch (texinfo.texgentype) {
case XF_TEXGEN_EMBOSS_MAP: // calculate tex coords into bump map
// first transformation
switch (texinfo.texgentype) {
case XF_TEXGEN_EMBOSS_MAP: // calculate tex coords into bump map
if (components & (VB_HAS_NRM1|VB_HAS_NRM2)) {
// transform the light dir into tangent space
WRITE(p, "ldir = normalize("I_LIGHTS".lights[%d].pos.xyz - pos.xyz);\n", texinfo.embosslightshift);
WRITE(p, "o.tex%d.xyz = o.tex%d.xyz + float3(dot(ldir, _norm1), dot(ldir, _norm2), 0.0f);\n", i, texinfo.embosssourceshift);
}
else _assert_(0); // should have normals
if (components & (VB_HAS_NRM1|VB_HAS_NRM2)) {
// transform the light dir into tangent space
WRITE(p, "ldir = normalize("I_LIGHTS".lights[%d].pos.xyz - pos.xyz);\n", texinfo.embosslightshift);
WRITE(p, "o.tex%d.xyz = o.tex%d.xyz + float3(dot(ldir, _norm1), dot(ldir, _norm2), 0.0f);\n", i, texinfo.embosssourceshift);
}
else _assert_(0); // should have normals
break;
case XF_TEXGEN_COLOR_STRGBC0:
_assert_(texinfo.sourcerow == XF_SRCCOLORS_INROW);
WRITE(p, "o.tex%d.xyz = float3(o.colors[0].x, o.colors[0].y, 1);\n", i);
break;
case XF_TEXGEN_COLOR_STRGBC1:
_assert_(texinfo.sourcerow == XF_SRCCOLORS_INROW);
WRITE(p, "o.tex%d.xyz = float3(o.colors[1].x, o.colors[1].y, 1);\n", i);
break;
break;
case XF_TEXGEN_COLOR_STRGBC0:
_assert_(texinfo.sourcerow == XF_SRCCOLORS_INROW);
WRITE(p, "o.tex%d.xyz = float3(o.colors[0].x, o.colors[0].y, 1);\n", i);
break;
case XF_TEXGEN_COLOR_STRGBC1:
_assert_(texinfo.sourcerow == XF_SRCCOLORS_INROW);
WRITE(p, "o.tex%d.xyz = float3(o.colors[1].x, o.colors[1].y, 1);\n", i);
break;
case XF_TEXGEN_REGULAR:
default:
if (components & (VB_HAS_TEXMTXIDX0<<i)) {
if (texinfo.projection == XF_TEXPROJ_STQ )
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+1].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+2].t));\n", i, i, i, i);
else {
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+1].t), 1);\n", i, i, i);
}
}
else {
if (texinfo.projection == XF_TEXPROJ_STQ )
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t));\n", i, 3*i, 3*i+1, 3*i+2);
else
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t), 1);\n", i, 3*i, 3*i+1);
}
break;
}
if (components & (VB_HAS_TEXMTXIDX0<<i)) {
if (texinfo.projection == XF_TEXPROJ_STQ)
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+1].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+2].t));\n", i, i, i, i);
else {
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z].t), dot(coord, "I_TRANSFORMMATRICES".T[tex%d.z+1].t), 1);\n", i, i, i);
}
}
else {
if (texinfo.projection == XF_TEXPROJ_STQ)
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t));\n", i, 3*i, 3*i+1, 3*i+2);
else
WRITE(p, "o.tex%d.xyz = float3(dot(coord, "I_TEXMATRICES".T[%d].t), dot(coord, "I_TEXMATRICES".T[%d].t), 1);\n", i, 3*i, 3*i+1);
}
break;
}
if (xfregs.bEnableDualTexTransform && texinfo.texgentype == XF_TEXGEN_REGULAR) { // only works for regular tex gen types?
if (xfregs.bEnableDualTexTransform && texinfo.texgentype == XF_TEXGEN_REGULAR) { // only works for regular tex gen types?
int postidx = xfregs.texcoords[i].postmtxinfo.index;
WRITE(p, "float4 P0 = "I_POSTTRANSFORMMATRICES".T[%d].t;\n"
"float4 P1 = "I_POSTTRANSFORMMATRICES".T[%d].t;\n"
@ -433,24 +436,25 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
// q of input is 1
// q of output is unknown
//multiply by postmatrix
// multiply by postmatrix
WRITE(p, "o.tex%d.xyz = float3(dot(P0.xy, o.tex%d.xy) + P0.z + P0.w, dot(P1.xy, o.tex%d.xy) + P1.z + P1.w, 0.0f);\n", i, i, i);
}
else {
else
{
if (xfregs.texcoords[i].postmtxinfo.normalize)
WRITE(p, "o.tex%d.xyz = normalize(o.tex%d.xyz);\n", i, i);
//multiply by postmatrix
// multiply by postmatrix
WRITE(p, "o.tex%d.xyz = float3(dot(P0.xyz, o.tex%d.xyz) + P0.w, dot(P1.xyz, o.tex%d.xyz) + P1.w, dot(P2.xyz, o.tex%d.xyz) + P2.w);\n", i, i, i, i);
}
}
}
WRITE(p, "}\n");
}
WRITE(p, "}\n");
}
// clipPos/w needs to be done in pixel shader, not here
if (xfregs.numTexGens < 7) {
WRITE(p, "o.clipPos = o.pos;\n");
WRITE(p, "o.clipPos = o.pos;\n");
} else {
WRITE(p, "o.tex0.w = o.pos.x;\n");
WRITE(p, "o.tex1.w = o.pos.y;\n");
@ -468,66 +472,67 @@ const char *GenerateVertexShaderCode(u32 components, API_TYPE api_type)
WRITE(p, "o.pos.z = (o.pos.z * 2.0f) + o.pos.w;\n");
}
WRITE(p, "return o;\n}\n");
WRITE(p, "return o;\n}\n");
if (text[sizeof(text) - 1] != 0x7C)
PanicAlert("VertexShader generator - buffer too small, canary has been eaten!");
return text;
return text;
}
// coloralpha - 1 if color, 2 if alpha
char *GenerateLightShader(char *p, int index, const LitChannel& chan, const char *dest, int coloralpha)
{
const char* swizzle = "xyzw";
if (coloralpha == 1 ) swizzle = "xyz";
else if (coloralpha == 2 ) swizzle = "w";
const char* swizzle = "xyzw";
if (coloralpha == 1 ) swizzle = "xyz";
else if (coloralpha == 2 ) swizzle = "w";
if (!(chan.attnfunc & 1)) {
// atten disabled
switch (chan.diffusefunc) {
case LIGHTDIF_NONE:
WRITE(p, "%s.%s += "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle);
break;
case LIGHTDIF_SIGN:
case LIGHTDIF_CLAMP:
WRITE(p, "ldir = normalize("I_LIGHTS".lights[%d].pos.xyz - pos.xyz);\n", index);
WRITE(p, "%s.%s += %sdot(ldir, _norm0)) * "I_LIGHTS".lights[%d].col.%s;\n",
dest, swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", index, swizzle);
break;
default: _assert_(0);
}
}
else { // spec and spot
WRITE(p, "ldir = "I_LIGHTS".lights[%d].pos.xyz - pos.xyz;\n", index);
if (!(chan.attnfunc & 1)) {
// atten disabled
switch (chan.diffusefunc) {
case LIGHTDIF_NONE:
WRITE(p, "%s.%s += "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle);
break;
case LIGHTDIF_SIGN:
case LIGHTDIF_CLAMP:
WRITE(p, "ldir = normalize("I_LIGHTS".lights[%d].pos.xyz - pos.xyz);\n", index);
WRITE(p, "%s.%s += %sdot(ldir, _norm0)) * "I_LIGHTS".lights[%d].col.%s;\n",
dest, swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", index, swizzle);
break;
default: _assert_(0);
}
}
else { // spec and spot
WRITE(p, "ldir = "I_LIGHTS".lights[%d].pos.xyz - pos.xyz;\n", index);
if (chan.attnfunc == 3) { // spot
WRITE(p, "dist2 = dot(ldir, ldir);\n"
"dist = sqrt(dist2);\n"
"ldir = ldir / dist;\n"
"attn = max(0.0f, dot(ldir, "I_LIGHTS".lights[%d].dir.xyz));\n",index);
WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, float3(1.0f, attn, attn*attn))) / dot("I_LIGHTS".lights[%d].distatt.xyz, float3(1.0f,dist,dist2));\n", index, index);
}
else if (chan.attnfunc == 1) { // specular
WRITE(p, "attn = (dot(_norm0, "I_LIGHTS".lights[%d].pos.xyz) > 0.0f) ? max(0.0f, dot(_norm0, "I_LIGHTS".lights[%d].dir.xyz)) : 0.0f;\n", index, index);
WRITE(p, "ldir = float3(1,attn,attn*attn);\n");
WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, ldir)) / dot("I_LIGHTS".lights[%d].distatt.xyz, ldir);\n", index, index);
}
if (chan.attnfunc == 3) { // spot
WRITE(p, "dist2 = dot(ldir, ldir);\n"
"dist = sqrt(dist2);\n"
"ldir = ldir / dist;\n"
"attn = max(0.0f, dot(ldir, "I_LIGHTS".lights[%d].dir.xyz));\n",index);
WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, float3(1.0f, attn, attn*attn))) / dot("I_LIGHTS".lights[%d].distatt.xyz, float3(1.0f,dist,dist2));\n", index, index);
}
else if (chan.attnfunc == 1) { // specular
WRITE(p, "attn = (dot(_norm0, "I_LIGHTS".lights[%d].pos.xyz) > 0.0f) ? max(0.0f, dot(_norm0, "I_LIGHTS".lights[%d].dir.xyz)) : 0.0f;\n", index, index);
WRITE(p, "ldir = float3(1,attn,attn*attn);\n");
WRITE(p, "attn = max(0.0f, dot("I_LIGHTS".lights[%d].cosatt.xyz, ldir)) / dot("I_LIGHTS".lights[%d].distatt.xyz, ldir);\n", index, index);
}
switch (chan.diffusefunc) {
case LIGHTDIF_NONE:
WRITE(p, "%s.%s += attn * "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle);
break;
case LIGHTDIF_SIGN:
case LIGHTDIF_CLAMP:
WRITE(p, "%s.%s += attn * %sdot(ldir, _norm0)) * "I_LIGHTS".lights[%d].col.%s;\n",
dest, swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", index, swizzle);
break;
default: _assert_(0);
}
}
WRITE(p, "\n");
switch (chan.diffusefunc)
{
case LIGHTDIF_NONE:
WRITE(p, "%s.%s += attn * "I_LIGHTS".lights[%d].col.%s;\n", dest, swizzle, index, swizzle);
break;
case LIGHTDIF_SIGN:
case LIGHTDIF_CLAMP:
WRITE(p, "%s.%s += attn * %sdot(ldir, _norm0)) * "I_LIGHTS".lights[%d].col.%s;\n",
dest, swizzle, chan.diffusefunc != LIGHTDIF_SIGN ? "max(0.0f," :"(", index, swizzle);
break;
default: _assert_(0);
}
}
WRITE(p, "\n");
setlocale(LC_NUMERIC, ""); // restore locale
return p;
return p;
}

View File

@ -284,7 +284,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw
float sizeratio = size / (float)m_LineHeight;
// translate starting positions
float sx = x * scalex - 1.f;
float sx = x * scalex - 1.f;
float sy = 1.f - y * scaley;
char c;
@ -355,7 +355,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw
v[4] = v[2];
v[5] = v[1];
memcpy(pVertices, v, 6*sizeof(FONT2DVERTEX));
memcpy(pVertices, v, 6*sizeof(FONT2DVERTEX));
pVertices+=6;
dwNumTriangles += 2;
@ -416,7 +416,7 @@ ID3D11Buffer* clearvb = NULL;
typedef struct { float x,y,z,u,v; } STQVertex;
typedef struct { float x,y,z,u,v; } STSQVertex;
typedef struct { float x,y,z; u32 col;} ClearVertex;
typedef struct { float x,y,z; u32 col; } ClearVertex;
void InitUtils()
{
@ -496,7 +496,7 @@ void drawShadedTexQuad(ID3D11ShaderResourceView* texture,
D3D::context->IASetInputLayout(layout);
D3D::context->IASetVertexBuffers(0, 1, &stqvb, &stride, &offset);
D3D::context->PSSetSamplers(0, 1, &stqsamplerstate);
D3D::context->PSSetShader(PShader, NULL, 0);
D3D::context->PSSetShader(PShader, NULL, 0);
D3D::context->PSSetShaderResources(0, 1, &texture);
D3D::context->VSSetShader(Vshader, NULL, 0);
D3D::stateman->Apply();

View File

@ -361,4 +361,4 @@ void StateManager::Apply()
else ERROR_LOG(VIDEO, "Tried to apply without rasterizer state!");
}
} // namespace
} // namespace

View File

@ -140,13 +140,13 @@ bool Init()
CreateDeviceObjects();
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
return true;
}
void ResetBuffer()
{
s_pCurBufferPointer = LocalVBuffer;
s_pCurBufferPointer = LocalVBuffer;
}
void Shutdown()
@ -163,12 +163,12 @@ void AddIndices(int _primitive, int _numVertices)
{
switch (_primitive)
{
case GX_DRAW_QUADS: IndexGenerator::AddQuads(_numVertices); break;
case GX_DRAW_QUADS: IndexGenerator::AddQuads(_numVertices); break;
case GX_DRAW_TRIANGLES: IndexGenerator::AddList(_numVertices); break;
case GX_DRAW_TRIANGLE_STRIP: IndexGenerator::AddStrip(_numVertices); break;
case GX_DRAW_TRIANGLE_FAN: IndexGenerator::AddFan(_numVertices); break;
case GX_DRAW_LINE_STRIP: IndexGenerator::AddLineStrip(_numVertices); break;
case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break;
case GX_DRAW_LINES: IndexGenerator::AddLineList(_numVertices); break;
case GX_DRAW_POINTS: IndexGenerator::AddPoints(_numVertices); break;
}
}
@ -225,7 +225,7 @@ void AddVertices(int _primitive, int _numVertices)
IndexGenerator::Start(TIBuffer,LIBuffer,PIBuffer);
Flushed=false;
}
lastPrimitive = _primitive;
lastPrimitive = _primitive;
ADDSTAT(stats.thisFrame.numPrims, _numVertices);
INCSTAT(stats.thisFrame.numPrimitiveJoins);
AddIndices(_primitive, _numVertices);
@ -244,7 +244,7 @@ inline void Draw(unsigned int stride, bool alphapass)
}
UINT bufoffset = 0;
UINT bufstride = (UINT)stride;
UINT bufstride = stride;
if (!alphapass) gfxstate->ApplyState();
else gfxstate->AlphaPass();
@ -361,7 +361,7 @@ void Flush()
Draw(stride, false);
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
if (bpmem.dstalpha.enable && bpmem.blendmode.alphaupdate)
{
DWORD write = 0;
if (!PixelShaderCache::SetShader(true))

View File

@ -92,16 +92,6 @@ bool IsD3D()
return true;
}
bool IsD3D9()
{
return false;
}
bool IsD3D11()
{
return true;
}
// This is used for the functions right below here which use wxwidgets
#if defined(HAVE_WX) && HAVE_WX
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
@ -128,7 +118,7 @@ void DllDebugger(HWND _hParent, bool Show)
return true;
}
};
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
IMPLEMENT_APP_NO_MAIN(wxDLLApp)
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
#endif
@ -173,7 +163,7 @@ void UpdateFPSDisplay(const char* text)
{
char temp[512];
sprintf_s(temp, 512, "SVN R%i: DX11: %s", SVN_REV, text);
SetWindowTextA(EmuWindow::GetWnd(), temp);
SetWindowTextA(EmuWindow::GetWnd(), temp);
}
void GetDllInfo(PLUGIN_INFO* _PluginInfo)
@ -220,9 +210,9 @@ void Initialize(void* init)
g_VideoInitialize.pPeekMessages = &Callback_PeekMessages;
g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay;
_pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages;
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
_pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages;
_pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay;
_pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle;
OSD::AddMessage("Dolphin Direct3D 11 Video Plugin.", 5000);
s_PluginInitialized = true;
@ -244,8 +234,8 @@ void Video_Prepare()
VertexShaderManager::Init();
PixelShaderCache::Init();
PixelShaderManager::Init();
CommandProcessor::Init();
PixelEngine::Init();
CommandProcessor::Init();
PixelEngine::Init();
D3D::InitUtils();
// tell the host that the window is ready
@ -339,14 +329,14 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight)
if (addrRangesOverlap(aLower, aUpper, bLower, bUpper))
VideoFifo_CheckSwapRequest();
}
}
}
}
// Run from the CPU thread (from VideoInterface.cpp)
void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
{
if (s_PluginInitialized && g_ActiveConfig.bUseXFB)
{
{
if (g_VideoInitialize.bOnThread)
{
while (Common::AtomicLoadAcquire(s_swapRequested) && !s_FifoShuttingDown)
@ -354,7 +344,7 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight)
Common::YieldCPU();
}
else
VideoFifo_CheckSwapRequest();
VideoFifo_CheckSwapRequest();
s_beginFieldArgs.xfbAddr = xfbAddr;
s_beginFieldArgs.field = field;
s_beginFieldArgs.fbWidth = fbWidth;
@ -373,11 +363,6 @@ void Video_AddMessage(const char* pstr, u32 milliseconds)
OSD::AddMessage(pstr, milliseconds);
}
HRESULT ScreenShot(const char* filename)
{
return S_OK;
}
void Video_Screenshot(const char* _szFilename)
{
Renderer::SetScreenshot(_szFilename);
@ -430,37 +415,37 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address)
{
CommandProcessor::Read16(_rReturnValue, _Address);
CommandProcessor::Read16(_rReturnValue, _Address);
}
void Video_CommandProcessorWrite16(const u16 _Data, const u32 _Address)
{
CommandProcessor::Write16(_Data, _Address);
CommandProcessor::Write16(_Data, _Address);
}
void Video_PixelEngineRead16(u16& _rReturnValue, const u32 _Address)
{
PixelEngine::Read16(_rReturnValue, _Address);
PixelEngine::Read16(_rReturnValue, _Address);
}
void Video_PixelEngineWrite16(const u16 _Data, const u32 _Address)
{
PixelEngine::Write16(_Data, _Address);
PixelEngine::Write16(_Data, _Address);
}
void Video_PixelEngineWrite32(const u32 _Data, const u32 _Address)
{
PixelEngine::Write32(_Data, _Address);
PixelEngine::Write32(_Data, _Address);
}
inline void Video_GatherPipeBursted(void)
{
CommandProcessor::GatherPipeBursted();
CommandProcessor::GatherPipeBursted();
}
void Video_WaitForFrameFinish(void)
{
CommandProcessor::WaitForFrameFinish();
CommandProcessor::WaitForFrameFinish();
}
bool Video_IsFifoBusy(void)

View File

@ -33,10 +33,10 @@
#include "TextureCache.h"
BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog)
EVT_CLOSE(GFXConfigDialogDX::OnClose)
EVT_BUTTON(ID_CLOSE, GFXConfigDialogDX::CloseClick)
//Direct3D Tab
EVT_CHECKBOX(ID_VSYNC, GFXConfigDialogDX::DirectXSettingsChanged)
EVT_CHECKBOX(ID_WIDESCREEN_HACK, GFXConfigDialogDX::DirectXSettingsChanged)
@ -48,13 +48,13 @@ BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog)
EVT_RADIOBUTTON(ID_RADIO_SAFETEXTURECACHE_SAFE, GFXConfigDialogDX::DirectXSettingsChanged)
EVT_RADIOBUTTON(ID_RADIO_SAFETEXTURECACHE_NORMAL, GFXConfigDialogDX::DirectXSettingsChanged)
EVT_RADIOBUTTON(ID_RADIO_SAFETEXTURECACHE_FAST, GFXConfigDialogDX::DirectXSettingsChanged)
//Enhancements tab
EVT_CHECKBOX(ID_FORCEFILTERING, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_CHECKBOX(ID_FORCEANISOTROPY, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_CHECKBOX(ID_LOADHIRESTEXTURES, GFXConfigDialogDX::EnhancementsSettingsChanged)
EVT_CHECKBOX(ID_EFBSCALEDCOPY, GFXConfigDialogDX::EnhancementsSettingsChanged)
//Advanced Tab
EVT_CHECKBOX(ID_DISABLEFOG, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_OVERLAYFPS, GFXConfigDialogDX::AdvancedSettingsChanged)
@ -71,11 +71,11 @@ BEGIN_EVENT_TABLE(GFXConfigDialogDX,wxDialog)
EVT_CHECKBOX(ID_OVERLAYSTATS, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_PROJSTATS, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_SHADERERRORS, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_TEXFMT_OVERLAY, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_TEXFMT_OVERLAY, GFXConfigDialogDX::AdvancedSettingsChanged)
EVT_CHECKBOX(ID_TEXFMT_CENTER, GFXConfigDialogDX::AdvancedSettingsChanged)
END_EVENT_TABLE()
GFXConfigDialogDX::GFXConfigDialogDX(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style)
{
@ -86,16 +86,19 @@ GFXConfigDialogDX::~GFXConfigDialogDX()
{
INFO_LOG(CONSOLE, "GFXConfigDialogDX Closed");
}
void GFXConfigDialogDX::OnClose(wxCloseEvent& event)
{
//INFO_LOG(CONSOLE, "OnClose");
CloseWindow();
}
void GFXConfigDialogDX::CloseClick(wxCommandEvent& WXUNUSED (event))
{
//INFO_LOG(CONSOLE, "CloseClick");
CloseWindow();
}
void GFXConfigDialogDX::InitializeGUIValues()
{
// General Display Settings
@ -115,7 +118,7 @@ void GFXConfigDialogDX::InitializeGUIValues()
m_Radio_SafeTextureCache_Normal->SetValue(true);
else
m_Radio_SafeTextureCache_Fast->SetValue(true);
// Enhancements
if(g_Config.iMaxAnisotropy == 1)
m_MaxAnisotropy->SetValue(false);
@ -128,11 +131,11 @@ void GFXConfigDialogDX::InitializeGUIValues()
m_HiresTextures->SetValue(g_Config.bHiresTextures);
m_MSAAModeCB->SetSelection(g_Config.iMultisampleMode);
m_EFBScaledCopy->SetValue(g_Config.bCopyEFBScaled);
//Advance
m_DisableFog->SetValue(g_Config.bDisableFog);
m_OverlayFPS->SetValue(g_Config.bShowFPS);
m_CopyEFB->SetValue(!g_Config.bEFBCopyDisable);
g_Config.bCopyEFBToTexture ? m_Radio_CopyEFBToGL->SetValue(true) : m_Radio_CopyEFBToRAM->SetValue(true);
@ -151,8 +154,9 @@ void GFXConfigDialogDX::InitializeGUIValues()
m_TexfmtCenter->SetValue(g_Config.bTexFmtOverlayCenter);
m_TexfmtCenter->Enable(m_TexfmtOverlay->IsChecked());
}
void GFXConfigDialogDX::CreateGUIControls()
{
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
this->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
@ -163,19 +167,19 @@ void GFXConfigDialogDX::CreateGUIControls()
m_PageDirect3D = new wxPanel( m_Notebook, ID_DIRERCT3D, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_PageEnhancements = new wxPanel( m_Notebook, ID_PAGEENHANCEMENTS, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
m_PageAdvanced = new wxPanel( m_Notebook, ID_PAGEADVANCED, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
//D3D Tab
//D3D Tab
wxStaticBoxSizer* sbBasic;
sbBasic = new wxStaticBoxSizer( new wxStaticBox( m_PageDirect3D, wxID_ANY, wxT("Basic") ), wxVERTICAL );
m_AdapterText = new wxStaticText( m_PageDirect3D, wxID_ANY, wxT("Adapter:"), wxDefaultPosition, wxDefaultSize, 0 );
m_AdapterText->Wrap( -1 );
wxArrayString arrayStringFor_AdapterCB;
wxArrayString arrayStringFor_AdapterCB;
for (int i = 0; i < D3D::GetNumAdapters(); ++i)
{
const D3D::Adapter &adapter = D3D::GetAdapter(i);
arrayStringFor_AdapterCB.Add(wxString::FromAscii(adapter.ident.Description));
}
}
const D3D::Adapter &adapter = D3D::GetAdapter(g_Config.iAdapter);
m_AdapterCB = new wxChoice( m_PageDirect3D, ID_ADAPTER, wxDefaultPosition, wxDefaultSize, arrayStringFor_AdapterCB, 0);
@ -201,21 +205,21 @@ void GFXConfigDialogDX::CreateGUIControls()
m_EFBScaleText->Wrap( -1 );
wxString m_EFBScaleModeChoices[] = { wxT("Auto (Fractional)"), wxT("Auto (Integral)"), wxT("1x"), wxT("2x"), wxT("3x") };
int m_EFBScaleModeNChoices = sizeof( m_EFBScaleModeChoices ) / sizeof( wxString );
m_EFBScaleMode = new wxChoice( m_PageDirect3D, ID_EFBSCALEMODE, wxDefaultPosition, wxDefaultSize, m_EFBScaleModeNChoices, m_EFBScaleModeChoices, 0 );
m_EFBScaleMode = new wxChoice( m_PageDirect3D, ID_EFBSCALEMODE, wxDefaultPosition, wxDefaultSize, m_EFBScaleModeNChoices, m_EFBScaleModeChoices, 0 );
m_EnableEFBAccess = new wxCheckBox( m_PageDirect3D, ID_EFB_ACCESS_ENABLE, wxT("Enable CPU->EFB access"), wxDefaultPosition, wxDefaultSize, 0 );
wxStaticBoxSizer* sbSTC;
sbSTC = new wxStaticBoxSizer( new wxStaticBox( m_PageDirect3D, wxID_ANY, wxT("Safe Texture Cache") ), wxVERTICAL );
m_SafeTextureCache = new wxCheckBox( m_PageDirect3D, ID_SAFETEXTURECACHE, wxT("Use Safe Texture Cache"), wxDefaultPosition, wxDefaultSize, 0 );
m_Radio_SafeTextureCache_Safe = new wxRadioButton( m_PageDirect3D, ID_RADIO_SAFETEXTURECACHE_SAFE, wxT("Safe"), wxDefaultPosition, wxDefaultSize, 0 );
m_Radio_SafeTextureCache_Normal = new wxRadioButton( m_PageDirect3D, ID_RADIO_SAFETEXTURECACHE_NORMAL, wxT("Normal"), wxDefaultPosition, wxDefaultSize, 0 );
m_Radio_SafeTextureCache_Fast = new wxRadioButton( m_PageDirect3D, ID_RADIO_SAFETEXTURECACHE_FAST, wxT("Fast"), wxDefaultPosition, wxDefaultSize, 0 );
// Sizers
wxGridBagSizer* sBasic;
wxBoxSizer* sGeneral;
sGeneral = new wxBoxSizer( wxVERTICAL );
sBasic = new wxGridBagSizer( 0, 0 );
sBasic->SetFlexibleDirection( wxBOTH );
@ -257,7 +261,7 @@ void GFXConfigDialogDX::CreateGUIControls()
m_ForceFiltering = new wxCheckBox( m_PageEnhancements, ID_FORCEFILTERING, wxT("Force bi/trilinear filtering (Breaks video in several Wii games )"), wxDefaultPosition, wxDefaultSize, 0 );
m_MaxAnisotropy = new wxCheckBox( m_PageEnhancements, ID_FORCEANISOTROPY, wxT("Enable 16x Anisotropy filtering"), wxDefaultPosition, wxDefaultSize, 0 );
m_HiresTextures = new wxCheckBox( m_PageEnhancements, ID_LOADHIRESTEXTURES, wxT("Enable hires Texture loading"), wxDefaultPosition, wxDefaultSize, 0 );
wxStaticBoxSizer* sbEFBHacks;
sbEFBHacks = new wxStaticBoxSizer( new wxStaticBox( m_PageEnhancements, wxID_ANY, wxT("EFB Hacks") ), wxVERTICAL );
m_EFBScaledCopy = new wxCheckBox( m_PageEnhancements, ID_EFBSCALEDCOPY, wxT("EFB Scaled Copy"), wxDefaultPosition, wxDefaultSize, 0 );
@ -348,10 +352,10 @@ void GFXConfigDialogDX::CreateGUIControls()
wxGridBagSizer* sDebuggingTools;
sDebuggingTools = new wxGridBagSizer( 0, 0 );
sDebuggingTools->SetFlexibleDirection( wxBOTH );
sDebuggingTools->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
sDebuggingTools->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
sDebuggingTools->Add( m_OverlayStats, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sDebuggingTools->Add( m_ShaderErrors, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sDebuggingTools->Add( m_TexfmtOverlay, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sDebuggingTools->Add( m_TexfmtOverlay, wxGBPosition( 2, 0 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sDebuggingTools->Add( m_TexfmtCenter, wxGBPosition( 2, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sDebuggingTools->Add( m_ProjStats, wxGBPosition( 0, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 );
sbDebuggingTools->Add( sDebuggingTools, 0, wxEXPAND, 5 );
@ -380,6 +384,7 @@ void GFXConfigDialogDX::CreateGUIControls()
Center();
UpdateGUI();
}
void GFXConfigDialogDX::DirectXSettingsChanged(wxCommandEvent& event)
{
switch (event.GetId())

View File

@ -162,8 +162,6 @@ class GFXConfigDialogDX : public wxDialog
ID_SHADERERRORS,
ID_TEXFMT_OVERLAY,
ID_TEXFMT_CENTER,
ID_CHECK1,
ID_LIST1,
ID_DEBUGSTEP,
ID_REGISTERS,
ID_ENABLEDEBUGGING,

View File

@ -182,7 +182,7 @@ static const D3DBLEND d3dLogicOpDestFactors[16] =
D3DBLEND_ONE
};
static const D3DCULL d3dCullModes[4] =
static const D3DCULL d3dCullModes[4] =
{
D3DCULL_NONE,
D3DCULL_CCW,
@ -190,7 +190,7 @@ static const D3DCULL d3dCullModes[4] =
D3DCULL_CCW
};
static const D3DCMPFUNC d3dCmpFuncs[8] =
static const D3DCMPFUNC d3dCmpFuncs[8] =
{
D3DCMP_NEVER,
D3DCMP_LESS,
@ -202,7 +202,7 @@ static const D3DCMPFUNC d3dCmpFuncs[8] =
D3DCMP_ALWAYS
};
static const D3DTEXTUREFILTERTYPE d3dMipFilters[4] =
static const D3DTEXTUREFILTERTYPE d3dMipFilters[4] =
{
D3DTEXF_NONE,
D3DTEXF_POINT,
@ -231,7 +231,6 @@ void SetupDeviceObjects()
// To avoid shader compilation stutters, read back all shaders from cache.
VertexShaderCache::Init();
PixelShaderCache::Init();
// Texture cache will recreate themselves over time.
}
@ -272,7 +271,7 @@ bool Renderer::Init()
if (fullScreenRes == D3D::GetAdapter(g_ActiveConfig.iAdapter).resolutions.size())
fullScreenRes = 0;
D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(),
D3D::Create(g_ActiveConfig.iAdapter, EmuWindow::GetWnd(),
fullScreenRes, backbuffer_ms_mode, false);
IS_AMD = D3D::IsATIDevice();
@ -297,14 +296,14 @@ bool Renderer::Init()
s_LastAA = g_ActiveConfig.iMultisampleMode;
s_LastEFBScale = g_ActiveConfig.iEFBScale;
float SupersampleCoeficient = s_LastAA + 1;
float SupersampleCoeficient = s_LastAA + 1;
switch(s_LastEFBScale)
{
case 0:
case 0:
EFBxScale = xScale;
EFByScale = yScale;
break;
case 1:
case 1:
EFBxScale = ceilf(xScale);
EFByScale = ceilf(yScale);
break;
@ -443,7 +442,7 @@ void Renderer::DrawDebugText()
T0.push_back(StringFromFormat("4: Aspect Ratio: %s%s\n", OSDM21.c_str(), OSDM22.c_str()));
T0.push_back(StringFromFormat("5: Copy EFB: %s\n", OSDM3.c_str()));
T0.push_back(StringFromFormat("6: Fog: %s\n", g_ActiveConfig.bDisableFog ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
T0.push_back(StringFromFormat("7: Material Lighting: %s\n", g_ActiveConfig.bDisableLighting ? "Disabled" : "Enabled"));
// The latest changed setting in yellow
T1 += (OSDChoice == -1) ? T0.at(0) : "\n";
@ -516,7 +515,7 @@ void CheckForResize()
int width = rcParentWindow.right - rcParentWindow.left;
int height = rcParentWindow.bottom - rcParentWindow.top;
if (width != s_backbuffer_width || height != s_backbuffer_height)
::MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
MoveWindow(EmuWindow::GetWnd(), 0, 0, width, height, FALSE);
}
RECT rcWindow;
GetClientRect(EmuWindow::GetWnd(), &rcWindow);
@ -529,7 +528,7 @@ void CheckForResize()
{
TeardownDeviceObjects();
D3D::Reset();
D3D::Reset();
s_backbuffer_width = D3D::GetBackBufferWidth();
s_backbuffer_height = D3D::GetBackBufferHeight();
WindowResized = true;
@ -540,7 +539,7 @@ void CheckForResize()
void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc)
{
if(!fbWidth || !fbHeight)
if (!fbWidth || !fbHeight)
return;
VideoFifo_CheckEFBAccess();
VideoFifo_CheckSwapRequestAt(xfbAddr, fbWidth, fbHeight);
@ -596,7 +595,7 @@ bool Renderer::SetScissorRect()
rc.left = (int)(rc.left * EFBxScale) + Xstride;
rc.top = (int)(rc.top * EFByScale) + Ystride;
rc.right = (int)(rc.right * EFBxScale) + Xstride;
rc.bottom = (int)(rc.bottom * EFByScale) + Ystride;
rc.bottom = (int)(rc.bottom * EFByScale) + Ystride;
if (rc.right != rc.left && rc.bottom != rc.top)
{
@ -611,7 +610,6 @@ bool Renderer::SetScissorRect()
rc.right = Xstride + s_target_width;
rc.bottom = Ystride + s_target_height;
D3D::dev->SetScissorRect(&rc);
return false;
}
return false;
}
@ -619,9 +617,9 @@ bool Renderer::SetScissorRect()
void Renderer::SetColorMask()
{
DWORD color_mask = 0;
if (bpmem.blendmode.alphaupdate)
if (bpmem.blendmode.alphaupdate)
color_mask = D3DCOLORWRITEENABLE_ALPHA;
if (bpmem.blendmode.colorupdate)
if (bpmem.blendmode.colorupdate)
color_mask |= D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask);
}
@ -631,16 +629,16 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
if (!g_ActiveConfig.bEFBAccessEnable)
return 0;
//Get the working buffer
// Get the working buffer
LPDIRECT3DSURFACE9 pBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthRTSurface() : FBManager.GetEFBColorRTSurface();
//get the temporal buffer to move 1pixel data
// Get the temporal buffer to move 1pixel data
LPDIRECT3DSURFACE9 RBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthReadSurface() : FBManager.GetEFBColorReadSurface();
//get the memory buffer that can be locked
// Get the memory buffer that can be locked
LPDIRECT3DSURFACE9 pOffScreenBuffer = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthOffScreenRTSurface() : FBManager.GetEFBColorOffScreenRTSurface();
//get the buffer format
// Get the buffer format
D3DFORMAT BufferFormat = (type == PEEK_Z || type == POKE_Z) ?
FBManager.GetEFBDepthRTSurfaceFormat() : FBManager.GetEFBColorRTSurfaceFormat();
D3DFORMAT ReadBufferFormat = (type == PEEK_Z || type == POKE_Z) ?
@ -651,7 +649,7 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
D3DLOCKED_RECT drect;
//Buffer not found alert
// Buffer not found alert
if (!pBuffer) {
PanicAlert("No %s!", (type == PEEK_Z || type == POKE_Z) ? "Z-Buffer" : "Color EFB");
return 0;
@ -689,8 +687,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
RectToLock.bottom--;
if ((RectToLock.right - RectToLock.left) > 4)
RectToLock.left++;
ResetAPIState(); // reset any game specific settings
hr =D3D::dev->SetDepthStencilSurface(NULL);
ResetAPIState(); // Reset any game specific settings
hr = D3D::dev->SetDepthStencilSurface(NULL);
hr = D3D::dev->SetRenderTarget(0, RBuffer);
if (FAILED(hr))
{
@ -711,22 +709,22 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
PanicAlert("unable to set pixel viewport");
return 0;
}
float colmat[16]= {0.0f};
float colmat[16] = {0.0f};
float fConstAdd[4] = {0.0f};
colmat[0] = colmat[5] = colmat[10] = 1.0f;
PixelShaderManager::SetColorMatrix(colmat, fConstAdd); // set transformation
EFBRectangle source_rect;
LPDIRECT3DTEXTURE9 read_texture = FBManager.GetEFBDepthTexture(source_rect);
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::drawShadedTexQuad(
read_texture,
read_texture,
&RectToLock,
Renderer::GetFullTargetWidth() ,
Renderer::GetFullTargetHeight(),
4,4,
(BufferFormat == FOURCC_RAWZ)?PixelShaderCache::GetColorMatrixProgram(0):PixelShaderCache::GetDepthMatrixProgram(0),
Renderer::GetFullTargetWidth(),
Renderer::GetFullTargetHeight(),
4, 4,
(BufferFormat == FOURCC_RAWZ) ? PixelShaderCache::GetColorMatrixProgram(0) : PixelShaderCache::GetDepthMatrixProgram(0),
VertexShaderCache::GetSimpleVertexShader(0));
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
@ -738,11 +736,10 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
RectToLock.left = 0;
RectToLock.right = 4;
RectToLock.top = 0;
}
else
{
hr = D3D::dev->StretchRect(pBuffer,&RectToLock,RBuffer,NULL, D3DTEXF_NONE);
hr = D3D::dev->StretchRect(pBuffer, &RectToLock, RBuffer, NULL, D3DTEXF_NONE);
//change the rect to lock the entire one pixel buffer
RectToLock.bottom = 1;
RectToLock.left = 0;
@ -754,36 +751,34 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
PanicAlert("Unable to stretch data to buffer");
return 0;
}
//retriebe the pixel data to the local memory buffer
D3D::dev->GetRenderTargetData(RBuffer,pOffScreenBuffer);
// Retrieve the pixel data to the local memory buffer
D3D::dev->GetRenderTargetData(RBuffer, pOffScreenBuffer);
if (FAILED(hr))
{
PanicAlert("Unable to copy data to mem buffer");
return 0;
}
//the surface is good.. lock it
// The surface is good.. lock it
if ((hr = pOffScreenBuffer->LockRect(&drect, &RectToLock, D3DLOCK_READONLY)) != D3D_OK)
{
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" : hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
return 0;
}
switch(type) {
switch (type) {
case PEEK_Z:
{
switch (ReadBufferFormat)
{
case D3DFMT_R32F:
val = ((float *)drect.pBits)[6];
val = ((float*)drect.pBits)[6];
break;
default:
float ffrac = 1.0f/255.0f;
z = ((u32 *)drect.pBits)[6];
z = ((u32*)drect.pBits)[6];
val = ((float)((z>>16) & 0xFF)) * ffrac;
ffrac*= 1 / 255.0f;
val += ((float)((z>>8) & 0xFF)) * ffrac;
@ -805,16 +800,14 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
break;
case POKE_COLOR:
// TODO: Get that ARGB value to poke from somewhere
//((float *)drect.pBits)[0] = val;
//((float*)drect.pBits)[0] = val;
PanicAlert("Poke color EFB not implemented");
break;
}
pOffScreenBuffer->UnlockRect();
pOffScreenBuffer->UnlockRect();
// TODO: in RE0 this value is often off by one, which causes lighting to disappear
return z;
}
// Called from VertexShaderManager
@ -854,32 +847,32 @@ void UpdateViewport()
Height *= -1;
}
bool sizeChanged = false;
if(X < 0)
if (X < 0)
{
s_Fulltarget_width -= 2 * X;
X = 0;
sizeChanged=true;
}
if(Y < 0)
if (Y < 0)
{
s_Fulltarget_height -= 2 * Y;
Y = 0;
sizeChanged=true;
sizeChanged = true;
}
if(!IS_AMD)
if (!IS_AMD)
{
if(X + Width > s_Fulltarget_width)
{
s_Fulltarget_width += (X + Width - s_Fulltarget_width) * 2;
sizeChanged=true;
sizeChanged = true;
}
if(Y + Height > s_Fulltarget_height)
{
s_Fulltarget_height += (Y + Height - s_Fulltarget_height) * 2;
sizeChanged=true;
sizeChanged = true;
}
}
if(sizeChanged)
if (sizeChanged)
{
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
@ -887,42 +880,42 @@ void UpdateViewport()
FBManager.Create();
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
}
}
vp.X = X;
vp.Y = Y;
vp.Width = Width;
vp.Height = Height;
//some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
vp.MinZ = 0.0f;//(xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ =1.0f;// xfregs.rawViewport[5] / 16777216.0f;
// Some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
vp.MinZ = 0.0f; // (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ =1.0f; // xfregs.rawViewport[5] / 16777216.0f;
D3D::dev->SetViewport(&vp);
}
void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z)
{
{
// Update the view port for clearing the picture
TargetRectangle targetRc = Renderer::ConvertEFBRectangle(rc);
D3DVIEWPORT9 vp;
vp.X = targetRc.left;
vp.Y = targetRc.top;
vp.Y = targetRc.top;
vp.Width = targetRc.GetWidth();
vp.Height = targetRc.GetHeight();
vp.MinZ = 0.0;
vp.MaxZ = 1.0;
D3D::dev->SetViewport(&vp);
D3D::dev->SetViewport(&vp);
// Always set the scissor in case it was set by the game and has not been reset
RECT sirc;
sirc.left = targetRc.left;
sirc.top = targetRc.top;
sirc.right = targetRc.right;
sirc.bottom = targetRc.bottom;
D3D::dev->SetScissorRect(&sirc);
RECT sicr;
sicr.left = targetRc.left;
sicr.top = targetRc.top;
sicr.right = targetRc.right;
sicr.bottom = targetRc.bottom;
D3D::dev->SetScissorRect(&sicr);
D3D::ChangeRenderState(D3DRS_ALPHABLENDENABLE, false);
if (zEnable)
D3D::ChangeRenderState(D3DRS_ZFUNC, D3DCMP_ALWAYS);
D3D::drawClearQuad(color ,(z & 0xFFFFFF) / float(0xFFFFFF),PixelShaderCache::GetClearProgram(),VertexShaderCache::GetClearVertexShader());
D3D::drawClearQuad(color, (z & 0xFFFFFF) / float(0xFFFFFF), PixelShaderCache::GetClearProgram(), VertexShaderCache::GetClearVertexShader());
if (zEnable)
D3D::RefreshRenderState(D3DRS_ZFUNC);
D3D::RefreshRenderState(D3DRS_ALPHABLENDENABLE);
@ -931,27 +924,27 @@ void Renderer::ClearScreen(const EFBRectangle& rc, bool colorEnable, bool alphaE
}
void Renderer::SetBlendMode(bool forceUpdate)
{
{
if (bpmem.blendmode.logicopenable)
return;
if (bpmem.blendmode.subtract && bpmem.blendmode.blendenable)
if (bpmem.blendmode.subtract && bpmem.blendmode.blendenable)
{
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_REVSUBTRACT);
D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[1]);
D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[1]);
}
else
}
else
{
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0)));
if (bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0)))
if (bpmem.blendmode.blendenable && (!( bpmem.blendmode.srcfactor == 1 && bpmem.blendmode.dstfactor == 0)))
{
D3D::SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD);
D3D::SetRenderState(D3DRS_SRCBLEND, d3dSrcFactors[bpmem.blendmode.srcfactor]);
D3D::SetRenderState(D3DRS_DESTBLEND, d3dDestFactors[bpmem.blendmode.dstfactor]);
}
}
}
}
}
@ -972,9 +965,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
const XFBSource** xfbSourceList = FBManager.GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount);
if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB)
{
g_VideoInitialize.pCopiedToXFB(false);
g_VideoInitialize.pCopiedToXFB(false);
return;
}
}
Renderer::ResetAPIState();
// Set the backbuffer as the rendering target
@ -991,7 +984,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
vp.MinZ = 0.0f;
vp.MaxZ = 1.0f;
D3D::dev->SetViewport(&vp);
D3D::dev->Clear(0,NULL, D3DCLEAR_TARGET,D3DCOLOR_XRGB(0,0,0),1.0f,0);
D3D::dev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
int X = dst_rect.left;
int Y = dst_rect.top;
@ -1078,7 +1071,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
D3D::drawShadedTexQuad(read_texture,targetRc.AsRECT(),Renderer::GetFullTargetWidth(),Renderer::GetFullTargetHeight(),Width,Height,PixelShaderCache::GetColorCopyProgram(g_Config.iMultisampleMode),VertexShaderCache::GetSimpleVertexShader(g_Config.iMultisampleMode));
}
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
vp.X = 0;
vp.Y = 0;
vp.Width = s_backbuffer_width;
@ -1104,68 +1097,67 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
s_bScreenshot = false;
s_criticalScreenshot.Leave();
}
if (g_ActiveConfig.bDumpFrames)
if (g_ActiveConfig.bDumpFrames)
{
D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(),ScreenShootMEMSurface);
if (!s_LastFrameDumped)
D3D::dev->GetRenderTargetData(D3D::GetBackBufferSurface(), ScreenShootMEMSurface);
if (!s_LastFrameDumped)
{
s_recordWidth = s_backbuffer_width;
s_recordHeight = s_backbuffer_height;
s_AVIDumping = AVIDump::Start(EmuWindow::GetParentWnd(), s_recordWidth, s_recordHeight);
if (!s_AVIDumping)
if (!s_AVIDumping)
{
PanicAlert("Error dumping frames to AVI.");
}
else
}
else
{
char msg [255];
sprintf_s(msg,255, "Dumping Frames to \"%sframedump0.avi\" (%dx%d RGB24)", File::GetUserPath(D_DUMPFRAMES_IDX), s_recordWidth, s_recordHeight);
OSD::AddMessage(msg, 2000);
}
}
if (s_AVIDumping)
if (s_AVIDumping)
{
D3DLOCKED_RECT rect;
if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
if (SUCCEEDED(ScreenShootMEMSurface->LockRect(&rect, NULL, D3DLOCK_NO_DIRTY_UPDATE | D3DLOCK_NOSYSLOCK | D3DLOCK_READONLY)))
{
char *data = (char *)malloc(3 * s_recordWidth * s_recordHeight);
formatBufferDump((const char *)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch);
char* data = (char*)malloc(3 * s_recordWidth * s_recordHeight);
formatBufferDump((const char*)rect.pBits, data, s_recordWidth, s_recordHeight, rect.Pitch);
AVIDump::AddFrame(data);
free(data);
ScreenShootMEMSurface->UnlockRect();
}
}
s_LastFrameDumped = true;
}
else
}
else
{
if (s_LastFrameDumped && s_AVIDumping)
if (s_LastFrameDumped && s_AVIDumping)
{
AVIDump::Stop();
s_AVIDumping = false;
}
s_LastFrameDumped = false;
}
// Finish up the current frame, print some stats
if (g_ActiveConfig.bShowFPS)
{
char fps[20];
StringCchPrintfA(fps, 20, "FPS: %d\n", s_fps);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,fps,false);
D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, fps, false);
}
Renderer::DrawDebugText();
if (g_ActiveConfig.bOverlayStats)
{
Statistics::ToString(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false);
}
else if (g_ActiveConfig.bOverlayProjStats)
{
Statistics::ToStringProj(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
D3D::font.DrawTextScaled(0, 30, 20, 20, 0.0f, 0xFF00FFFF, st, false);
}
@ -1177,28 +1169,27 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
TextureCache::Cleanup();
// Make any new configuration settings active.
UpdateActiveConfig();
UpdateActiveConfig();
WindowResized = false;
CheckForResize();
bool xfbchanged = false;
if(s_XFB_width != fbWidth || s_XFB_height != fbHeight)
if (s_XFB_width != fbWidth || s_XFB_height != fbHeight)
{
xfbchanged = true;
s_XFB_width = fbWidth;
s_XFB_height = fbHeight;
if(s_XFB_width < 1) s_XFB_width = MAX_XFB_WIDTH;
if(s_XFB_width > MAX_XFB_WIDTH) s_XFB_width = MAX_XFB_WIDTH;
if(s_XFB_height < 1) s_XFB_height = MAX_XFB_HEIGHT;
if(s_XFB_height > MAX_XFB_HEIGHT) s_XFB_height = MAX_XFB_HEIGHT;
if (s_XFB_width < 1) s_XFB_width = MAX_XFB_WIDTH;
if (s_XFB_width > MAX_XFB_WIDTH) s_XFB_width = MAX_XFB_WIDTH;
if (s_XFB_height < 1) s_XFB_height = MAX_XFB_HEIGHT;
if (s_XFB_height > MAX_XFB_HEIGHT) s_XFB_height = MAX_XFB_HEIGHT;
}
u32 newAA = g_ActiveConfig.iMultisampleMode;
u32 newEFBScale = g_ActiveConfig.iEFBScale;
if(newAA != s_LastAA || newEFBScale != s_LastEFBScale || xfbchanged || WindowResized)
{
if (newAA != s_LastAA || newEFBScale != s_LastEFBScale || xfbchanged || WindowResized)
{
s_LastAA = newAA;
s_LastEFBScale = newEFBScale;
@ -1217,11 +1208,11 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
float SupersampleCoeficient = s_LastAA + 1;
switch(s_LastEFBScale)
{
case 0:
case 0:
EFBxScale = xScale;
EFByScale = yScale;
break;
case 1:
case 1:
EFBxScale = ceilf(xScale);
EFByScale = ceilf(yScale);
break;
@ -1237,7 +1228,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
s_target_height = EFB_HEIGHT * EFByScale;
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(D3D::GetBackBufferDepthSurface());
if(WindowResized)
if (WindowResized)
{
SetupDeviceObjects();
}
@ -1248,7 +1239,6 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
}
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
}
// ---------------------------------------------------------------------
@ -1256,9 +1246,9 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
// -------------
static int fpscount = 1;
static unsigned long lasttime;
if(XFBWrited)
if (XFBWrited)
++fpscount;
if (Common::Timer::GetTimeMs() - lasttime > 1000)
if (Common::Timer::GetTimeMs() - lasttime > 1000)
{
lasttime = Common::Timer::GetTimeMs();
s_fps = fpscount - 1;
@ -1288,7 +1278,7 @@ void Renderer::ResetAPIState()
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZENABLE, FALSE);
D3D::SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA| D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
DWORD color_mask = D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE;
D3D::SetRenderState(D3DRS_COLORWRITEENABLE, color_mask);
}
@ -1298,8 +1288,10 @@ void Renderer::RestoreAPIState()
D3D::SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE);
UpdateViewport();
SetScissorRect();
if (bpmem.zmode.testenable) D3D::SetRenderState(D3DRS_ZENABLE, TRUE);
if (bpmem.zmode.updateenable) D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
if (bpmem.zmode.testenable)
D3D::SetRenderState(D3DRS_ZENABLE, TRUE);
if (bpmem.zmode.updateenable)
D3D::SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
SetColorMask();
SetLogicOpMode();
}
@ -1326,7 +1318,7 @@ void Renderer::SetDepthMode()
void Renderer::SetLogicOpMode()
{
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
if (bpmem.blendmode.logicopenable && bpmem.blendmode.logicmode != 3)
{
D3D::SetRenderState(D3DRS_ALPHABLENDENABLE, true);
D3D::SetRenderState(D3DRS_BLENDOP, d3dLogicOpop[bpmem.blendmode.logicmode]);
@ -1341,7 +1333,7 @@ void Renderer::SetLogicOpMode()
void Renderer::SetDitherMode()
{
D3D::SetRenderState(D3DRS_DITHERENABLE,bpmem.blendmode.dither);
D3D::SetRenderState(D3DRS_DITHERENABLE, bpmem.blendmode.dither);
}
void Renderer::SetLineWidth()
@ -1354,7 +1346,7 @@ void Renderer::SetLineWidth()
void Renderer::SetSamplerState(int stage, int texindex)
{
const FourTexUnits &tex = bpmem.tex[texindex];
const FourTexUnits &tex = bpmem.tex[texindex];
const TexMode0 &tm0 = tex.texMode0[stage];
const TexMode1 &tm1 = tex.texMode1[stage];
@ -1367,14 +1359,14 @@ void Renderer::SetSamplerState(int stage, int texindex)
{
min = (tm0.min_filter & 4) ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mag = tm0.mag_filter ? D3DTEXF_LINEAR : D3DTEXF_POINT;
mip = (tm0.min_filter == 8)?D3DTEXF_NONE:d3dMipFilters[tm0.min_filter & 3];
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0)) mip = D3DTEXF_NONE;
mip = (tm0.min_filter == 8) ? D3DTEXF_NONE : d3dMipFilters[tm0.min_filter & 3];
if((tm0.min_filter & 3) && (tm0.min_filter != 8) && ((tm1.max_lod >> 4) == 0))
mip = D3DTEXF_NONE;
}
if (texindex)
stage += 4;
stage += 4;
if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR &&
g_ActiveConfig.iMaxAnisotropy > 1)
if (mag == D3DTEXF_LINEAR && min == D3DTEXF_LINEAR && g_ActiveConfig.iMaxAnisotropy > 1)
{
min = D3DTEXF_ANISOTROPIC;
}
@ -1386,8 +1378,8 @@ void Renderer::SetSamplerState(int stage, int texindex)
D3D::SetSamplerState(stage, D3DSAMP_ADDRESSV, d3dClamps[tm0.wrap_t]);
//float SuperSampleCoeficient = (s_LastAA < 3)? s_LastAA + 1 : s_LastAA - 1;// uncoment this changes to conserve detail when incresing ssaa level
float lodbias = (tm0.lod_bias / 32.0f);// + (s_LastAA)?(log(SuperSampleCoeficient) / log(2.0f)):0;
D3D::SetSamplerState(stage,D3DSAMP_MIPMAPLODBIAS,*(DWORD*)&lodbias);
D3D::SetSamplerState(stage,D3DSAMP_MAXMIPLEVEL,tm1.min_lod>>4);
D3D::SetSamplerState(stage, D3DSAMP_MIPMAPLODBIAS, *(DWORD*)&lodbias);
D3D::SetSamplerState(stage, D3DSAMP_MAXMIPLEVEL, tm1.min_lod >> 4);
}
void Renderer::SetInterlacingMode()
@ -1399,7 +1391,7 @@ void Renderer::SetInterlacingMode()
void Renderer::SetScreenshot(const char *filename)
{
s_criticalScreenshot.Enter();
strcpy_s(s_sScreenshotName,filename);
strcpy_s(s_sScreenshotName, filename);
s_bScreenshot = true;
s_criticalScreenshot.Leave();
}

View File

@ -53,9 +53,9 @@ public:
private:
DECLARE_EVENT_TABLE();
wxPanel *m_MainPanel;
wxPanel* m_MainPanel;
wxCheckBox *m_Check[6];
wxCheckBox* m_Check[6];
// WARNING: Make sure these are not also elsewhere
enum
@ -70,7 +70,7 @@ private:
NUM_OPTIONS
};
void OnClose(wxCloseEvent& event);
void OnClose(wxCloseEvent& event);
void CreateGUIControls();
void GeneralSettings(wxCommandEvent& event);

View File

@ -1,29 +1,29 @@
#include "UDPNunchuk.h"
#include "UDPWrapper.h"
#include "UDPWiimote.h"
#include "UDPNunchuk.h"
#include "UDPWrapper.h"
#include "UDPWiimote.h"
#define NUNCHUK_C 0x02
#define NUNCHUK_Z 0x01
#define NUNCHUK_Z 0x01
namespace WiimoteEmu
{
void UDPNunchuk::GetState( u8* const data, const bool focus )
{
Nunchuk::GetState(data,focus);
if (!(wrp->inst)) return;
wm_extension* const ncdata = (wm_extension*)data;
u8 mask;
float x,y;
wrp->inst->getNunchuck(x,y,mask);
if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C;
if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z;
if ((ncdata->jx==0x80)&&(ncdata->jy==0x80))
{
ncdata->jx=u8(0x80+x*127);
ncdata->jy=u8(0x80+y*127);
}
}
{
void UDPNunchuk::GetState( u8* const data, const bool focus )
{
Nunchuk::GetState(data, focus);
if (!(wrp->inst)) return;
wm_extension* const ncdata = (wm_extension*)data;
u8 mask;
float x, y;
wrp->inst->getNunchuck(x, y, mask);
if (mask&UDPWM_NC) ncdata->bt&=~NUNCHUK_C;
if (mask&UDPWM_NZ) ncdata->bt&=~NUNCHUK_Z;
if ((ncdata->jx==0x80)&&(ncdata->jy==0x80))
{
ncdata->jx=u8(0x80+x*127);
ncdata->jy=u8(0x80+y*127);
}
}
}

View File

@ -1,7 +1,7 @@
#ifndef UDPNUNCHUCK_H
#define UDPNUNCHUCK_H
#include "Nunchuk.h"
#ifndef UDPNUNCHUCK_H
#define UDPNUNCHUCK_H
#include "Nunchuk.h"
class UDPWrapper;
@ -11,11 +11,11 @@ namespace WiimoteEmu
class UDPNunchuk : public Nunchuk
{
public:
UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp ) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p
virtual void GetState( u8* const data, const bool focus );
private:
UDPWrapper * wrp;
};
}
#endif
UDPNunchuk(UDPWrapper * _wrp) : wrp(_wrp) {name="UDP Nunchuk";}; //sorry for this :p I just dont' feel like rewriting the whole class for a name :p
virtual void GetState( u8* const data, const bool focus );
private:
UDPWrapper * wrp;
};
}
#endif

View File

@ -1,53 +1,53 @@
//UDP Wiimote Translation Layer
#ifndef UDPTLAYER_H
#define UDPTLAYER_H
#include "UDPWiimote.h"
namespace UDPTLayer
{
void GetButtons(UDPWrapper * m , wm_core * butt)
{
if (!(m->inst)) return;
if (!(m->updButt)) return;
u32 mask=m->inst->getButtons();
*butt|=(mask&UDPWM_BA)?WIIMOTE_A:0;
*butt|=(mask&UDPWM_BB)?WIIMOTE_B:0;
*butt|=(mask&UDPWM_B1)?WIIMOTE_ONE:0;
*butt|=(mask&UDPWM_B2)?WIIMOTE_TWO:0;
*butt|=(mask&UDPWM_BP)?WIIMOTE_PLUS:0;
*butt|=(mask&UDPWM_BM)?WIIMOTE_MINUS:0;
*butt|=(mask&UDPWM_BH)?WIIMOTE_HOME:0;
*butt|=(mask&UDPWM_BU)?WIIMOTE_PAD_UP:0;
*butt|=(mask&UDPWM_BD)?WIIMOTE_PAD_DOWN:0;
*butt|=(mask&UDPWM_BL)?WIIMOTE_PAD_LEFT:0;
*butt|=(mask&UDPWM_BR)?WIIMOTE_PAD_RIGHT:0;
}
void GetAcceleration(UDPWrapper * m , wm_accel * data, accel_cal * calib)
{
if (!(m->inst)) return;
if (!(m->updAccel)) return;
float x,y,z;
m->inst->getAccel(x,y,z);
data->x=u8(x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x);
data->y=u8(y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y);
data->z=u8(z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z);
}
void GetIR( UDPWrapper * m, float * x, float * y, float * z)
{
if (!(m->inst)) return;
if (!(m->updIR)) return;
if ((*x>-1)&&(*x<1)&&(*y>-1)&&(*y<1)) return; //the recieved values are used ONLY when the normal pointer is offscreen
float _x,_y;
m->inst->getIR(_x,_y);
*x=_x*2-1;
*y=-(_y*2-1);
*z=0;
}
}
#endif
//UDP Wiimote Translation Layer
#ifndef UDPTLAYER_H
#define UDPTLAYER_H
#include "UDPWiimote.h"
namespace UDPTLayer
{
void GetButtons(UDPWrapper * m , wm_core * butt)
{
if (!(m->inst)) return;
if (!(m->updButt)) return;
u32 mask=m->inst->getButtons();
*butt|=(mask&UDPWM_BA)?WIIMOTE_A:0;
*butt|=(mask&UDPWM_BB)?WIIMOTE_B:0;
*butt|=(mask&UDPWM_B1)?WIIMOTE_ONE:0;
*butt|=(mask&UDPWM_B2)?WIIMOTE_TWO:0;
*butt|=(mask&UDPWM_BP)?WIIMOTE_PLUS:0;
*butt|=(mask&UDPWM_BM)?WIIMOTE_MINUS:0;
*butt|=(mask&UDPWM_BH)?WIIMOTE_HOME:0;
*butt|=(mask&UDPWM_BU)?WIIMOTE_PAD_UP:0;
*butt|=(mask&UDPWM_BD)?WIIMOTE_PAD_DOWN:0;
*butt|=(mask&UDPWM_BL)?WIIMOTE_PAD_LEFT:0;
*butt|=(mask&UDPWM_BR)?WIIMOTE_PAD_RIGHT:0;
}
void GetAcceleration(UDPWrapper * m , wm_accel * data, accel_cal * calib)
{
if (!(m->inst)) return;
if (!(m->updAccel)) return;
float x,y,z;
m->inst->getAccel(x,y,z);
data->x=u8(x*(calib->one_g.x-calib->zero_g.x)+calib->zero_g.x);
data->y=u8(y*(calib->one_g.y-calib->zero_g.y)+calib->zero_g.y);
data->z=u8(z*(calib->one_g.z-calib->zero_g.z)+calib->zero_g.z);
}
void GetIR( UDPWrapper * m, float * x, float * y, float * z)
{
if (!(m->inst)) return;
if (!(m->updIR)) return;
if ((*x>-1)&&(*x<1)&&(*y>-1)&&(*y<1)) return; //the recieved values are used ONLY when the normal pointer is offscreen
float _x,_y;
m->inst->getIR(_x,_y);
*x=_x*2-1;
*y=-(_y*2-1);
*z=0;
}
}
#endif