fix: 修复 DX FL 10 的硬件上编译着色器依然使用ShaderModel 5.0的问题

This commit is contained in:
Xu Liu 2021-12-01 21:25:15 +08:00
commit 4020cd92b8
14 changed files with 138 additions and 847 deletions

View file

@ -2,11 +2,34 @@
#include "CursorDrawer.h"
#include "App.h"
#include "Utils.h"
#include "shaders/MonochromeCursorPS.h"
#include <VertexTypes.h>
extern std::shared_ptr<spdlog::logger> logger;
constexpr const char* monochromeCursorPS = R"(
Texture2D originTex : register(t0);
Texture2D maskTex : register(t1);
SamplerState sam : register(s0);
float4 main(float4 pos : SV_POSITION, float2 coord : TEXCOORD) : SV_Target{
float2 masks = maskTex.Sample(sam, coord).xy;
if (masks.x > 0.5) {
float3 origin = originTex.Sample(sam, coord).rgb;
if (masks.y > 0.5) {
return float4(1 - origin, 1);
} else {
return float4(origin, 1);
}
} else {
if (masks.y > 0.5) {
return float4(1, 1, 1, 1);
} else {
return float4(0, 0, 0, 1);
}
}
}
)";
bool CursorDrawer::Initialize(ComPtr<ID3D11Texture2D> renderTarget, const RECT& destRect) {
App& app = App::GetInstance();
@ -33,8 +56,14 @@ bool CursorDrawer::Initialize(ComPtr<ID3D11Texture2D> renderTarget, const RECT&
return false;
}
ComPtr<ID3DBlob> blob;
if (!renderer.CompileShader(false, monochromeCursorPS, "main", &blob, "MonochromeCursorPS")) {
SPDLOG_LOGGER_ERROR(logger, "编译 MonochromeCursorPS 失败");
return false;
}
HRESULT hr = renderer.GetD3DDevice()->CreatePixelShader(
MonochromeCursorPSShaderByteCode, sizeof(MonochromeCursorPSShaderByteCode), nullptr, &_monoCursorPS);
blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, &_monoCursorPS);
if (FAILED(hr)) {
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("创建 MonochromeCursorPS 失败", hr));
return false;

View file

@ -6,6 +6,7 @@
#include <charconv>
#include "EffectCache.h"
#include "StrUtils.h"
#include "App.h"
static constexpr const char* META_INDICATOR = "//!";
@ -13,6 +14,38 @@ static constexpr const char* META_INDICATOR = "//!";
extern std::shared_ptr<spdlog::logger> logger;
class PassInclude : public ID3DInclude {
public:
HRESULT CALLBACK Open(
D3D_INCLUDE_TYPE IncludeType,
LPCSTR pFileName,
LPCVOID pParentData,
LPCVOID* ppData,
UINT* pBytes
) override {
std::wstring relativePath = L"effects\\" + StrUtils::UTF8ToUTF16(pFileName);
std::string file;
if (!Utils::ReadTextFile(relativePath.c_str(), file)) {
return E_FAIL;
}
char* result = new char[file.size()];
std::memcpy(result, file.data(), file.size());
*ppData = result;
*pBytes = (UINT)file.size();
return S_OK;
}
HRESULT CALLBACK Close(LPCVOID pData) override {
delete[](char*)pData;
return S_OK;
}
};
static PassInclude passInclude;
UINT RemoveComments(std::string& source) {
// 确保以换行符结尾
@ -729,62 +762,6 @@ UINT ResolveCommon(std::string_view& block) {
return 0;
}
class PassInclude : public ID3DInclude {
public:
HRESULT CALLBACK Open(
D3D_INCLUDE_TYPE IncludeType,
LPCSTR pFileName,
LPCVOID pParentData,
LPCVOID* ppData,
UINT* pBytes
) override {
std::wstring relativePath = L"effects\\" + StrUtils::UTF8ToUTF16(pFileName);
std::string file;
if (!Utils::ReadTextFile(relativePath.c_str(), file)) {
return E_FAIL;
}
char* result = new char[file.size()];
std::memcpy(result, file.data(), file.size());
*ppData = result;
*pBytes = (UINT)file.size();
return S_OK;
}
HRESULT CALLBACK Close(LPCVOID pData) override {
delete[](char*)pData;
return S_OK;
}
};
bool CompilePassPS(std::string_view hlsl, const char* entryPoint, ID3DBlob** blob, UINT passIndex) {
ComPtr<ID3DBlob> errorMsgs = nullptr;
UINT flags = D3DCOMPILE_ENABLE_STRICTNESS;
PassInclude passInclude;
HRESULT hr = D3DCompile(hlsl.data(), hlsl.size(), fmt::format("Pass{}", passIndex).c_str(), nullptr, &passInclude,
entryPoint, "ps_5_0", flags, 0, blob, &errorMsgs);
if (FAILED(hr)) {
if (errorMsgs) {
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg(
fmt::format("编译像素着色器失败:{}", (const char*)errorMsgs->GetBufferPointer()), hr));
}
return false;
} else {
if (errorMsgs) {
// 显示警告消息
SPDLOG_LOGGER_WARN(logger,
"编译像素着色器时产生警告:"s + (const char*)errorMsgs->GetBufferPointer());
}
}
return true;
}
struct TPContext {
ULONG index;
std::vector<std::string>& passSources;
@ -794,8 +771,9 @@ struct TPContext {
void NTAPI TPWork(PTP_CALLBACK_INSTANCE, PVOID Context, PTP_WORK) {
TPContext* con = (TPContext*)Context;
ULONG index = InterlockedIncrement(&con->index);
if (!CompilePassPS(con->passSources[index], "__M", con->passes[index].cso.ReleaseAndGetAddressOf(), index + 1)) {
if (!App::GetInstance().GetRenderer().CompileShader(false, con->passSources[index],
"__M", con->passes[index].cso.ReleaseAndGetAddressOf(), fmt::format("Pass{}", index + 1).c_str(), &passInclude)) {
con->passes[index].cso = nullptr;
}
}
@ -1010,8 +988,10 @@ UINT ResolvePasses(const std::vector<std::string_view>& blocks, const std::vecto
// 编译生成的 hlsl
assert(!passSources.empty());
Renderer& renderer = App::GetInstance().GetRenderer();
if (passSources.size() == 1) {
if (!CompilePassPS(passSources[0], "__M", desc.passes[0].cso.ReleaseAndGetAddressOf(), 1)) {
if (!renderer.CompileShader(false, passSources[0], "__M", desc.passes[0].cso.ReleaseAndGetAddressOf(), "Pass1", &passInclude)) {
SPDLOG_LOGGER_ERROR(logger, "编译 Pass1 失败");
return 1;
}
@ -1030,7 +1010,7 @@ UINT ResolvePasses(const std::vector<std::string_view>& blocks, const std::vecto
SubmitThreadpoolWork(work);
}
CompilePassPS(passSources[0], "__M", desc.passes[0].cso.ReleaseAndGetAddressOf(), 1);
renderer.CompileShader(false, passSources[0], "__M", desc.passes[0].cso.ReleaseAndGetAddressOf(), "Pass1", &passInclude);
WaitForThreadpoolWorkCallbacks(work, FALSE);
CloseThreadpoolWork(work);
@ -1046,7 +1026,7 @@ UINT ResolvePasses(const std::vector<std::string_view>& blocks, const std::vecto
// 回退到单线程
for (size_t i = 0; i < passSources.size(); ++i) {
if (!CompilePassPS(passSources[i], "__M", desc.passes[i].cso.ReleaseAndGetAddressOf(), (UINT)i + 1)) {
if (!renderer.CompileShader(false, passSources[i], "__M", desc.passes[i].cso.ReleaseAndGetAddressOf(), fmt::format("Pass{}", i + 1).c_str(), &passInclude)) {
SPDLOG_LOGGER_ERROR(logger, fmt::format("编译 Pass{} 失败", i + 1));
return 1;
}

View file

@ -3,9 +3,6 @@
#include "App.h"
#include "Utils.h"
#include "StrUtils.h"
#include "shaders/FillVS.h"
#include "shaders/CopyPS.h"
#include "shaders/SimpleVS.h"
#include <VertexTypes.h>
#include "EffectCompiler.h"
#include <rapidjson/document.h>
@ -108,7 +105,15 @@ bool Renderer::GetShaderResourceView(ID3D11Texture2D* texture, ID3D11ShaderResou
bool Renderer::SetFillVS() {
if (!_fillVS) {
HRESULT hr = _d3dDevice->CreateVertexShader(FillVSShaderByteCode, sizeof(FillVSShaderByteCode), nullptr, &_fillVS);
const char* src = "void m(uint i:SV_VERTEXID,out float4 p:SV_POSITION,out float2 c:TEXCOORD){c=float2(i&1,i>>1)*2;p=float4(c.x*2-1,-c.y*2+1,0,1);}";
ComPtr<ID3DBlob> blob;
if (!CompileShader(true, src, "m", &blob, "FillVS")) {
SPDLOG_LOGGER_ERROR(logger, "编译 FillVS 失败");
return false;
}
HRESULT hr = _d3dDevice->CreateVertexShader(blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, &_fillVS);
if (FAILED(hr)) {
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("创建 FillVS 失败", hr));
return false;
@ -125,7 +130,15 @@ bool Renderer::SetFillVS() {
bool Renderer::SetCopyPS(ID3D11SamplerState* sampler, ID3D11ShaderResourceView* input) {
if (!_copyPS) {
HRESULT hr = _d3dDevice->CreatePixelShader(CopyPSShaderByteCode, sizeof(CopyPSShaderByteCode), nullptr, &_copyPS);
const char* src = "Texture2D t:register(t0);SamplerState s:register(s0);float4 m(float4 p:SV_POSITION,float2 c:TEXCOORD):SV_Target{return t.Sample(s,c);}";
ComPtr<ID3DBlob> blob;
if (!CompileShader(false, src, "m", &blob, "CopyPS")) {
SPDLOG_LOGGER_ERROR(logger, "编译 CopyPS 失败");
return false;
}
HRESULT hr = _d3dDevice->CreatePixelShader(blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, &_copyPS);
if (FAILED(hr)) {
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("创建 CopyPS 失败", hr));
return false;
@ -142,7 +155,15 @@ bool Renderer::SetCopyPS(ID3D11SamplerState* sampler, ID3D11ShaderResourceView*
bool Renderer::SetSimpleVS(ID3D11Buffer* simpleVB) {
if (!_simpleVS) {
HRESULT hr = _d3dDevice->CreateVertexShader(SimpleVSShaderByteCode, sizeof(SimpleVSShaderByteCode), nullptr, &_simpleVS);
const char* src = "void m(float4 p:SV_POSITION,float2 c:TEXCOORD,out float4 q:SV_POSITION,out float2 d:TEXCOORD) {q=p;d=c;}";
ComPtr<ID3DBlob> blob;
if (!CompileShader(true, src, "m", &blob, "SimpleVS")) {
SPDLOG_LOGGER_ERROR(logger, "编译 SimpleVS 失败");
return false;
}
HRESULT hr = _d3dDevice->CreateVertexShader(blob->GetBufferPointer(), blob->GetBufferSize(), nullptr, &_simpleVS);
if (FAILED(hr)) {
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg("创建 SimpleVS 失败", hr));
return false;
@ -151,8 +172,8 @@ bool Renderer::SetSimpleVS(ID3D11Buffer* simpleVB) {
hr = _d3dDevice->CreateInputLayout(
VertexPositionTexture::InputElements,
VertexPositionTexture::InputElementCount,
SimpleVSShaderByteCode,
sizeof(SimpleVSShaderByteCode),
blob->GetBufferPointer(),
blob->GetBufferSize(),
&_simpleIL
);
if (FAILED(hr)) {
@ -246,6 +267,40 @@ bool GetGraphicsAdapter(IDXGIFactory1* dxgiFactory, UINT adapterIdx, ComPtr<IDXG
}
}
bool Renderer::CompileShader(bool isVS, std::string_view hlsl, const char* entryPoint,
ID3DBlob** blob, const char* sourceName, ID3DInclude* include
) {
ComPtr<ID3DBlob> errorMsgs = nullptr;
UINT flags = D3DCOMPILE_ENABLE_STRICTNESS;
const char* target;
if (isVS) {
target = _featureLevel >= D3D_FEATURE_LEVEL_11_0 ? "vs_5_0" :
(_featureLevel == D3D_FEATURE_LEVEL_10_1 ? "vs_4_1" : "vs_4_0");
} else {
target = _featureLevel >= D3D_FEATURE_LEVEL_11_0 ? "ps_5_0" :
(_featureLevel == D3D_FEATURE_LEVEL_10_1 ? "ps_4_1" : "ps_4_0");
}
HRESULT hr = D3DCompile(hlsl.data(), hlsl.size(), sourceName, nullptr, include,
entryPoint, target, flags, 0, blob, &errorMsgs);
if (FAILED(hr)) {
if (errorMsgs) {
SPDLOG_LOGGER_ERROR(logger, MakeComErrorMsg(fmt::format("编译{}着色器失败:{}",
isVS ? "顶点" : "像素", (const char*)errorMsgs->GetBufferPointer()), hr));
}
return false;
} else {
if (errorMsgs) {
// 显示警告消息
SPDLOG_LOGGER_WARN(logger, fmt::format("编译{}着色器时产生警告:{}",
isVS ? "顶点" : "像素", (const char*)errorMsgs->GetBufferPointer()));
}
}
return true;
}
bool Renderer::_InitD3D() {
HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(_dxgiFactory.ReleaseAndGetAddressOf()));
if (FAILED(hr)) {

View file

@ -54,6 +54,9 @@ public:
return _featureLevel;
}
bool CompileShader(bool isVS, std::string_view hlsl, const char* entryPoint,
ID3DBlob** blob, const char* sourceName = nullptr, ID3DInclude* include = nullptr);
private:
bool _InitD3D();

View file

@ -211,24 +211,6 @@
<ItemGroup>
<ResourceCompile Include="Runtime.rc" />
</ItemGroup>
<ItemGroup>
<FxCompile Include="shaders\CopyPS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="shaders\FillVS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
<FxCompile Include="shaders\MonochromeCursorPS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Pixel</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Pixel</ShaderType>
</FxCompile>
<FxCompile Include="shaders\SimpleVS.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Vertex</ShaderType>
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Vertex</ShaderType>
</FxCompile>
</ItemGroup>
<ItemGroup>
<Text Include="conanfile.txt" />
</ItemGroup>

View file

@ -141,9 +141,6 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Filter Include="着色器">
<UniqueIdentifier>{0d12cfca-e0f7-451b-b3ce-713fb1202715}</UniqueIdentifier>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{f3740afe-3a7c-49d0-84ea-04d66feace50}</UniqueIdentifier>
</Filter>
@ -162,20 +159,6 @@
<Filter>资源文件</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<FxCompile Include="shaders\CopyPS.hlsl">
<Filter>着色器</Filter>
</FxCompile>
<FxCompile Include="shaders\FillVS.hlsl">
<Filter>着色器</Filter>
</FxCompile>
<FxCompile Include="shaders\SimpleVS.hlsl">
<Filter>着色器</Filter>
</FxCompile>
<FxCompile Include="shaders\MonochromeCursorPS.hlsl">
<Filter>着色器</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<Text Include="conanfile.txt" />
</ItemGroup>

View file

@ -1,150 +0,0 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//
// Resource Bindings:
//
// Name Type Format Dim HLSL Bind Count
// ------------------------------ ---------- ------- ----------- -------------- ------
// sam sampler NA NA s0 1
// tex texture float4 2d t0 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xy 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
sample_indexable(texture2d)(float,float,float,float) o0.xyzw, v1.xyxx, t0.xyzw, s0
ret
// Approximately 2 instruction slots used
#endif
const BYTE CopyPSShaderByteCode[] =
{
68, 88, 66, 67, 198, 220,
227, 181, 164, 108, 250, 31,
86, 241, 35, 11, 196, 218,
106, 22, 1, 0, 0, 0,
136, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
232, 0, 0, 0, 64, 1,
0, 0, 116, 1, 0, 0,
236, 1, 0, 0, 82, 68,
69, 70, 172, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0,
60, 0, 0, 0, 0, 5,
255, 255, 0, 1, 36, 0,
132, 0, 0, 0, 82, 68,
49, 49, 60, 0, 0, 0,
24, 0, 0, 0, 32, 0,
0, 0, 40, 0, 0, 0,
36, 0, 0, 0, 12, 0,
0, 0, 0, 0, 0, 0,
124, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, 0,
0, 0, 128, 0, 0, 0,
2, 0, 0, 0, 5, 0,
0, 0, 4, 0, 0, 0,
255, 255, 255, 255, 0, 0,
0, 0, 1, 0, 0, 0,
13, 0, 0, 0, 115, 97,
109, 0, 116, 101, 120, 0,
77, 105, 99, 114, 111, 115,
111, 102, 116, 32, 40, 82,
41, 32, 72, 76, 83, 76,
32, 83, 104, 97, 100, 101,
114, 32, 67, 111, 109, 112,
105, 108, 101, 114, 32, 49,
48, 46, 49, 0, 73, 83,
71, 78, 80, 0, 0, 0,
2, 0, 0, 0, 8, 0,
0, 0, 56, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 3, 3,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
78, 0, 84, 69, 88, 67,
79, 79, 82, 68, 0, 171,
171, 171, 79, 83, 71, 78,
44, 0, 0, 0, 1, 0,
0, 0, 8, 0, 0, 0,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 84, 97, 114,
103, 101, 116, 0, 171, 171,
83, 72, 69, 88, 112, 0,
0, 0, 80, 0, 0, 0,
28, 0, 0, 0, 106, 8,
0, 1, 90, 0, 0, 3,
0, 96, 16, 0, 0, 0,
0, 0, 88, 24, 0, 4,
0, 112, 16, 0, 0, 0,
0, 0, 85, 85, 0, 0,
98, 16, 0, 3, 50, 16,
16, 0, 1, 0, 0, 0,
101, 0, 0, 3, 242, 32,
16, 0, 0, 0, 0, 0,
69, 0, 0, 139, 194, 0,
0, 128, 67, 85, 21, 0,
242, 32, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0,
1, 0, 0, 0, 70, 126,
16, 0, 0, 0, 0, 0,
0, 96, 16, 0, 0, 0,
0, 0, 62, 0, 0, 1,
83, 84, 65, 84, 148, 0,
0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};

View file

@ -1,6 +0,0 @@
Texture2D tex : register(t0);
SamplerState sam : register(s0);
float4 main(float4 pos : SV_POSITION, float2 coord : TEXCOORD) : SV_Target{
return tex.Sample(sam, coord);
}

View file

@ -1,161 +0,0 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_VERTEXID 0 x 0 VERTID uint x
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// TEXCOORD 0 xy 1 NONE float xy
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_input_sgv v0.x, vertex_id
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
dcl_temps 1
and r0.x, v0.x, l(1)
ushr r0.z, v0.x, l(1)
utof r0.xy, r0.xzxx
mad o0.xy, r0.xyxx, l(4.000000, -4.000000, 0.000000, 0.000000), l(-1.000000, 1.000000, 0.000000, 0.000000)
add o1.xy, r0.xyxx, r0.xyxx
mov o0.zw, l(0,0,0,1.000000)
ret
// Approximately 7 instruction slots used
#endif
const BYTE FillVSShaderByteCode[] =
{
68, 88, 66, 67, 136, 138,
191, 77, 5, 143, 180, 83,
210, 62, 238, 101, 188, 160,
136, 150, 1, 0, 0, 0,
216, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
160, 0, 0, 0, 212, 0,
0, 0, 44, 1, 0, 0,
60, 2, 0, 0, 82, 68,
69, 70, 100, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
60, 0, 0, 0, 0, 5,
254, 255, 0, 1, 36, 0,
60, 0, 0, 0, 82, 68,
49, 49, 60, 0, 0, 0,
24, 0, 0, 0, 32, 0,
0, 0, 40, 0, 0, 0,
36, 0, 0, 0, 12, 0,
0, 0, 0, 0, 0, 0,
77, 105, 99, 114, 111, 115,
111, 102, 116, 32, 40, 82,
41, 32, 72, 76, 83, 76,
32, 83, 104, 97, 100, 101,
114, 32, 67, 111, 109, 112,
105, 108, 101, 114, 32, 49,
48, 46, 49, 0, 73, 83,
71, 78, 44, 0, 0, 0,
1, 0, 0, 0, 8, 0,
0, 0, 32, 0, 0, 0,
0, 0, 0, 0, 6, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 1, 1,
0, 0, 83, 86, 95, 86,
69, 82, 84, 69, 88, 73,
68, 0, 79, 83, 71, 78,
80, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 3, 12, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
84, 69, 88, 67, 79, 79,
82, 68, 0, 171, 171, 171,
83, 72, 69, 88, 8, 1,
0, 0, 80, 0, 1, 0,
66, 0, 0, 0, 106, 8,
0, 1, 96, 0, 0, 4,
18, 16, 16, 0, 0, 0,
0, 0, 6, 0, 0, 0,
103, 0, 0, 4, 242, 32,
16, 0, 0, 0, 0, 0,
1, 0, 0, 0, 101, 0,
0, 3, 50, 32, 16, 0,
1, 0, 0, 0, 104, 0,
0, 2, 1, 0, 0, 0,
1, 0, 0, 7, 18, 0,
16, 0, 0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 0, 0, 0, 0,
0, 0
};

View file

@ -1,4 +0,0 @@
void main(uint id : SV_VERTEXID, out float4 pos : SV_POSITION, out float2 coord : TEXCOORD) {
coord = float2(id & 1, id >> 1) * 2.0;
pos = float4(coord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}

View file

@ -1,250 +0,0 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//
// Resource Bindings:
//
// Name Type Format Dim HLSL Bind Count
// ------------------------------ ---------- ------- ----------- -------------- ------
// sam sampler NA NA s0 1
// originTex texture float4 2d t0 1
// maskTex texture float4 2d t1 1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float
// TEXCOORD 0 xy 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_Target 0 xyzw 0 TARGET float xyzw
//
ps_5_0
dcl_globalFlags refactoringAllowed
dcl_sampler s0, mode_default
dcl_resource_texture2d (float,float,float,float) t0
dcl_resource_texture2d (float,float,float,float) t1
dcl_input_ps linear v1.xy
dcl_output o0.xyzw
dcl_temps 2
sample_indexable(texture2d)(float,float,float,float) r0.xy, v1.xyxx, t1.xyzw, s0
lt r0.x, l(0.500000), r0.x
if_nz r0.x
sample_indexable(texture2d)(float,float,float,float) r0.xzw, v1.xyxx, t0.xwyz, s0
lt r1.x, l(0.500000), r0.y
if_nz r1.x
add o0.xyz, -r0.xzwx, l(1.000000, 1.000000, 1.000000, 0.000000)
mov o0.w, l(1.000000)
ret
else
mov o0.xyz, r0.xzwx
mov o0.w, l(1.000000)
ret
endif
else
lt r0.x, l(0.500000), r0.y
if_nz r0.x
mov o0.xyzw, l(1.000000,1.000000,1.000000,1.000000)
ret
else
mov o0.xyzw, l(0,0,0,1.000000)
ret
endif
endif
ret
// Approximately 25 instruction slots used
#endif
const BYTE MonochromeCursorPSShaderByteCode[] =
{
68, 88, 66, 67, 201, 211,
185, 136, 117, 25, 12, 128,
134, 111, 15, 118, 245, 99,
182, 25, 1, 0, 0, 0,
68, 4, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
24, 1, 0, 0, 112, 1,
0, 0, 164, 1, 0, 0,
168, 3, 0, 0, 82, 68,
69, 70, 220, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
60, 0, 0, 0, 0, 5,
255, 255, 0, 1, 36, 0,
178, 0, 0, 0, 82, 68,
49, 49, 60, 0, 0, 0,
24, 0, 0, 0, 32, 0,
0, 0, 40, 0, 0, 0,
36, 0, 0, 0, 12, 0,
0, 0, 0, 0, 0, 0,
156, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 1, 0,
0, 0, 160, 0, 0, 0,
2, 0, 0, 0, 5, 0,
0, 0, 4, 0, 0, 0,
255, 255, 255, 255, 0, 0,
0, 0, 1, 0, 0, 0,
13, 0, 0, 0, 170, 0,
0, 0, 2, 0, 0, 0,
5, 0, 0, 0, 4, 0,
0, 0, 255, 255, 255, 255,
1, 0, 0, 0, 1, 0,
0, 0, 13, 0, 0, 0,
115, 97, 109, 0, 111, 114,
105, 103, 105, 110, 84, 101,
120, 0, 109, 97, 115, 107,
84, 101, 120, 0, 77, 105,
99, 114, 111, 115, 111, 102,
116, 32, 40, 82, 41, 32,
72, 76, 83, 76, 32, 83,
104, 97, 100, 101, 114, 32,
67, 111, 109, 112, 105, 108,
101, 114, 32, 49, 48, 46,
49, 0, 171, 171, 73, 83,
71, 78, 80, 0, 0, 0,
2, 0, 0, 0, 8, 0,
0, 0, 56, 0, 0, 0,
0, 0, 0, 0, 1, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 15, 0,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 3, 3,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
78, 0, 84, 69, 88, 67,
79, 79, 82, 68, 0, 171,
171, 171, 79, 83, 71, 78,
44, 0, 0, 0, 1, 0,
0, 0, 8, 0, 0, 0,
32, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
83, 86, 95, 84, 97, 114,
103, 101, 116, 0, 171, 171,
83, 72, 69, 88, 252, 1,
0, 0, 80, 0, 0, 0,
127, 0, 0, 0, 106, 8,
0, 1, 90, 0, 0, 3,
0, 96, 16, 0, 0, 0,
0, 0, 88, 24, 0, 4,
0, 112, 16, 0, 0, 0,
0, 0, 85, 85, 0, 0,
88, 24, 0, 4, 0, 112,
16, 0, 1, 0, 0, 0,
85, 85, 0, 0, 98, 16,
0, 3, 50, 16, 16, 0,
1, 0, 0, 0, 101, 0,
0, 3, 242, 32, 16, 0,
0, 0, 0, 0, 104, 0,
0, 2, 2, 0, 0, 0,
69, 0, 0, 139, 194, 0,
0, 128, 67, 85, 21, 0,
50, 0, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0,
1, 0, 0, 0, 70, 126,
16, 0, 1, 0, 0, 0,
0, 96, 16, 0, 0, 0,
0, 0, 49, 0, 0, 7,
18, 0, 16, 0, 0, 0,
0, 0, 1, 64, 0, 0,
0, 0, 0, 63, 10, 0,
16, 0, 0, 0, 0, 0,
31, 0, 4, 3, 10, 0,
16, 0, 0, 0, 0, 0,
69, 0, 0, 139, 194, 0,
0, 128, 67, 85, 21, 0,
210, 0, 16, 0, 0, 0,
0, 0, 70, 16, 16, 0,
1, 0, 0, 0, 198, 121,
16, 0, 0, 0, 0, 0,
0, 96, 16, 0, 0, 0,
0, 0, 49, 0, 0, 7,
18, 0, 16, 0, 1, 0,
0, 0, 1, 64, 0, 0,
0, 0, 0, 63, 26, 0,
16, 0, 0, 0, 0, 0,
31, 0, 4, 3, 10, 0,
16, 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, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0
};

View file

@ -1,23 +0,0 @@
Texture2D originTex : register(t0);
Texture2D maskTex : register(t1);
SamplerState sam : register(s0);
float4 main(float4 pos : SV_POSITION, float2 coord : TEXCOORD) : SV_Target{
float2 masks = maskTex.Sample(sam, coord).xy;
if (masks.x > 0.5) {
float3 origin = originTex.Sample(sam, coord).rgb;
if (masks.y > 0.5) {
return float4(1 - origin, 1);
} else {
return float4(origin, 1);
}
} else {
if (masks.y > 0.5) {
return float4(1, 1, 1, 1);
} else {
return float4(0, 0, 0, 1);
}
}
}

View file

@ -1,138 +0,0 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
//
//
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 NONE float xyzw
// TEXCOORD 0 xy 1 NONE float xy
//
//
// Output signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_POSITION 0 xyzw 0 POS float xyzw
// TEXCOORD 0 xy 1 NONE float xy
//
vs_5_0
dcl_globalFlags refactoringAllowed
dcl_input v0.xyzw
dcl_input v1.xy
dcl_output_siv o0.xyzw, position
dcl_output o1.xy
mov o0.xyzw, v0.xyzw
mov o1.xy, v1.xyxx
ret
// Approximately 3 instruction slots used
#endif
const BYTE SimpleVSShaderByteCode[] =
{
68, 88, 66, 67, 13, 38,
122, 102, 50, 117, 191, 59,
224, 34, 162, 250, 148, 76,
160, 165, 1, 0, 0, 0,
96, 2, 0, 0, 5, 0,
0, 0, 52, 0, 0, 0,
160, 0, 0, 0, 248, 0,
0, 0, 80, 1, 0, 0,
196, 1, 0, 0, 82, 68,
69, 70, 100, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
60, 0, 0, 0, 0, 5,
254, 255, 0, 1, 36, 0,
60, 0, 0, 0, 82, 68,
49, 49, 60, 0, 0, 0,
24, 0, 0, 0, 32, 0,
0, 0, 40, 0, 0, 0,
36, 0, 0, 0, 12, 0,
0, 0, 0, 0, 0, 0,
77, 105, 99, 114, 111, 115,
111, 102, 116, 32, 40, 82,
41, 32, 72, 76, 83, 76,
32, 83, 104, 97, 100, 101,
114, 32, 67, 111, 109, 112,
105, 108, 101, 114, 32, 49,
48, 46, 49, 0, 73, 83,
71, 78, 80, 0, 0, 0,
2, 0, 0, 0, 8, 0,
0, 0, 56, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
0, 0, 0, 0, 15, 15,
0, 0, 68, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 3, 3,
0, 0, 83, 86, 95, 80,
79, 83, 73, 84, 73, 79,
78, 0, 84, 69, 88, 67,
79, 79, 82, 68, 0, 171,
171, 171, 79, 83, 71, 78,
80, 0, 0, 0, 2, 0,
0, 0, 8, 0, 0, 0,
56, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
3, 0, 0, 0, 0, 0,
0, 0, 15, 0, 0, 0,
68, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
3, 0, 0, 0, 1, 0,
0, 0, 3, 12, 0, 0,
83, 86, 95, 80, 79, 83,
73, 84, 73, 79, 78, 0,
84, 69, 88, 67, 79, 79,
82, 68, 0, 171, 171, 171,
83, 72, 69, 88, 108, 0,
0, 0, 80, 0, 1, 0,
27, 0, 0, 0, 106, 8,
0, 1, 95, 0, 0, 3,
242, 16, 16, 0, 0, 0,
0, 0, 95, 0, 0, 3,
50, 16, 16, 0, 1, 0,
0, 0, 103, 0, 0, 4,
242, 32, 16, 0, 0, 0,
0, 0, 1, 0, 0, 0,
101, 0, 0, 3, 50, 32,
16, 0, 1, 0, 0, 0,
54, 0, 0, 5, 242, 32,
16, 0, 0, 0, 0, 0,
70, 30, 16, 0, 0, 0,
0, 0, 54, 0, 0, 5,
50, 32, 16, 0, 1, 0,
0, 0, 70, 16, 16, 0,
1, 0, 0, 0, 62, 0,
0, 1, 83, 84, 65, 84,
148, 0, 0, 0, 3, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 4, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 2, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
0, 0
};

View file

@ -1,9 +0,0 @@
void main(
float4 pos : SV_POSITION,
float2 coord : TEXCOORD,
out float4 posOut : SV_POSITION,
out float2 coordOut : TEXCOORD
) {
posOut = pos;
coordOut = coord;
}