mirror of
https://github.com/libretro/RetroArch
synced 2025-02-23 06:41:04 +00:00
(360) Stock Cg/HLSL shaders should be now almost the same - only
mall 1/2-line ifdefs should be needed
This commit is contained in:
parent
8a6b628bee
commit
5cad1e4c39
@ -1,40 +1,40 @@
|
|||||||
sampler2D decal : register(s0);
|
/*
|
||||||
float4x4 modelViewProj : register(c0);
|
VERTEX_SHADER
|
||||||
|
*/
|
||||||
struct FP_IN
|
void main_vertex
|
||||||
|
(
|
||||||
|
float2 position : POSITION,
|
||||||
|
float2 texCoord : TEXCOORD0,
|
||||||
|
uniform float4x4 modelViewProj : register(c0),
|
||||||
|
out float4 oPosition : POSITION,
|
||||||
|
out float2 otexCoord : TEXCOORD
|
||||||
|
)
|
||||||
{
|
{
|
||||||
float2 texCoord : TEXCOORD0;
|
oPosition = mul(modelViewProj, float4(position, 0.0, 1.0));
|
||||||
};
|
otexCoord = texCoord;
|
||||||
|
}
|
||||||
|
|
||||||
struct VP_IN
|
|
||||||
{
|
|
||||||
float2 position : POSITION;
|
|
||||||
float2 texCoord : TEXCOORD0;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct VP_OUT
|
/*
|
||||||
{
|
FRAGMENT SHADER
|
||||||
float4 oPosition : POSITION;
|
*/
|
||||||
float2 otexCoord : TEXCOORD0;
|
struct output
|
||||||
};
|
|
||||||
|
|
||||||
struct FP_OUT
|
|
||||||
{
|
{
|
||||||
float4 color : COLOR;
|
float4 color : COLOR;
|
||||||
};
|
};
|
||||||
|
|
||||||
FP_OUT main_fragment(FP_IN input) : COLOR
|
struct input
|
||||||
{
|
{
|
||||||
FP_OUT output;
|
float2 video_size;
|
||||||
output.color = tex2D(decal, input.texCoord);
|
float2 texture_size;
|
||||||
return output;
|
float2 output_size;
|
||||||
}
|
};
|
||||||
|
|
||||||
VP_OUT main_vertex(VP_IN input)
|
|
||||||
{
|
output main_fragment(float2 texCoord : TEXCOORD0, uniform sampler2D decal : register(s0), uniform input IN) : COLOR
|
||||||
VP_OUT output;
|
{
|
||||||
output.oPosition = mul(modelViewProj, float4(input.position, 0.0, 1.0));
|
output OUT;
|
||||||
output.otexCoord = input.texCoord;
|
OUT.color = tex2D(decal, texCoord);
|
||||||
return output;
|
return OUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,17 @@ static bool g_first_msg;
|
|||||||
unsigned g_frame_count;
|
unsigned g_frame_count;
|
||||||
void *g_d3d;
|
void *g_d3d;
|
||||||
|
|
||||||
|
struct hlsl_program_t
|
||||||
|
{
|
||||||
|
D3DXHANDLE vid_size_f;
|
||||||
|
D3DXHANDLE tex_size_f;
|
||||||
|
D3DXHANDLE out_size_f;
|
||||||
|
D3DXHANDLE vid_size_v;
|
||||||
|
D3DXHANDLE tex_size_v;
|
||||||
|
D3DXHANDLE out_size_v;
|
||||||
|
XMMATRIX modelViewProj;
|
||||||
|
} hlsl_program;
|
||||||
|
|
||||||
static void xdk360_gfx_free(void * data)
|
static void xdk360_gfx_free(void * data)
|
||||||
{
|
{
|
||||||
if (g_d3d)
|
if (g_d3d)
|
||||||
@ -141,7 +152,7 @@ void xdk360_set_orientation(uint32_t orientation)
|
|||||||
angle = M_PI * 90 / 180;
|
angle = M_PI * 90 / 180;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vid->modelViewProj = XMMatrixRotationZ(angle);
|
hlsl_program.modelViewProj = XMMatrixRotationZ(angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xdk360_set_aspect_ratio(uint32_t aspectratio_index)
|
void xdk360_set_aspect_ratio(uint32_t aspectratio_index)
|
||||||
@ -252,7 +263,7 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
|
|||||||
ID3DXBuffer* pShaderCodeP = NULL;
|
ID3DXBuffer* pShaderCodeP = NULL;
|
||||||
ID3DXBuffer* pErrorMsg = NULL;
|
ID3DXBuffer* pErrorMsg = NULL;
|
||||||
|
|
||||||
HRESULT hr = D3DXCompileShaderFromFile(
|
ret = D3DXCompileShaderFromFile(
|
||||||
g_settings.video.cg_shader_path, //filepath
|
g_settings.video.cg_shader_path, //filepath
|
||||||
NULL, //macros
|
NULL, //macros
|
||||||
NULL, //includes
|
NULL, //includes
|
||||||
@ -263,10 +274,10 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
|
|||||||
&pErrorMsg, // errors
|
&pErrorMsg, // errors
|
||||||
&vid->constantTable); // constants
|
&vid->constantTable); // constants
|
||||||
|
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(ret))
|
||||||
{
|
{
|
||||||
SSNES_LOG("Vertex shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
|
SSNES_LOG("Vertex shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
|
||||||
HRESULT hr = D3DXCompileShaderFromFile(
|
ret = D3DXCompileShaderFromFile(
|
||||||
g_settings.video.cg_shader_path, //filepath
|
g_settings.video.cg_shader_path, //filepath
|
||||||
NULL, //macros
|
NULL, //macros
|
||||||
NULL, //includes
|
NULL, //includes
|
||||||
@ -278,9 +289,10 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
|
|||||||
NULL); // constants
|
NULL); // constants
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(ret))
|
||||||
{
|
{
|
||||||
OutputDebugString(pErrorMsg ? (char*)pErrorMsg->GetBufferPointer() : "");
|
if(pErrorMsg)
|
||||||
|
SSNES_LOG("%s\n", (char*)pErrorMsg->GetBufferPointer());
|
||||||
D3DDevice_Release(vid->xdk360_render_device);
|
D3DDevice_Release(vid->xdk360_render_device);
|
||||||
Direct3D_Release();
|
Direct3D_Release();
|
||||||
free(vid);
|
free(vid);
|
||||||
@ -342,7 +354,7 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
|
|||||||
vp.MaxZ = 1.0f;
|
vp.MaxZ = 1.0f;
|
||||||
D3DDevice_SetViewport(vid->xdk360_render_device, &vp);
|
D3DDevice_SetViewport(vid->xdk360_render_device, &vp);
|
||||||
|
|
||||||
vid->modelViewProj = XMMatrixIdentity();
|
hlsl_program.modelViewProj = XMMatrixIdentity();
|
||||||
|
|
||||||
return vid;
|
return vid;
|
||||||
}
|
}
|
||||||
@ -382,7 +394,7 @@ static bool xdk360_gfx_frame(void *data, const void *frame,
|
|||||||
vid->last_height = height;
|
vid->last_height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
vid->xdk360_render_device->SetVertexShaderConstantF(0, (FLOAT*)&vid->modelViewProj, 4);
|
vid->xdk360_render_device->SetVertexShaderConstantF(0, (FLOAT*)&hlsl_program.modelViewProj, 4);
|
||||||
|
|
||||||
vid->constantTable->SetDefaults(vid->xdk360_render_device);
|
vid->constantTable->SetDefaults(vid->xdk360_render_device);
|
||||||
|
|
||||||
|
@ -56,7 +56,6 @@ typedef struct xdk360_video
|
|||||||
LPD3DXCONSTANTTABLE constantTable;
|
LPD3DXCONSTANTTABLE constantTable;
|
||||||
D3DPRESENT_PARAMETERS d3dpp;
|
D3DPRESENT_PARAMETERS d3dpp;
|
||||||
XVIDEO_MODE video_mode;
|
XVIDEO_MODE video_mode;
|
||||||
XMMATRIX modelViewProj;
|
|
||||||
} xdk360_video_t;
|
} xdk360_video_t;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
Loading…
x
Reference in New Issue
Block a user