WinRT: added texture channel color-modulation support for D3D 11.1
--HG-- rename : src/render/direct3d11/SDL_D3D11_PixelShader_TextureCopy.hlsl => src/render/direct3d11/SDL_D3D11_PixelShader_TextureColored.hlsl
This commit is contained in:
parent
b1b2ba3f09
commit
b74856f7b7
6 changed files with 44 additions and 20 deletions
|
@ -382,7 +382,7 @@
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Pixel</ShaderType>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureCopy.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
|
|
|
@ -592,14 +592,14 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureCopy.hlsl">
|
|
||||||
<Filter>GPU Shaders</Filter>
|
|
||||||
</FxCompile>
|
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
|
||||||
<Filter>GPU Shaders</Filter>
|
<Filter>GPU Shaders</Filter>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
|
||||||
<Filter>GPU Shaders</Filter>
|
<Filter>GPU Shaders</Filter>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
|
||||||
|
<Filter>GPU Shaders</Filter>
|
||||||
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -293,7 +293,7 @@
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0_level_9_1</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0_level_9_1</ShaderModel>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0_level_9_1</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0_level_9_1</ShaderModel>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureCopy.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">Pixel</ShaderType>
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Pixel</ShaderType>
|
||||||
|
@ -304,8 +304,6 @@
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">4.0_level_9_1</ShaderModel>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">4.0_level_9_1</ShaderModel>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
|
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">4.0_level_9_1</ShaderModel>
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">4.0_level_9_1</ShaderModel>
|
|
||||||
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">4.0_level_9_1</ShaderModel>
|
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
|
||||||
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Vertex</ShaderType>
|
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">Vertex</ShaderType>
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureCopy.hlsl">
|
|
||||||
<Filter>GPU Shaders</Filter>
|
|
||||||
</FxCompile>
|
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_FixedColor.hlsl">
|
||||||
<Filter>GPU Shaders</Filter>
|
<Filter>GPU Shaders</Filter>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_VertexShader_Default.hlsl">
|
||||||
<Filter>GPU Shaders</Filter>
|
<Filter>GPU Shaders</Filter>
|
||||||
</FxCompile>
|
</FxCompile>
|
||||||
|
<FxCompile Include="..\..\src\render\direct3d11\SDL_D3D11_PixelShader_TextureColored.hlsl">
|
||||||
|
<Filter>GPU Shaders</Filter>
|
||||||
|
</FxCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\src\SDL.c">
|
<ClCompile Include="..\..\src\SDL.c">
|
||||||
|
|
|
@ -10,5 +10,5 @@ struct PixelShaderInput
|
||||||
|
|
||||||
float4 main(PixelShaderInput input) : SV_TARGET
|
float4 main(PixelShaderInput input) : SV_TARGET
|
||||||
{
|
{
|
||||||
return theTexture.Sample(theSampler, input.tex);
|
return theTexture.Sample(theSampler, input.tex) * input.color;
|
||||||
}
|
}
|
|
@ -436,7 +436,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
|
||||||
//
|
//
|
||||||
// Load in SDL's pixel shaders
|
// Load in SDL's pixel shaders
|
||||||
//
|
//
|
||||||
result = D3D11_LoadPixelShader(renderer, L"SDL_D3D11_PixelShader_TextureCopy.cso", &data->texturePixelShader);
|
result = D3D11_LoadPixelShader(renderer, L"SDL_D3D11_PixelShader_TextureColored.cso", &data->texturePixelShader);
|
||||||
if (FAILED(result)) {
|
if (FAILED(result)) {
|
||||||
// D3D11_LoadPixelShader will have aleady set the SDL error
|
// D3D11_LoadPixelShader will have aleady set the SDL error
|
||||||
return result;
|
return result;
|
||||||
|
@ -1461,11 +1461,24 @@ D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
float minv = (float) srcrect->y / texture->h;
|
float minv = (float) srcrect->y / texture->h;
|
||||||
float maxv = (float) (srcrect->y + srcrect->h) / texture->h;
|
float maxv = (float) (srcrect->y + srcrect->h) / texture->h;
|
||||||
|
|
||||||
|
float r = 1.0f;
|
||||||
|
float g = 1.0f;
|
||||||
|
float b = 1.0f;
|
||||||
|
float a = 1.0f;
|
||||||
|
if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
|
||||||
|
r = (float)(texture->r / 255.0f);
|
||||||
|
g = (float)(texture->g / 255.0f);
|
||||||
|
b = (float)(texture->b / 255.0f);
|
||||||
|
}
|
||||||
|
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
|
||||||
|
a = (float)(texture->a / 255.0f);
|
||||||
|
}
|
||||||
|
|
||||||
VertexPositionColor vertices[] = {
|
VertexPositionColor vertices[] = {
|
||||||
{XMFLOAT3(dstrect->x, dstrect->y, 0.0f), XMFLOAT2(minu, minv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(dstrect->x, dstrect->y, 0.0f), XMFLOAT2(minu, minv), XMFLOAT4(r, g, b, a)},
|
||||||
{XMFLOAT3(dstrect->x, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(minu, maxv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(dstrect->x, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(minu, maxv), XMFLOAT4(r, g, b, a)},
|
||||||
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y, 0.0f), XMFLOAT2(maxu, minv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y, 0.0f), XMFLOAT2(maxu, minv), XMFLOAT4(r, g, b, a)},
|
||||||
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(maxu, maxv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(dstrect->x + dstrect->w, dstrect->y + dstrect->h, 0.0f), XMFLOAT2(maxu, maxv), XMFLOAT4(r, g, b, a)},
|
||||||
};
|
};
|
||||||
if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
|
if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1498,6 +1511,19 @@ D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
float minv = (float) srcrect->y / texture->h;
|
float minv = (float) srcrect->y / texture->h;
|
||||||
float maxv = (float) (srcrect->y + srcrect->h) / texture->h;
|
float maxv = (float) (srcrect->y + srcrect->h) / texture->h;
|
||||||
|
|
||||||
|
float r = 1.0f;
|
||||||
|
float g = 1.0f;
|
||||||
|
float b = 1.0f;
|
||||||
|
float a = 1.0f;
|
||||||
|
if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) {
|
||||||
|
r = (float)(texture->r / 255.0f);
|
||||||
|
g = (float)(texture->g / 255.0f);
|
||||||
|
b = (float)(texture->b / 255.0f);
|
||||||
|
}
|
||||||
|
if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) {
|
||||||
|
a = (float)(texture->a / 255.0f);
|
||||||
|
}
|
||||||
|
|
||||||
if (flip & SDL_FLIP_HORIZONTAL) {
|
if (flip & SDL_FLIP_HORIZONTAL) {
|
||||||
float tmp = maxu;
|
float tmp = maxu;
|
||||||
maxu = minu;
|
maxu = minu;
|
||||||
|
@ -1523,10 +1549,10 @@ D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
|
||||||
const float maxy = dstrect->h - center->y;
|
const float maxy = dstrect->h - center->y;
|
||||||
|
|
||||||
VertexPositionColor vertices[] = {
|
VertexPositionColor vertices[] = {
|
||||||
{XMFLOAT3(minx, miny, 0.0f), XMFLOAT2(minu, minv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(minx, miny, 0.0f), XMFLOAT2(minu, minv), XMFLOAT4(r, g, b, a)},
|
||||||
{XMFLOAT3(minx, maxy, 0.0f), XMFLOAT2(minu, maxv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(minx, maxy, 0.0f), XMFLOAT2(minu, maxv), XMFLOAT4(r, g, b, a)},
|
||||||
{XMFLOAT3(maxx, miny, 0.0f), XMFLOAT2(maxu, minv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(maxx, miny, 0.0f), XMFLOAT2(maxu, minv), XMFLOAT4(r, g, b, a)},
|
||||||
{XMFLOAT3(maxx, maxy, 0.0f), XMFLOAT2(maxu, maxv), XMFLOAT4(1.0f, 1.0f, 1.0f, 1.0f)},
|
{XMFLOAT3(maxx, maxy, 0.0f), XMFLOAT2(maxu, maxv), XMFLOAT4(r, g, b, a)},
|
||||||
};
|
};
|
||||||
if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
|
if (D3D11_UpdateVertexBuffer(renderer, vertices, sizeof(vertices)) != 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue