MCPcopy Create free account
hub / github.com/aliasIsolation/aliasIsolation / modifySharpenPass

Function modifySharpenPass

src/dll/post.cpp:89–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89void modifySharpenPass(ID3D11DeviceContext *const context)
90{
91 ZoneScopedN(__FUNCTION__);
92
93 static ID3D11Texture2D *logoTex;
94 static ID3D11Buffer *cb;
95 static bool resourcesCreated = false;
96
97 struct Constants
98 {
99 float logoIntensity;
100 float sharpenAmount;
101 // this must be a 4 byte type, as a regular bool can potentially break the
102 // HLSL shader logic by not initialising all of the memory.
103 BOOL sharpenEnabled;
104 float pad;
105 } constants = {
106 // Fade off the logo with time
107 (g_frameConstants.gameTime > 0.0f ? (1.f - glm::smoothstep(10.0f, 12.0f, g_frameConstants.gameTime)) : 0.0f),
108 g_settings.sharpening, g_settings.sharpeningEnabled
109 // TODO! Is pad using initialised memory? If it isn't, this could cause
110 // cache misses.
111 };
112
113 if (!resourcesCreated)
114 {
115 resourcesCreated = true;
116
117 {
118 const std::string logoPath = getDataFilePath("textures\\aliasIsolationLogo.png", false);
119 int x, y, n;
120 unsigned char *data = stbi_load(logoPath.c_str(), &x, &y, &n, 4);
121 if (data && 4 == n)
122 {
123 D3D11_TEXTURE2D_DESC texDesc;
124 ZeroMemory(&texDesc, sizeof(texDesc));
125 texDesc.Width = x;
126 texDesc.Height = y;
127 texDesc.MipLevels = 1;
128 texDesc.ArraySize = 1;
129 texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
130 texDesc.SampleDesc.Count = 1;
131 texDesc.SampleDesc.Quality = 0;
132 texDesc.Usage = D3D11_USAGE_IMMUTABLE;
133 texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
134
135 D3D11_SUBRESOURCE_DATA sub;
136 ZeroMemory(&sub, sizeof(sub));
137 sub.pSysMem = data;
138 sub.SysMemPitch = x * n;
139 sub.SysMemSlicePitch = x * y * n;
140
141 DX_CHECK(g_device->CreateTexture2D(&texDesc, &sub, &logoTex));
142 }
143 stbi_image_free(data);
144 }
145
146 cb = createConstantBuffer(sizeof(constants));

Callers 1

Calls 4

getDataFilePathFunction · 0.85
createConstantBufferFunction · 0.85
updateConstantBufferFunction · 0.85
srvFromTexFunction · 0.85

Tested by

no test coverage detected