diff --git a/360/media/shaders/stock.cg b/360/media/shaders/stock.cg index 23f8077e2e..9c7b378e64 100644 --- a/360/media/shaders/stock.cg +++ b/360/media/shaders/stock.cg @@ -1,40 +1,40 @@ -sampler2D decal : register(s0); -float4x4 modelViewProj : register(c0); - -struct FP_IN +/* +VERTEX_SHADER +*/ +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 -{ - float4 oPosition : POSITION; - float2 otexCoord : TEXCOORD0; -}; - -struct FP_OUT +/* +FRAGMENT SHADER +*/ +struct output { float4 color : COLOR; }; -FP_OUT main_fragment(FP_IN input) : COLOR +struct input { - FP_OUT output; - output.color = tex2D(decal, input.texCoord); - return output; -} - -VP_OUT main_vertex(VP_IN input) -{ - VP_OUT output; - output.oPosition = mul(modelViewProj, float4(input.position, 0.0, 1.0)); - output.otexCoord = input.texCoord; - return output; + float2 video_size; + float2 texture_size; + float2 output_size; +}; + + +output main_fragment(float2 texCoord : TEXCOORD0, uniform sampler2D decal : register(s0), uniform input IN) : COLOR +{ + output OUT; + OUT.color = tex2D(decal, texCoord); + return OUT; } diff --git a/360/xdk360_video.cpp b/360/xdk360_video.cpp index 197188e0f6..2851a19601 100644 --- a/360/xdk360_video.cpp +++ b/360/xdk360_video.cpp @@ -34,6 +34,17 @@ static bool g_first_msg; unsigned g_frame_count; 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) { if (g_d3d) @@ -141,7 +152,7 @@ void xdk360_set_orientation(uint32_t orientation) angle = M_PI * 90 / 180; break; } - vid->modelViewProj = XMMatrixRotationZ(angle); + hlsl_program.modelViewProj = XMMatrixRotationZ(angle); } 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* pErrorMsg = NULL; - HRESULT hr = D3DXCompileShaderFromFile( + ret = D3DXCompileShaderFromFile( g_settings.video.cg_shader_path, //filepath NULL, //macros NULL, //includes @@ -263,10 +274,10 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i &pErrorMsg, // errors &vid->constantTable); // constants - if (SUCCEEDED(hr)) + if (SUCCEEDED(ret)) { 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 NULL, //macros NULL, //includes @@ -278,9 +289,10 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i 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); Direct3D_Release(); 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; D3DDevice_SetViewport(vid->xdk360_render_device, &vp); - vid->modelViewProj = XMMatrixIdentity(); + hlsl_program.modelViewProj = XMMatrixIdentity(); return vid; } @@ -382,7 +394,7 @@ static bool xdk360_gfx_frame(void *data, const void *frame, 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); diff --git a/360/xdk360_video.h b/360/xdk360_video.h index bce415757c..0472c073a4 100644 --- a/360/xdk360_video.h +++ b/360/xdk360_video.h @@ -56,7 +56,6 @@ typedef struct xdk360_video LPD3DXCONSTANTTABLE constantTable; D3DPRESENT_PARAMETERS d3dpp; XVIDEO_MODE video_mode; - XMMATRIX modelViewProj; } xdk360_video_t; enum