1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Use convolution for point display filter

This commit is contained in:
narzoul 2023-04-14 16:00:18 +02:00
parent 3a570414b7
commit c39dc0b334
5 changed files with 28 additions and 2 deletions

View File

@ -19,6 +19,7 @@
#include <Shaders/Lanczos.h>
#include <Shaders/LockRef.h>
#include <Shaders/PaletteLookup.h>
#include <Shaders/Point.h>
#include <Shaders/TextureSampler.h>
#define CONCAT_(a, b) a##b
@ -84,6 +85,7 @@ namespace D3dDdi
, m_psLanczos(createPixelShader(g_psLanczos))
, m_psLockRef(createPixelShader(g_psLockRef))
, m_psPaletteLookup(createPixelShader(g_psPaletteLookup))
, m_psPoint(createPixelShader(g_psPoint))
, m_psTextureSampler(createPixelShader(g_psTextureSampler))
, m_vertexShaderDecl(createVertexShaderDecl())
, m_convolutionParams{}
@ -528,8 +530,8 @@ namespace D3dDdi
switch (Config::displayFilter.get())
{
case Config::Settings::DisplayFilter::POINT:
m_device.getShaderBlitter().textureBlt(rt, rtIndex, rtRect,
srcResource, srcSubResourceIndex, srcRect, D3DTEXF_POINT);
m_device.getShaderBlitter().pointBlt(rt, rtIndex, rtRect,
srcResource, srcSubResourceIndex, srcRect);
break;
case Config::Settings::DisplayFilter::BILINEAR:
@ -669,6 +671,16 @@ namespace D3dDdi
m_psPaletteLookup.get(), D3DTEXF_POINT);
}
void ShaderBlitter::pointBlt(const Resource& dstResource, UINT dstSubResourceIndex, const RECT& dstRect,
const Resource& srcResource, UINT srcSubResourceIndex, const RECT& srcRect)
{
LOG_FUNC("ShaderBlitter::pointBlt", static_cast<HANDLE>(dstResource), dstSubResourceIndex, dstRect,
static_cast<HANDLE>(srcResource), srcSubResourceIndex, srcRect);
convolutionBlt(dstResource, dstSubResourceIndex, dstRect, srcResource, srcSubResourceIndex, srcRect,
0.5f, m_psPoint.get());
}
void ShaderBlitter::resetGammaRamp()
{
g_isGammaRampDefault = true;

View File

@ -46,6 +46,8 @@ namespace D3dDdi
const Resource& lockRefResource);
void palettizedBlt(const Resource& dstResource, UINT dstSubResourceIndex, const RECT& dstRect,
const Resource& srcResource, UINT srcSubResourceIndex, const RECT& srcRect, RGBQUAD palette[256]);
void pointBlt(const Resource& dstResource, UINT dstSubResourceIndex, const RECT& dstRect,
const Resource& srcResource, UINT srcSubResourceIndex, const RECT& srcRect);
void splineBlt(const Resource& dstResource, UINT dstSubResourceIndex, const RECT& dstRect,
const Resource& srcResource, UINT srcSubResourceIndex, const RECT& srcRect, UINT lobes);
void textureBlt(const Resource& dstResource, UINT dstSubResourceIndex, const RECT& dstRect,
@ -117,6 +119,7 @@ namespace D3dDdi
std::unique_ptr<void, ResourceDeleter> m_psLanczos;
std::unique_ptr<void, ResourceDeleter> m_psLockRef;
std::unique_ptr<void, ResourceDeleter> m_psPaletteLookup;
std::unique_ptr<void, ResourceDeleter> m_psPoint;
std::unique_ptr<void, ResourceDeleter> m_psTextureSampler;
std::unique_ptr<void, ResourceDeleter> m_vertexShaderDecl;
ConvolutionParams m_convolutionParams;

View File

@ -473,6 +473,7 @@
<FxCompile Include="Shaders\Lanczos.hlsl" />
<FxCompile Include="Shaders\LockRef.hlsl" />
<FxCompile Include="Shaders\PaletteLookup.hlsl" />
<FxCompile Include="Shaders\Point.hlsl" />
<FxCompile Include="Shaders\TextureSampler.hlsl" />
<FxCompile Include="Shaders\VertexFixup.hlsl">
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Vertex</ShaderType>

View File

@ -1115,6 +1115,9 @@
<FxCompile Include="Shaders\Bilinear.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
<FxCompile Include="Shaders\Point.hlsl">
<Filter>Shaders</Filter>
</FxCompile>
</ItemGroup>
<ItemGroup>
<Image Include="arrow.bmp">

View File

@ -0,0 +1,7 @@
#define NONNEGATIVE
#include "Convolution.hlsli"
float4 kernel(float4 x)
{
return abs(x) <= 0.5f;
}