mirror of
https://github.com/Blinue/Magpie.git
synced 2026-06-24 02:04:10 +00:00
fix: 修复 DX FL 10 的硬件上编译着色器依然使用ShaderModel 5.0的问题
This commit is contained in:
parent
50095acc3c
commit
4020cd92b8
14 changed files with 138 additions and 847 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue