Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Compare 2pass float intermediate with 2pass 10bits intermediate. Slig…

…htly changed the difference shader to show the differences differently
  • Loading branch information...
commit b87b770d945109e0ebe2ee1471e82fb33bae483a 1 parent d5448b4
@CrystalP authored
View
23 system/shaders/difference_d3d.fx
@@ -57,8 +57,29 @@ PS_OUTPUT YUV2RGB( VS_OUTPUT In)
PS_OUTPUT OUT;
float4 diff = abs(tex2D(SamplerA, In.TextureUV) - tex2D(SamplerB, In.TextureUV));
+
+ if (diff.r > 2.0/255.0)
+ OUT.RGBColor.r = 1.0;
+ else if (diff.r > 1.0/255.0)
+ OUT.RGBColor.r = 0.5;
+ else
+ OUT.RGBColor.r = 0;
- OUT.RGBColor = diff * 50;
+ if (diff.g > 2.0/255.0)
+ OUT.RGBColor.g = 1.0;
+ else if (diff.g > 1.0/255.0)
+ OUT.RGBColor.g = 0.5;
+ else
+ OUT.RGBColor.g = 0;
+
+ if (diff.b > 2.0/255.0)
+ OUT.RGBColor.b = 1.0;
+ else if (diff.b > 1.0/255.0)
+ OUT.RGBColor.b = 0.5;
+ else
+ OUT.RGBColor.b = 0;
+
+ //OUT.RGBColor = diff * 50;
OUT.RGBColor.a = 1.0;
return OUT;
}
View
96 xbmc/cores/VideoRenderers/VideoShaders/WinVideoFilter.cpp
@@ -647,6 +647,58 @@ bool CConvolutionShaderSeparable::Create(ESCALINGMETHOD method)
return true;
}
+bool CConvolutionShaderSeparable::Create(ESCALINGMETHOD method, bool useFloat)
+{
+ CStdString effectString;
+ switch(method)
+ {
+ case VS_SCALINGMETHOD_CUBIC:
+ case VS_SCALINGMETHOD_LANCZOS2:
+ case VS_SCALINGMETHOD_LANCZOS3_FAST:
+ effectString = "special://xbmc/system/shaders/convolutionsep-4x4_d3d.fx";
+ break;
+ case VS_SCALINGMETHOD_LANCZOS3:
+ effectString = "special://xbmc/system/shaders/convolutionsep-6x6_d3d.fx";
+ break;
+ default:
+ CLog::Log(LOGERROR, __FUNCTION__": scaling method %d not supported.", method);
+ return false;
+ }
+
+ if (!ChooseIntermediateD3DFormat(useFloat))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": failed to find a compatible texture format for the intermediate render target.");
+ return false;
+ }
+
+ if (!ChooseKernelD3DFormat())
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": failed to find a compatible texture format for the kernel.");
+ return false;
+ }
+
+ CWinShader::CreateVertexBuffer(D3DFVF_XYZRHW | D3DFVF_TEX1, 8, sizeof(CUSTOMVERTEX), 2);
+
+ DefinesMap defines;
+ if (m_floattex)
+ defines["HAS_FLOAT_TEXTURE"] = "";
+ if (m_rgba)
+ defines["HAS_RGBA"] = "";
+ if (m_IntermediateIsFloat)
+ defines["HAS_FLOAT_INTERMEDIATE_TEXTURE"] = "";
+
+ if(!LoadEffect(effectString, &defines))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": Failed to load shader %s.", effectString.c_str());
+ return false;
+ }
+
+ if (!CreateHQKernel(method))
+ return false;
+
+ return true;
+}
+
void CConvolutionShaderSeparable::Render(CD3DTexture &sourceTexture,
unsigned int sourceWidth, unsigned int sourceHeight,
unsigned int destWidth, unsigned int destHeight,
@@ -686,17 +738,47 @@ bool CConvolutionShaderSeparable::ChooseIntermediateD3DFormat()
DWORD usage = D3DUSAGE_RENDERTARGET;
// Need a float texture, as the output of the first pass can contain negative values.
-/* if (g_Windowing.IsTextureFormatOk(D3DFMT_A2R10G10B10, usage)) { m_IntermediateFormat = D3DFMT_A2R10G10B10; m_IntermediateIsFloat = false; }
- else if (g_Windowing.IsTextureFormatOk(D3DFMT_A2B10G10R10, usage)) { m_IntermediateFormat = D3DFMT_A2B10G10R10; m_IntermediateIsFloat = false; }
- else*/ if (g_Windowing.IsTextureFormatOk(D3DFMT_A16B16G16R16F, usage)) { m_IntermediateFormat = D3DFMT_A16B16G16R16F; m_IntermediateIsFloat = true; }
- else if (g_Windowing.IsTextureFormatOk(D3DFMT_A32B32G32R32F, usage)) { m_IntermediateFormat = D3DFMT_A32B32G32R32F; m_IntermediateIsFloat = true; }
-/*else if (g_Windowing.IsTextureFormatOk(D3DFMT_A8R8G8B8, usage)) m_IntermediateFormat = D3DFMT_A8R8G8B8;
+ if (g_Windowing.IsTextureFormatOk(D3DFMT_A16B16G16R16F, usage)) { m_IntermediateFormat = D3DFMT_A16B16G16R16F; m_IntermediateIsFloat = true; }
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A32B32G32R32F, usage)) { m_IntermediateFormat = D3DFMT_A32B32G32R32F; m_IntermediateIsFloat = true; }
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A2R10G10B10, usage)) { m_IntermediateFormat = D3DFMT_A2R10G10B10; m_IntermediateIsFloat = false; }
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A2B10G10R10, usage)) { m_IntermediateFormat = D3DFMT_A2B10G10R10; m_IntermediateIsFloat = false; }
+
+
+ /*
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A8R8G8B8, usage)) m_IntermediateFormat = D3DFMT_A8R8G8B8;
else if (g_Windowing.IsTextureFormatOk(D3DFMT_A8B8G8R8, usage)) m_IntermediateFormat = D3DFMT_A8B8G8R8;
else if (g_Windowing.IsTextureFormatOk(D3DFMT_X8R8G8B8, usage)) m_IntermediateFormat = D3DFMT_X8R8G8B8;
else if (g_Windowing.IsTextureFormatOk(D3DFMT_X8B8G8R8, usage)) m_IntermediateFormat = D3DFMT_X8B8G8R8;
- else if (g_Windowing.IsTextureFormatOk(D3DFMT_R8G8B8, usage)) m_IntermediateFormat = D3DFMT_R8G8B8;*/
- else return false;
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_R8G8B8, usage)) m_IntermediateFormat = D3DFMT_R8G8B8;
+*/
+ CLog::Log(LOGDEBUG, __FUNCTION__": format %i", m_IntermediateFormat);
+ return true;
+}
+
+bool CConvolutionShaderSeparable::ChooseIntermediateD3DFormat(bool useFloat)
+{
+ DWORD usage = D3DUSAGE_RENDERTARGET;
+
+ // Need a float texture, as the output of the first pass can contain negative values.
+ if (useFloat)
+ {
+ if (g_Windowing.IsTextureFormatOk(D3DFMT_A16B16G16R16F, usage)) { m_IntermediateFormat = D3DFMT_A16B16G16R16F; m_IntermediateIsFloat = true; }
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A32B32G32R32F, usage)) { m_IntermediateFormat = D3DFMT_A32B32G32R32F; m_IntermediateIsFloat = true; }
+ }
+ else
+ {
+ if (g_Windowing.IsTextureFormatOk(D3DFMT_A2R10G10B10, usage)) { m_IntermediateFormat = D3DFMT_A2R10G10B10; m_IntermediateIsFloat = false; }
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A2B10G10R10, usage)) { m_IntermediateFormat = D3DFMT_A2B10G10R10; m_IntermediateIsFloat = false; }
+ }
+
+ /*
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A8R8G8B8, usage)) m_IntermediateFormat = D3DFMT_A8R8G8B8;
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_A8B8G8R8, usage)) m_IntermediateFormat = D3DFMT_A8B8G8R8;
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_X8R8G8B8, usage)) m_IntermediateFormat = D3DFMT_X8R8G8B8;
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_X8B8G8R8, usage)) m_IntermediateFormat = D3DFMT_X8B8G8R8;
+ else if (g_Windowing.IsTextureFormatOk(D3DFMT_R8G8B8, usage)) m_IntermediateFormat = D3DFMT_R8G8B8;
+*/
CLog::Log(LOGDEBUG, __FUNCTION__": format %i", m_IntermediateFormat);
return true;
View
2  xbmc/cores/VideoRenderers/VideoShaders/WinVideoFilter.h
@@ -154,6 +154,7 @@ class CConvolutionShaderSeparable : public CConvolutionShader
public:
CConvolutionShaderSeparable();
virtual bool Create(ESCALINGMETHOD method);
+ bool Create(ESCALINGMETHOD method, bool useFloat);
virtual void Render(CD3DTexture &sourceTexture,
unsigned int sourceWidth, unsigned int sourceHeight,
unsigned int destWidth, unsigned int destHeight,
@@ -163,6 +164,7 @@ class CConvolutionShaderSeparable : public CConvolutionShader
protected:
virtual bool ChooseIntermediateD3DFormat();
+ virtual bool ChooseIntermediateD3DFormat(bool useFloat);
virtual bool CreateIntermediateRenderTarget(unsigned int width, unsigned int height);
virtual void PrepareParameters(unsigned int sourceWidth, unsigned int sourceHeight,
unsigned int destWidth, unsigned int destHeight,
View
13 xbmc/cores/VideoRenderers/WinRenderer.cpp
@@ -558,20 +558,23 @@ void CWinRenderer::UpdatePSVideoFilter()
// First try the more efficient two pass convolution scaler
if (m_scalingMethod != VS_SCALINGMETHOD_CUBIC && m_scalingMethod != VS_SCALINGMETHOD_LANCZOS2)
{
- m_scalerShader = new CConvolutionShaderSeparable();
+ CConvolutionShaderSeparable* csr = new CConvolutionShaderSeparable();
+ m_scalerShader = csr;
- if (!m_scalerShader->Create(m_scalingMethod))
+ if (!csr->Create(m_scalingMethod, 0))
{
SAFE_DELETE(m_scalerShader);
CLog::Log(LOGNOTICE, __FUNCTION__": two pass convolution shader init problem, falling back to one pass.");
}
- m_scalerShaderRef = new CConvolutionShader1Pass();
+
+ csr = new CConvolutionShaderSeparable();
+ m_scalerShaderRef = csr;
- if (!m_scalerShaderRef->Create(m_scalingMethod))
+ if (!csr->Create(m_scalingMethod,1))
{
SAFE_DELETE(m_scalerShaderRef);
- CLog::Log(LOGNOTICE, __FUNCTION__": 1 pass convolution reference shader init problem, falling back to one pass.");
+ CLog::Log(LOGNOTICE, __FUNCTION__": reference shader init problem, falling back to one pass.");
}
m_differenceShader = new CDifferenceShader();
Please sign in to comment.
Something went wrong with that request. Please try again.