mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 03:59:36 +00:00
More window chrome improvements
This commit is contained in:
@@ -1,56 +1,67 @@
|
||||
static unsigned char gs_shaderData[] = {
|
||||
68, 88, 66, 67, 75, 29, 59, 91, 67, 226, 130, 211, 218, 1, 246,
|
||||
35, 4, 77, 147, 90, 1, 0, 0, 0, 4, 3, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 224, 0, 0, 0, 56, 1, 0, 0, 108,
|
||||
1, 0, 0, 136, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 122, 0, 0, 0, 92, 0,
|
||||
68, 88, 66, 67, 162, 86, 191, 155, 118, 151, 0, 3, 108, 83, 21,
|
||||
32, 68, 243, 178, 112, 1, 0, 0, 0, 176, 3, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 112, 1, 0, 0, 200, 1, 0, 0, 252,
|
||||
1, 0, 0, 52, 3, 0, 0, 82, 68, 69, 70, 52, 1, 0, 0,
|
||||
1, 0, 0, 0, 180, 0, 0, 0, 3, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 12, 1, 0, 0, 124, 0,
|
||||
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
|
||||
255, 255, 255, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0,
|
||||
107, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0,
|
||||
139, 0, 0, 0, 2, 0, 0, 0, 5, 0, 0, 0, 2, 0, 0,
|
||||
0, 255, 255, 255, 255, 1, 0, 0, 0, 1, 0, 0, 0, 13, 0,
|
||||
0, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116, 117, 114,
|
||||
101, 0, 112, 97, 108, 101, 116, 116, 101, 84, 101, 120, 116, 117, 114,
|
||||
101, 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, 65, 82, 71, 69,
|
||||
84, 0, 171, 171, 83, 72, 68, 82, 20, 1, 0, 0, 64, 0, 0,
|
||||
0, 69, 0, 0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0,
|
||||
0, 0, 68, 68, 0, 0, 88, 16, 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, 1, 0, 0, 0, 65, 0, 0, 5, 50, 0,
|
||||
16, 0, 0, 0, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 27,
|
||||
0, 0, 5, 50, 0, 16, 0, 0, 0, 0, 0, 70, 0, 16, 0,
|
||||
0, 0, 0, 0, 54, 0, 0, 8, 194, 0, 16, 0, 0, 0, 0,
|
||||
0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16, 0, 0,
|
||||
0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 70, 126, 16, 0,
|
||||
0, 0, 0, 0, 54, 0, 0, 8, 226, 0, 16, 0, 0, 0, 0,
|
||||
0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 45, 0, 0, 7, 242, 0, 16, 0, 0,
|
||||
0, 0, 0, 70, 14, 16, 0, 0, 0, 0, 0, 70, 126, 16, 0,
|
||||
1, 0, 0, 0, 54, 0, 0, 5, 114, 32, 16, 0, 0, 0, 0,
|
||||
0, 70, 2, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5, 130, 32,
|
||||
16, 0, 0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 62,
|
||||
0, 0, 1, 83, 84, 65, 84, 116, 0, 0, 0, 9, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
|
||||
0, 0, 154, 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,
|
||||
1, 0, 0, 0, 115, 117, 114, 102, 97, 99, 101, 84, 101, 120, 116,
|
||||
117, 114, 101, 0, 112, 97, 108, 101, 116, 116, 101, 84, 101, 120, 116,
|
||||
117, 114, 101, 0, 83, 68, 114, 97, 119, 81, 117, 97, 100, 80, 105,
|
||||
120, 101, 108, 67, 111, 110, 115, 116, 97, 110, 116, 115, 0, 171, 171,
|
||||
154, 0, 0, 0, 1, 0, 0, 0, 204, 0, 0, 0, 16, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, 0, 0,
|
||||
0, 0, 16, 0, 0, 0, 2, 0, 0, 0, 252, 0, 0, 0, 0,
|
||||
0, 0, 0, 99, 111, 110, 115, 116, 97, 110, 116, 115, 95, 77, 111,
|
||||
100, 117, 108, 97, 116, 105, 111, 110, 0, 171, 171, 171, 1, 0, 3,
|
||||
0, 1, 0, 4, 0, 0, 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, 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, 65, 82, 71, 69, 84, 0, 171, 171, 83, 72,
|
||||
68, 82, 48, 1, 0, 0, 64, 0, 0, 0, 76, 0, 0, 0, 89,
|
||||
0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, 1, 0, 0, 0,
|
||||
88, 24, 0, 4, 0, 112, 16, 0, 0, 0, 0, 0, 68, 68, 0,
|
||||
0, 88, 16, 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,
|
||||
1, 0, 0, 0, 65, 0, 0, 5, 50, 0, 16, 0, 0, 0, 0,
|
||||
0, 70, 16, 16, 0, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0,
|
||||
16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 54,
|
||||
0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 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, 4, 0, 0,
|
||||
0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 45, 0, 0, 7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14,
|
||||
16, 0, 0, 0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54,
|
||||
0, 0, 8, 226, 0, 16, 0, 0, 0, 0, 0, 2, 64, 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, 45, 0, 0, 7, 242, 0, 16, 0, 0, 0, 0, 0, 70, 14,
|
||||
16, 0, 0, 0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 54,
|
||||
0, 0, 5, 130, 0, 16, 0, 0, 0, 0, 0, 1, 64, 0, 0,
|
||||
0, 0, 128, 63, 56, 0, 0, 8, 242, 32, 16, 0, 0, 0, 0,
|
||||
0, 70, 14, 16, 0, 0, 0, 0, 0, 70, 142, 32, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 62, 0, 0, 1, 83, 84, 65, 84, 116,
|
||||
0, 0, 0, 9, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 0, 0, 0, 2, 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, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 3, 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,
|
||||
};
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#pragma comment (lib, "d3d11.lib")
|
||||
|
||||
static GpDisplayDriverSurfaceEffects gs_defaultEffects;
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
{
|
||||
extern const unsigned char *g_drawQuadV_D3D11[2];
|
||||
@@ -284,6 +286,20 @@ bool GpDisplayDriverD3D11::InitResources(uint32_t virtualWidth, uint32_t virtual
|
||||
return false;
|
||||
}
|
||||
|
||||
// Quad pixel constant buffer
|
||||
{
|
||||
D3D11_BUFFER_DESC bufferDesc;
|
||||
bufferDesc.ByteWidth = sizeof(DrawQuadPixelConstants);
|
||||
bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
bufferDesc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
|
||||
bufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
bufferDesc.MiscFlags = 0;
|
||||
bufferDesc.StructureByteStride = 0;
|
||||
|
||||
if (m_device->CreateBuffer(&bufferDesc, nullptr, m_drawQuadPixelConstantBuffer.GetMutablePtr()) != S_OK)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Quad index buffer
|
||||
{
|
||||
const uint16_t indexBufferData[] = { 0, 1, 2, 1, 3, 2 };
|
||||
@@ -1025,8 +1041,11 @@ IGpDisplayDriverSurface *GpDisplayDriverD3D11::CreateSurface(size_t width, size_
|
||||
return GpDisplayDriverSurfaceD3D11::Create(m_device, m_deviceContext, width, height, pixelFormat);
|
||||
}
|
||||
|
||||
void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height)
|
||||
void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects)
|
||||
{
|
||||
if (!effects)
|
||||
effects = &gs_defaultEffects;
|
||||
|
||||
ID3D11Buffer *vbPtr = m_quadVertexBuffer;
|
||||
UINT vbStride = sizeof(float) * 2;
|
||||
UINT zero = 0;
|
||||
@@ -1039,21 +1058,36 @@ void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t
|
||||
const float twoDivWidth = 2.0f / static_cast<float>(m_windowWidthVirtual);
|
||||
const float negativeTwoDivHeight = -2.0f / static_cast<float>(m_windowHeightVirtual);
|
||||
|
||||
DrawQuadVertexConstants constantsData;
|
||||
constantsData.m_ndcOriginX = static_cast<float>(x) * twoDivWidth - 1.0f;
|
||||
constantsData.m_ndcOriginY = static_cast<float>(y) * negativeTwoDivHeight + 1.0f;
|
||||
constantsData.m_ndcWidth = static_cast<float>(width) * twoDivWidth;
|
||||
constantsData.m_ndcHeight = static_cast<float>(height) * negativeTwoDivHeight;
|
||||
DrawQuadVertexConstants vConstantsData;
|
||||
vConstantsData.m_ndcOriginX = static_cast<float>(x) * twoDivWidth - 1.0f;
|
||||
vConstantsData.m_ndcOriginY = static_cast<float>(y) * negativeTwoDivHeight + 1.0f;
|
||||
vConstantsData.m_ndcWidth = static_cast<float>(width) * twoDivWidth;
|
||||
vConstantsData.m_ndcHeight = static_cast<float>(height) * negativeTwoDivHeight;
|
||||
|
||||
constantsData.m_surfaceDimensionX = static_cast<float>(d3d11Surface->GetWidth());
|
||||
constantsData.m_surfaceDimensionY = static_cast<float>(d3d11Surface->GetHeight());
|
||||
vConstantsData.m_surfaceDimensionX = static_cast<float>(d3d11Surface->GetWidth());
|
||||
vConstantsData.m_surfaceDimensionY = static_cast<float>(d3d11Surface->GetHeight());
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE mappedConstants;
|
||||
if (m_deviceContext->Map(m_drawQuadVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedConstants) == S_OK)
|
||||
D3D11_MAPPED_SUBRESOURCE vMappedConstants;
|
||||
if (m_deviceContext->Map(m_drawQuadVertexConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &vMappedConstants) == S_OK)
|
||||
{
|
||||
memcpy(mappedConstants.pData, &constantsData, sizeof(constantsData));
|
||||
memcpy(vMappedConstants.pData, &vConstantsData, sizeof(vConstantsData));
|
||||
m_deviceContext->Unmap(m_drawQuadVertexConstantBuffer, 0);
|
||||
}
|
||||
|
||||
DrawQuadPixelConstants pConstantsData;
|
||||
for (int i = 0; i < 4; i++)
|
||||
pConstantsData.m_modulation[i] = 1.0f;
|
||||
|
||||
if (effects->m_darken)
|
||||
for (int i = 0; i < 3; i++)
|
||||
pConstantsData.m_modulation[i] = 0.5f;
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE pMappedConstants;
|
||||
if (m_deviceContext->Map(m_drawQuadPixelConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &pMappedConstants) == S_OK)
|
||||
{
|
||||
memcpy(pMappedConstants.pData, &pConstantsData, sizeof(pConstantsData));
|
||||
m_deviceContext->Unmap(m_drawQuadPixelConstantBuffer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
m_deviceContext->IASetVertexBuffers(0, 1, &vbPtr, &vbStride, &zero);
|
||||
@@ -1071,6 +1105,9 @@ void GpDisplayDriverD3D11::DrawSurface(IGpDisplayDriverSurface *surface, int32_t
|
||||
};
|
||||
m_deviceContext->PSSetSamplers(0, sizeof(samplerStates) / sizeof(samplerStates[0]), samplerStates);
|
||||
|
||||
ID3D11Buffer *psConstants = m_drawQuadPixelConstantBuffer;
|
||||
m_deviceContext->PSSetConstantBuffers(0, 1, &psConstants);
|
||||
|
||||
GpPixelFormat_t pixelFormat = d3d11Surface->GetPixelFormat();
|
||||
if (pixelFormat == GpPixelFormats::k8BitStandard || pixelFormat == GpPixelFormats::k8BitCustom)
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ struct ID3D11Texture1D;
|
||||
struct ID3D11Texture2D;
|
||||
struct ID3D11VertexShader;
|
||||
|
||||
|
||||
class GpDisplayDriverD3D11 : public IGpDisplayDriver
|
||||
{
|
||||
public:
|
||||
@@ -38,7 +39,7 @@ public:
|
||||
void GetDisplayResolution(unsigned int *width, unsigned int *height, GpPixelFormat_t *bpp) override;
|
||||
|
||||
IGpDisplayDriverSurface *CreateSurface(size_t width, size_t height, GpPixelFormat_t pixelFormat) override;
|
||||
void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height) override;
|
||||
void DrawSurface(IGpDisplayDriverSurface *surface, int32_t x, int32_t y, size_t width, size_t height, const GpDisplayDriverSurfaceEffects *effects) override;
|
||||
|
||||
IGpCursor *LoadCursor(bool isColor, int cursorID) override;
|
||||
void SetCursor(IGpCursor *cursor) override;
|
||||
@@ -62,9 +63,15 @@ private:
|
||||
|
||||
float m_surfaceDimensionX;
|
||||
float m_surfaceDimensionY;
|
||||
|
||||
float m_unused[2];
|
||||
};
|
||||
|
||||
struct DrawQuadPixelConstants
|
||||
{
|
||||
float m_modulation[4];
|
||||
};
|
||||
|
||||
struct ScaleQuadPixelConstants
|
||||
{
|
||||
float m_dx;
|
||||
@@ -106,6 +113,7 @@ private:
|
||||
GpComPtr<ID3D11PixelShader> m_drawQuadRGBPixelShader;
|
||||
GpComPtr<ID3D11PixelShader> m_scaleQuadPixelShader;
|
||||
GpComPtr<ID3D11Buffer> m_drawQuadVertexConstantBuffer;
|
||||
GpComPtr<ID3D11Buffer> m_drawQuadPixelConstantBuffer;
|
||||
GpComPtr<ID3D11Buffer> m_scaleQuadPixelConstantBuffer;
|
||||
GpComPtr<ID3D11DepthStencilState> m_drawQuadDepthStencilState;
|
||||
GpComPtr<ID3D11SamplerState> m_nearestNeighborSamplerState;
|
||||
|
||||
Reference in New Issue
Block a user