(D3D) Cleanups
This commit is contained in:
parent
08b7ac500b
commit
64559154cf
|
@ -262,15 +262,9 @@ static void renderchain_set_shader_params(cg_renderchain_t *chain,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define DECL_FVF_POSITION(stream) \
|
|
||||||
{ (WORD)(stream), 0 * sizeof(float), D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, \
|
|
||||||
D3DDECLUSAGE_POSITION, 0 }
|
|
||||||
#define DECL_FVF_TEXCOORD(stream, offset, index) \
|
#define DECL_FVF_TEXCOORD(stream, offset, index) \
|
||||||
{ (WORD)(stream), (WORD)(offset * sizeof(float)), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, \
|
{ (WORD)(stream), (WORD)(offset * sizeof(float)), D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, \
|
||||||
D3DDECLUSAGE_TEXCOORD, (BYTE)(index) }
|
D3DDECLUSAGE_TEXCOORD, (BYTE)(index) }
|
||||||
#define DECL_FVF_COLOR(stream, offset, index) \
|
|
||||||
{ (WORD)(stream), (WORD)(offset * sizeof(float)), D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, \
|
|
||||||
D3DDECLUSAGE_COLOR, (BYTE)(index) } \
|
|
||||||
|
|
||||||
static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||||
{
|
{
|
||||||
|
@ -283,10 +277,8 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||||
cg_renderchain_t *chain = (cg_renderchain_t*)data;
|
cg_renderchain_t *chain = (cg_renderchain_t*)data;
|
||||||
Pass *pass = (Pass*)pass_data;
|
Pass *pass = (Pass*)pass_data;
|
||||||
static const D3DVERTEXELEMENT decl_end = D3DDECL_END();
|
static const D3DVERTEXELEMENT decl_end = D3DDECL_END();
|
||||||
static const D3DVERTEXELEMENT position_decl = DECL_FVF_POSITION(0);
|
|
||||||
static const D3DVERTEXELEMENT tex_coord0 = DECL_FVF_TEXCOORD(1, 3, 0);
|
static const D3DVERTEXELEMENT tex_coord0 = DECL_FVF_TEXCOORD(1, 3, 0);
|
||||||
static const D3DVERTEXELEMENT tex_coord1 = DECL_FVF_TEXCOORD(2, 5, 1);
|
static const D3DVERTEXELEMENT tex_coord1 = DECL_FVF_TEXCOORD(2, 5, 1);
|
||||||
static const D3DVERTEXELEMENT color = DECL_FVF_COLOR(3, 7, 0);
|
|
||||||
D3DVERTEXELEMENT decl[MAXD3DDECLLENGTH] = {{0}};
|
D3DVERTEXELEMENT decl[MAXD3DDECLLENGTH] = {{0}};
|
||||||
|
|
||||||
if (cgD3D9GetVertexDeclaration(pass->vPrg, decl) == CG_FALSE)
|
if (cgD3D9GetVertexDeclaration(pass->vPrg, decl) == CG_FALSE)
|
||||||
|
@ -319,10 +311,16 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
stream_taken[0] = true;
|
stream_taken[0] = true;
|
||||||
RARCH_LOG("[FVF]: POSITION semantic found.\n");
|
|
||||||
index = cgGetParameterResourceIndex(param);
|
index = cgGetParameterResourceIndex(param);
|
||||||
decl[index] = position_decl;
|
|
||||||
indices[index] = true;
|
indices[index] = true;
|
||||||
|
decl[index] = (D3DVERTEXELEMENT) {
|
||||||
|
0, 0,
|
||||||
|
D3DDECLTYPE_FLOAT3,
|
||||||
|
D3DDECLMETHOD_DEFAULT,
|
||||||
|
D3DDECLUSAGE_POSITION, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
RARCH_LOG("[FVF]: POSITION semantic found.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
param = d3d9_cg_find_param_from_semantic(cgGetFirstParameter(pass->vPrg, CG_PROGRAM), "TEXCOORD");
|
param = d3d9_cg_find_param_from_semantic(cgGetFirstParameter(pass->vPrg, CG_PROGRAM), "TEXCOORD");
|
||||||
|
@ -333,10 +331,11 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||||
{
|
{
|
||||||
stream_taken[1] = true;
|
stream_taken[1] = true;
|
||||||
texcoord0_taken = true;
|
texcoord0_taken = true;
|
||||||
RARCH_LOG("[FVF]: TEXCOORD0 semantic found.\n");
|
|
||||||
index = cgGetParameterResourceIndex(param);
|
index = cgGetParameterResourceIndex(param);
|
||||||
decl[index] = tex_coord0;
|
decl[index] = tex_coord0;
|
||||||
indices[index] = true;
|
indices[index] = true;
|
||||||
|
|
||||||
|
RARCH_LOG("[FVF]: TEXCOORD0 semantic found.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
param = d3d9_cg_find_param_from_semantic(cgGetFirstParameter(pass->vPrg, CG_PROGRAM), "TEXCOORD1");
|
param = d3d9_cg_find_param_from_semantic(cgGetFirstParameter(pass->vPrg, CG_PROGRAM), "TEXCOORD1");
|
||||||
|
@ -344,10 +343,11 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||||
{
|
{
|
||||||
stream_taken[2] = true;
|
stream_taken[2] = true;
|
||||||
texcoord1_taken = true;
|
texcoord1_taken = true;
|
||||||
RARCH_LOG("[FVF]: TEXCOORD1 semantic found.\n");
|
|
||||||
index = cgGetParameterResourceIndex(param);
|
index = cgGetParameterResourceIndex(param);
|
||||||
decl[index] = tex_coord1;
|
decl[index] = tex_coord1;
|
||||||
indices[index] = true;
|
indices[index] = true;
|
||||||
|
|
||||||
|
RARCH_LOG("[FVF]: TEXCOORD1 semantic found.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
param = d3d9_cg_find_param_from_semantic(cgGetFirstParameter(pass->vPrg, CG_PROGRAM), "COLOR");
|
param = d3d9_cg_find_param_from_semantic(cgGetFirstParameter(pass->vPrg, CG_PROGRAM), "COLOR");
|
||||||
|
@ -357,14 +357,24 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||||
if (param)
|
if (param)
|
||||||
{
|
{
|
||||||
stream_taken[3] = true;
|
stream_taken[3] = true;
|
||||||
RARCH_LOG("[FVF]: COLOR0 semantic found.\n");
|
|
||||||
index = cgGetParameterResourceIndex(param);
|
index = cgGetParameterResourceIndex(param);
|
||||||
decl[index] = color;
|
|
||||||
indices[index] = true;
|
indices[index] = true;
|
||||||
|
decl[index] = (D3DVERTEXELEMENT) {
|
||||||
|
3, sizeof(float) * 7,
|
||||||
|
D3DDECLTYPE_FLOAT4,
|
||||||
|
D3DDECLMETHOD_DEFAULT,
|
||||||
|
D3DDECLUSAGE_COLOR, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
RARCH_LOG("[FVF]: COLOR0 semantic found.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stream {0, 1, 2, 3} might be already taken. Find first vacant stream. */
|
/* Stream {0, 1, 2, 3} might be already taken. Find first vacant stream. */
|
||||||
for (index = 0; index < 4 && stream_taken[index]; index++);
|
for (index = 0; index < 4; index++)
|
||||||
|
{
|
||||||
|
if (stream_taken[index] == false)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* Find first vacant texcoord declaration. */
|
/* Find first vacant texcoord declaration. */
|
||||||
if (texcoord0_taken && texcoord1_taken)
|
if (texcoord0_taken && texcoord1_taken)
|
||||||
|
@ -380,21 +390,24 @@ static bool cg_d3d9_renderchain_init_shader_fvf(void *data, void *pass_data)
|
||||||
pass->attrib_map.push_back(0);
|
pass->attrib_map.push_back(0);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
D3DVERTEXELEMENT elem = DECL_FVF_TEXCOORD(index, 3, tex_index);
|
|
||||||
|
|
||||||
pass->attrib_map.push_back(index);
|
pass->attrib_map.push_back(index);
|
||||||
|
|
||||||
decl[i] = elem;
|
decl[i] = (D3DVERTEXELEMENT)
|
||||||
|
{
|
||||||
|
index, sizeof(float) * 3,
|
||||||
|
D3DDECLTYPE_FLOAT2,
|
||||||
|
D3DDECLMETHOD_DEFAULT,
|
||||||
|
D3DDECLUSAGE_TEXCOORD, tex_index
|
||||||
|
};
|
||||||
|
|
||||||
/* Find next vacant stream. */
|
/* Find next vacant stream. */
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
while (index < 4 && stream_taken[index])
|
while ((++index < 4) && stream_taken[index])
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
/* Find next vacant texcoord declaration. */
|
/* Find next vacant texcoord declaration. */
|
||||||
tex_index++;
|
if ((++tex_index == 1) && texcoord1_taken)
|
||||||
if (tex_index == 1 && texcoord1_taken)
|
|
||||||
tex_index++;
|
tex_index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue