(360) Uses runtime shader compiler - loads stock shader from

file now
This commit is contained in:
TwinAphex51224 2012-03-09 21:50:12 +01:00
parent 6b552cfba1
commit 31be6766c6
4 changed files with 86 additions and 44 deletions

View File

@ -0,0 +1,32 @@
sampler2D tex : register(s0);
struct PS_IN
{
float2 coord : TEXCOORD0;
};
struct VS_IN
{
float2 pos : POSITION;
float2 coord : TEXCOORD0;
};
struct VS_OUT
{
float4 pos : POSITION;
float2 coord : TEXCOORD0;
};
float4 main_fragment(PS_IN input) : COLOR
{
return tex2D(tex, input.coord);
}
VS_OUT main_vertex(VS_IN input)
{
VS_OUT output;
output.pos = float4(input.pos, 0.0, 1.0);
output.coord = input.coord;
return output;
}

View File

@ -29,40 +29,6 @@
#include "config.h"
#endif
static const char* g_strPixelShaderProgram =
" sampler2D tex : register(s0); "
" struct PS_IN "
" { "
" float2 coord : TEXCOORD0; "
" }; "
" "
" float4 main(PS_IN input) : COLOR "
" { "
" return tex2D(tex, input.coord); "
" } ";
static const char* g_strVertexShaderProgram =
" struct VS_IN "
" "
" { "
" float2 pos : POSITION; "
" float2 coord : TEXCOORD0; "
" }; "
" "
" struct VS_OUT "
" { "
" float4 pos : POSITION; "
" float2 coord : TEXCOORD0; "
" }; "
" "
" VS_OUT main(VS_IN input) "
" { "
" VS_OUT output; "
" output.pos = float4(input.pos, 0.0, 1.0); "
" output.coord = input.coord; "
" return output; "
" } ";
static bool g_quitting;
static bool g_first_msg;
unsigned g_frame_count;
@ -263,13 +229,30 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
ID3DXBuffer* pShaderCodeP = NULL;
ID3DXBuffer* pErrorMsg = NULL;
HRESULT hr = D3DXCompileShader(g_strVertexShaderProgram, (UINT)strlen(g_strVertexShaderProgram),
NULL, NULL, "main", "vs_2_0", 0, &pShaderCodeV, &pErrorMsg, NULL);
HRESULT hr = D3DXCompileShaderFromFile(
"game:\\media\\shaders\\stock.cg", //filepath
NULL, //macros
NULL, //includes
"main_vertex", // main function
"vs_2_0", // shader profile
0, // flags
&pShaderCodeV, // compiled operations
&pErrorMsg, // errors
NULL); // constants
if (SUCCEEDED(hr))
{
hr = D3DXCompileShader(g_strPixelShaderProgram, (UINT)strlen(g_strPixelShaderProgram),
NULL, NULL, "main", "ps_2_0", 0, &pShaderCodeP, &pErrorMsg, NULL);
SSNES_LOG("Vertex shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
HRESULT hr = D3DXCompileShaderFromFile(
"game:\\media\\shaders\\stock.cg", //filepath
NULL, //macros
NULL, //includes
"main_fragment", // main function
"ps_2_0", // shader profile
0, // flags
&pShaderCodeP, // compiled operations
&pErrorMsg, // errors
NULL); // constants
}
if (FAILED(hr))
@ -280,6 +263,10 @@ static void *xdk360_gfx_init(const video_info_t *video, const input_driver_t **i
free(vid);
return NULL;
}
else
{
SSNES_LOG("Pixel shader program from [%s] successfully compiled.\n", "game:\\media\\shaders\\stock.cg");
}
vid->pVertexShader = D3DDevice_CreateVertexShader((const DWORD*)pShaderCodeV->GetBufferPointer());
vid->pPixelShader = D3DDevice_CreatePixelShader((const DWORD*)pShaderCodeP->GetBufferPointer());

View File

@ -122,7 +122,7 @@
</Link>
<Deploy>
<DeploymentType>CopyToHardDrive</DeploymentType>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg</DeploymentFiles>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg;$(RemoteRoot)\media\shaders=$(OutDir)media\shaders</DeploymentFiles>
<ForceCopy>true</ForceCopy>
</Deploy>
<ImageXex>
@ -158,7 +158,7 @@
<AdditionalDependencies>xapilibd.lib;d3d9d.lib;d3dx9d.lib;xgraphicsd.lib;xboxkrnl.lib;xnetd.lib;xaudiod2.lib;xactd3.lib;x3daudiod.lib;xmcored.lib;xbdm.lib;vcompd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Deploy>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg</DeploymentFiles>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg;$(RemoteRoot)\media\shaders=$(OutDir)media\shaders</DeploymentFiles>
<ForceCopy>true</ForceCopy>
<DeploymentType>CopyToHardDrive</DeploymentType>
</Deploy>
@ -200,7 +200,7 @@
<AdditionalDependencies>xapilibi.lib;d3d9i.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3i.lib;x3daudioi.lib;xmcorei.lib;xbdm.lib;vcomp.lib;$(TargetDir)libsnes.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Deploy>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg</DeploymentFiles>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg;$(RemoteRoot)\media\shaders=$(OutDir)media\shaders</DeploymentFiles>
<ForceCopy>true</ForceCopy>
<DeploymentType>CopyToHardDrive</DeploymentType>
</Deploy>
@ -241,7 +241,7 @@
<AdditionalDependencies>xapilib.lib;d3d9.lib;d3dx9.lib;xgraphics.lib;xboxkrnl.lib;xnet.lib;xaudio2.lib;xact3.lib;x3daudio.lib;xmcore.lib;vcomp.lib;xbdm.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<Deploy>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg</DeploymentFiles>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg;$(RemoteRoot)\media\shaders=$(OutDir)media\shaders</DeploymentFiles>
<ForceCopy>true</ForceCopy>
<DeploymentType>CopyToHardDrive</DeploymentType>
</Deploy>
@ -282,7 +282,7 @@
</Link>
<Deploy>
<DeploymentType>CopyToHardDrive</DeploymentType>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg</DeploymentFiles>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg;$(RemoteRoot)\media\shaders=$(OutDir)media\shaders</DeploymentFiles>
<ForceCopy>true</ForceCopy>
</Deploy>
<ImageXex>
@ -324,7 +324,7 @@
<ForceCopy>true</ForceCopy>
</Deploy>
<Deploy>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg</DeploymentFiles>
<DeploymentFiles>$(RemoteRoot)=$(ImagePath);$(RemoteRoot)\media=$(OutDir)media;$(RemoteRoot)=$(OutDir)cfg;$(RemoteRoot)\media\shaders=$(OutDir)media\shaders</DeploymentFiles>
<DeploymentType>CopyToHardDrive</DeploymentType>
</Deploy>
<ImageXex>
@ -601,6 +601,23 @@
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">$(OutDir)media\ssnes_libsnescore_browser.xur;</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\360\media\shaders\stock.cg">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">copy %(FullPath) $(OutDir)media\shaders\stock.cg</Command>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Xbox 360'">$(OutDir)media\shaders\stock.cg;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">$(OutDir)media\shaders\stock.cg;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">$(OutDir)media\shaders\stock.cg;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">$(OutDir)media\shaders\stock.cg;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">$(OutDir)media\shaders\stock.cg;%(Outputs)</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">$(OutDir)media\shaders\stock.cg;%(Outputs)</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='CodeAnalysis|Xbox 360'">copy %(FullPath) $(OutDir)media\shaders\stock.cg</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug|Xbox 360'">copy %(FullPath) $(OutDir)media\shaders\stock.cg</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile|Xbox 360'">copy %(FullPath) $(OutDir)media\shaders\stock.cg</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Profile_FastCap|Xbox 360'">copy %(FullPath) $(OutDir)media\shaders\stock.cg</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release_LTCG|Xbox 360'">copy %(FullPath) $(OutDir)media\shaders\stock.cg</Command>
</CustomBuild>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>

View File

@ -39,6 +39,9 @@
<Filter Include="Source Files\input">
<UniqueIdentifier>{b19dc1de-69d4-4501-87ef-b8ee4a7795c5}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\media\shader">
<UniqueIdentifier>{3a05047b-b9ec-4821-bb28-d1b0e9e3e8bb}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\360\xdk360_video.cpp">
@ -273,5 +276,8 @@
<CustomBuild Include="..\..\360\media\ssnes_libsnescore_browser.xui">
<Filter>Source Files\media</Filter>
</CustomBuild>
<CustomBuild Include="..\..\360\media\shaders\stock.cg">
<Filter>Source Files\media\shader</Filter>
</CustomBuild>
</ItemGroup>
</Project>