mirror of https://github.com/PCSX2/pcsx2.git
Set some svn:eol-style properties.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5173 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
3d700b9264
commit
a27142f1a6
File diff suppressed because it is too large
Load Diff
|
@ -1,145 +1,145 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2007-2009 Gabest
|
* Copyright (C) 2007-2009 Gabest
|
||||||
* http://www.gabest.org
|
* http://www.gabest.org
|
||||||
*
|
*
|
||||||
* This Program is free software; you can redistribute it and/or modify
|
* This Program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2, or (at your option)
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
* any later version.
|
* any later version.
|
||||||
*
|
*
|
||||||
* This Program is distributed in the hope that it will be useful,
|
* This Program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with GNU Make; see the file COPYING. If not, write to
|
* along with GNU Make; see the file COPYING. If not, write to
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
* http://www.gnu.org/copyleft/gpl.html
|
* http://www.gnu.org/copyleft/gpl.html
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "GSRenderer.h"
|
#include "GSRenderer.h"
|
||||||
#include "GSDevice11.h"
|
#include "GSDevice11.h"
|
||||||
|
|
||||||
class GSRendererCS : public GSRenderer
|
class GSRendererCS : public GSRenderer
|
||||||
{
|
{
|
||||||
struct VSSelector
|
struct VSSelector
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32 tme:1;
|
uint32 tme:1;
|
||||||
uint32 fst:1;
|
uint32 fst:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 key;
|
uint32 key;
|
||||||
};
|
};
|
||||||
|
|
||||||
operator uint32() {return key & 0x3;}
|
operator uint32() {return key & 0x3;}
|
||||||
|
|
||||||
VSSelector() : key(0) {}
|
VSSelector() : key(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
__aligned(struct, 32) VSConstantBuffer
|
__aligned(struct, 32) VSConstantBuffer
|
||||||
{
|
{
|
||||||
GSVector4 VertexScale;
|
GSVector4 VertexScale;
|
||||||
GSVector4 VertexOffset;
|
GSVector4 VertexOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GSSelector
|
struct GSSelector
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32 iip:1;
|
uint32 iip:1;
|
||||||
uint32 prim:2;
|
uint32 prim:2;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 key;
|
uint32 key;
|
||||||
};
|
};
|
||||||
|
|
||||||
operator uint32() {return key & 0x7;}
|
operator uint32() {return key & 0x7;}
|
||||||
|
|
||||||
GSSelector() : key(0) {}
|
GSSelector() : key(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PSSelector
|
struct PSSelector
|
||||||
{
|
{
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
uint32 fpsm:6;
|
uint32 fpsm:6;
|
||||||
uint32 zpsm:6;
|
uint32 zpsm:6;
|
||||||
};
|
};
|
||||||
|
|
||||||
uint32 key;
|
uint32 key;
|
||||||
};
|
};
|
||||||
|
|
||||||
operator uint32() {return key & 0x3ff;}
|
operator uint32() {return key & 0x3ff;}
|
||||||
|
|
||||||
PSSelector() : key(0) {}
|
PSSelector() : key(0) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
__aligned(struct, 32) PSConstantBuffer
|
__aligned(struct, 32) PSConstantBuffer
|
||||||
{
|
{
|
||||||
uint32 fm;
|
uint32 fm;
|
||||||
uint32 zm;
|
uint32 zm;
|
||||||
};
|
};
|
||||||
|
|
||||||
CComPtr<ID3D11DepthStencilState> m_dss;
|
CComPtr<ID3D11DepthStencilState> m_dss;
|
||||||
CComPtr<ID3D11BlendState> m_bs;
|
CComPtr<ID3D11BlendState> m_bs;
|
||||||
CComPtr<ID3D11SamplerState> m_ss;
|
CComPtr<ID3D11SamplerState> m_ss;
|
||||||
CComPtr<ID3D11Buffer> m_lb;
|
CComPtr<ID3D11Buffer> m_lb;
|
||||||
CComPtr<ID3D11UnorderedAccessView> m_lb_uav;
|
CComPtr<ID3D11UnorderedAccessView> m_lb_uav;
|
||||||
CComPtr<ID3D11ShaderResourceView> m_lb_srv;
|
CComPtr<ID3D11ShaderResourceView> m_lb_srv;
|
||||||
CComPtr<ID3D11Buffer> m_sob;
|
CComPtr<ID3D11Buffer> m_sob;
|
||||||
CComPtr<ID3D11UnorderedAccessView> m_sob_uav;
|
CComPtr<ID3D11UnorderedAccessView> m_sob_uav;
|
||||||
CComPtr<ID3D11ShaderResourceView> m_sob_srv;
|
CComPtr<ID3D11ShaderResourceView> m_sob_srv;
|
||||||
CComPtr<ID3D11Buffer> m_vm;
|
CComPtr<ID3D11Buffer> m_vm;
|
||||||
//CComPtr<ID3D11Texture2D> m_vm;
|
//CComPtr<ID3D11Texture2D> m_vm;
|
||||||
CComPtr<ID3D11UnorderedAccessView> m_vm_uav;
|
CComPtr<ID3D11UnorderedAccessView> m_vm_uav;
|
||||||
uint32 m_vm_valid[16];
|
uint32 m_vm_valid[16];
|
||||||
CComPtr<ID3D11Buffer> m_pb;
|
CComPtr<ID3D11Buffer> m_pb;
|
||||||
//CComPtr<ID3D11Texture2D> m_pb;
|
//CComPtr<ID3D11Texture2D> m_pb;
|
||||||
hash_map<uint32, GSVertexShader11 > m_vs;
|
hash_map<uint32, GSVertexShader11 > m_vs;
|
||||||
CComPtr<ID3D11Buffer> m_vs_cb;
|
CComPtr<ID3D11Buffer> m_vs_cb;
|
||||||
hash_map<uint32, CComPtr<ID3D11GeometryShader> > m_gs;
|
hash_map<uint32, CComPtr<ID3D11GeometryShader> > m_gs;
|
||||||
CComPtr<ID3D11PixelShader> m_ps0;
|
CComPtr<ID3D11PixelShader> m_ps0;
|
||||||
hash_map<uint32, CComPtr<ID3D11PixelShader> > m_ps1;
|
hash_map<uint32, CComPtr<ID3D11PixelShader> > m_ps1;
|
||||||
CComPtr<ID3D11Buffer> m_ps_cb;
|
CComPtr<ID3D11Buffer> m_ps_cb;
|
||||||
|
|
||||||
void Write(GSOffset* o, const GSVector4i& r);
|
void Write(GSOffset* o, const GSVector4i& r);
|
||||||
void Read(GSOffset* o, const GSVector4i& r, bool invalidate);
|
void Read(GSOffset* o, const GSVector4i& r, bool invalidate);
|
||||||
|
|
||||||
struct OffsetBuffer
|
struct OffsetBuffer
|
||||||
{
|
{
|
||||||
CComPtr<ID3D11Buffer> row, col;
|
CComPtr<ID3D11Buffer> row, col;
|
||||||
CComPtr<ID3D11ShaderResourceView> row_srv, col_srv;
|
CComPtr<ID3D11ShaderResourceView> row_srv, col_srv;
|
||||||
};
|
};
|
||||||
|
|
||||||
hash_map<uint32, OffsetBuffer> m_offset;
|
hash_map<uint32, OffsetBuffer> m_offset;
|
||||||
|
|
||||||
bool GetOffsetBuffer(OffsetBuffer** fzbo);
|
bool GetOffsetBuffer(OffsetBuffer** fzbo);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
GSTexture* m_texture[2];
|
GSTexture* m_texture[2];
|
||||||
uint8* m_output;
|
uint8* m_output;
|
||||||
|
|
||||||
bool CreateDevice(GSDevice* dev);
|
bool CreateDevice(GSDevice* dev);
|
||||||
void ResetDevice();
|
void ResetDevice();
|
||||||
void VSync(int field);
|
void VSync(int field);
|
||||||
GSTexture* GetOutput(int i);
|
GSTexture* GetOutput(int i);
|
||||||
void Draw();
|
void Draw();
|
||||||
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
|
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
|
||||||
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut);
|
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GSRendererCS();
|
GSRendererCS();
|
||||||
virtual ~GSRendererCS();
|
virtual ~GSRendererCS();
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,44 +1,44 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2007-2009 Gabest
|
* Copyright (C) 2007-2009 Gabest
|
||||||
* http://www.gabest.org
|
* http://www.gabest.org
|
||||||
*
|
*
|
||||||
* This Program is free software; you can redistribute it and/or modify
|
* This Program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation; either version 2, or (at your option)
|
* the Free Software Foundation; either version 2, or (at your option)
|
||||||
* any later version.
|
* any later version.
|
||||||
*
|
*
|
||||||
* This Program is distributed in the hope that it will be useful,
|
* This Program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with GNU Make; see the file COPYING. If not, write to
|
* along with GNU Make; see the file COPYING. If not, write to
|
||||||
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
* http://www.gnu.org/copyleft/gpl.html
|
* http://www.gnu.org/copyleft/gpl.html
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//#define ENABLE_VTUNE
|
//#define ENABLE_VTUNE
|
||||||
|
|
||||||
#define ENABLE_JIT_RASTERIZER
|
#define ENABLE_JIT_RASTERIZER
|
||||||
|
|
||||||
//#define ENABLE_DYNAMIC_CRC_HACK
|
//#define ENABLE_DYNAMIC_CRC_HACK
|
||||||
|
|
||||||
#define ENABLE_UPSCALE_HACKS // Hacks intended to fix upscaling / rendering glitches in HW renderers
|
#define ENABLE_UPSCALE_HACKS // Hacks intended to fix upscaling / rendering glitches in HW renderers
|
||||||
|
|
||||||
//#define DISABLE_HW_TEXTURE_CACHE // Slow but fixes a lot of bugs
|
//#define DISABLE_HW_TEXTURE_CACHE // Slow but fixes a lot of bugs
|
||||||
|
|
||||||
//#define DISABLE_CRC_HACKS // Disable all game specific hacks
|
//#define DISABLE_CRC_HACKS // Disable all game specific hacks
|
||||||
|
|
||||||
#if defined(DISABLE_HW_TEXTURE_CACHE) && !defined(DISABLE_CRC_HACKS)
|
#if defined(DISABLE_HW_TEXTURE_CACHE) && !defined(DISABLE_CRC_HACKS)
|
||||||
#define DISABLE_CRC_HACKS
|
#define DISABLE_CRC_HACKS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define DISABLE_BITMASKING
|
//#define DISABLE_BITMASKING
|
||||||
|
|
||||||
//#define DISABLE_COLCLAMP
|
//#define DISABLE_COLCLAMP
|
||||||
|
|
||||||
//#define DISABLE_DATE
|
//#define DISABLE_DATE
|
||||||
|
|
|
@ -1,383 +1,383 @@
|
||||||
#ifndef VS_TME
|
#ifndef VS_TME
|
||||||
#define VS_TME 1
|
#define VS_TME 1
|
||||||
#define VS_FST 1
|
#define VS_FST 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef GS_IIP
|
#ifndef GS_IIP
|
||||||
#define GS_IIP 0
|
#define GS_IIP 0
|
||||||
#define GS_PRIM 2
|
#define GS_PRIM 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PS_BATCH_SIZE
|
#ifndef PS_BATCH_SIZE
|
||||||
#define PS_BATCH_SIZE 2048
|
#define PS_BATCH_SIZE 2048
|
||||||
#define PS_FPSM PSM_PSMCT32
|
#define PS_FPSM PSM_PSMCT32
|
||||||
#define PS_ZPSM PSM_PSMZ16
|
#define PS_ZPSM PSM_PSMZ16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PSM_PSMCT32 0
|
#define PSM_PSMCT32 0
|
||||||
#define PSM_PSMCT24 1
|
#define PSM_PSMCT24 1
|
||||||
#define PSM_PSMCT16 2
|
#define PSM_PSMCT16 2
|
||||||
#define PSM_PSMCT16S 10
|
#define PSM_PSMCT16S 10
|
||||||
#define PSM_PSMT8 19
|
#define PSM_PSMT8 19
|
||||||
#define PSM_PSMT4 20
|
#define PSM_PSMT4 20
|
||||||
#define PSM_PSMT8H 27
|
#define PSM_PSMT8H 27
|
||||||
#define PSM_PSMT4HL 36
|
#define PSM_PSMT4HL 36
|
||||||
#define PSM_PSMT4HH 44
|
#define PSM_PSMT4HH 44
|
||||||
#define PSM_PSMZ32 48
|
#define PSM_PSMZ32 48
|
||||||
#define PSM_PSMZ24 49
|
#define PSM_PSMZ24 49
|
||||||
#define PSM_PSMZ16 50
|
#define PSM_PSMZ16 50
|
||||||
#define PSM_PSMZ16S 58
|
#define PSM_PSMZ16S 58
|
||||||
|
|
||||||
struct VS_INPUT
|
struct VS_INPUT
|
||||||
{
|
{
|
||||||
float2 st : TEXCOORD0;
|
float2 st : TEXCOORD0;
|
||||||
float4 c : COLOR0;
|
float4 c : COLOR0;
|
||||||
float q : TEXCOORD1;
|
float q : TEXCOORD1;
|
||||||
uint2 p : POSITION0;
|
uint2 p : POSITION0;
|
||||||
uint z : POSITION1;
|
uint z : POSITION1;
|
||||||
uint2 uv : TEXCOORD2;
|
uint2 uv : TEXCOORD2;
|
||||||
float4 f : COLOR1;
|
float4 f : COLOR1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VS_OUTPUT
|
struct VS_OUTPUT
|
||||||
{
|
{
|
||||||
float4 p : SV_Position;
|
float4 p : SV_Position;
|
||||||
float2 z : TEXCOORD0;
|
float2 z : TEXCOORD0;
|
||||||
float4 t : TEXCOORD1;
|
float4 t : TEXCOORD1;
|
||||||
float4 c : COLOR0;
|
float4 c : COLOR0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GS_OUTPUT
|
struct GS_OUTPUT
|
||||||
{
|
{
|
||||||
float4 p : SV_Position;
|
float4 p : SV_Position;
|
||||||
float2 z : TEXCOORD0;
|
float2 z : TEXCOORD0;
|
||||||
float4 t : TEXCOORD1;
|
float4 t : TEXCOORD1;
|
||||||
float4 c : COLOR0;
|
float4 c : COLOR0;
|
||||||
uint id : SV_PrimitiveID;
|
uint id : SV_PrimitiveID;
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer VSConstantBuffer : register(c0)
|
cbuffer VSConstantBuffer : register(c0)
|
||||||
{
|
{
|
||||||
float4 VertexScale;
|
float4 VertexScale;
|
||||||
float4 VertexOffset;
|
float4 VertexOffset;
|
||||||
};
|
};
|
||||||
|
|
||||||
cbuffer PSConstantBuffer : register(c0)
|
cbuffer PSConstantBuffer : register(c0)
|
||||||
{
|
{
|
||||||
uint2 WriteMask;
|
uint2 WriteMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FragmentLinkItem
|
struct FragmentLinkItem
|
||||||
{
|
{
|
||||||
uint c, z, id, next;
|
uint c, z, id, next;
|
||||||
};
|
};
|
||||||
|
|
||||||
RWByteAddressBuffer VideoMemory : register(u0);
|
RWByteAddressBuffer VideoMemory : register(u0);
|
||||||
RWStructuredBuffer<FragmentLinkItem> FragmentLinkBuffer : register(u1);
|
RWStructuredBuffer<FragmentLinkItem> FragmentLinkBuffer : register(u1);
|
||||||
RWByteAddressBuffer StartOffsetBuffer : register(u2);
|
RWByteAddressBuffer StartOffsetBuffer : register(u2);
|
||||||
//RWTexture2D<uint> VideoMemory : register(u2); // 8192 * 512 R8_UINT
|
//RWTexture2D<uint> VideoMemory : register(u2); // 8192 * 512 R8_UINT
|
||||||
|
|
||||||
Buffer<int2> FZRowOffset : register(t0);
|
Buffer<int2> FZRowOffset : register(t0);
|
||||||
Buffer<int2> FZColOffset : register(t1);
|
Buffer<int2> FZColOffset : register(t1);
|
||||||
Texture2D<float4> Palette : register(t2);
|
Texture2D<float4> Palette : register(t2);
|
||||||
Texture2D<float4> Texture : register(t3);
|
Texture2D<float4> Texture : register(t3);
|
||||||
|
|
||||||
VS_OUTPUT vs_main(VS_INPUT input)
|
VS_OUTPUT vs_main(VS_INPUT input)
|
||||||
{
|
{
|
||||||
VS_OUTPUT output;
|
VS_OUTPUT output;
|
||||||
|
|
||||||
output.p = float4(input.p, 0.0f, 0.0f) * VertexScale - VertexOffset;
|
output.p = float4(input.p, 0.0f, 0.0f) * VertexScale - VertexOffset;
|
||||||
output.z = float2(input.z & 0xffff, input.z >> 16); // TODO: min(input.z, 0xffffff00) ?
|
output.z = float2(input.z & 0xffff, input.z >> 16); // TODO: min(input.z, 0xffffff00) ?
|
||||||
|
|
||||||
if(VS_TME)
|
if(VS_TME)
|
||||||
{
|
{
|
||||||
if(VS_FST)
|
if(VS_FST)
|
||||||
{
|
{
|
||||||
output.t.xy = input.uv;
|
output.t.xy = input.uv;
|
||||||
output.t.w = 1.0f;
|
output.t.w = 1.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output.t.xy = input.st;
|
output.t.xy = input.st;
|
||||||
output.t.w = input.q;
|
output.t.w = input.q;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
output.t.xy = 0;
|
output.t.xy = 0;
|
||||||
output.t.w = 1.0f;
|
output.t.w = 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.c = input.c;
|
output.c = input.c;
|
||||||
output.t.z = input.f.r;
|
output.t.z = input.f.r;
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if GS_PRIM == 0
|
#if GS_PRIM == 0
|
||||||
|
|
||||||
[maxvertexcount(1)]
|
[maxvertexcount(1)]
|
||||||
void gs_main(point VS_OUTPUT input[1], inout PointStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
void gs_main(point VS_OUTPUT input[1], inout PointStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
||||||
{
|
{
|
||||||
GS_OUTPUT output;
|
GS_OUTPUT output;
|
||||||
|
|
||||||
output.p = input[0].p;
|
output.p = input[0].p;
|
||||||
output.z = input[0].z;
|
output.z = input[0].z;
|
||||||
output.t = input[0].t;
|
output.t = input[0].t;
|
||||||
output.c = input[0].c;
|
output.c = input[0].c;
|
||||||
output.id = id;
|
output.id = id;
|
||||||
|
|
||||||
stream.Append(output);
|
stream.Append(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif GS_PRIM == 1
|
#elif GS_PRIM == 1
|
||||||
|
|
||||||
[maxvertexcount(2)]
|
[maxvertexcount(2)]
|
||||||
void gs_main(line VS_OUTPUT input[2], inout LineStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
void gs_main(line VS_OUTPUT input[2], inout LineStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
||||||
{
|
{
|
||||||
[unroll]
|
[unroll]
|
||||||
for(int i = 0; i < 2; i++)
|
for(int i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
GS_OUTPUT output;
|
GS_OUTPUT output;
|
||||||
|
|
||||||
output.p = input[i].p;
|
output.p = input[i].p;
|
||||||
output.z = input[i].z;
|
output.z = input[i].z;
|
||||||
output.t = input[i].t;
|
output.t = input[i].t;
|
||||||
output.c = input[i].c;
|
output.c = input[i].c;
|
||||||
output.id = id;
|
output.id = id;
|
||||||
|
|
||||||
#if GS_IIP == 0
|
#if GS_IIP == 0
|
||||||
if(i != 1) output.c = input[1].c;
|
if(i != 1) output.c = input[1].c;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
stream.Append(output);
|
stream.Append(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif GS_PRIM == 2
|
#elif GS_PRIM == 2
|
||||||
|
|
||||||
[maxvertexcount(3)]
|
[maxvertexcount(3)]
|
||||||
void gs_main(triangle VS_OUTPUT input[3], inout TriangleStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
void gs_main(triangle VS_OUTPUT input[3], inout TriangleStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
||||||
{
|
{
|
||||||
[unroll]
|
[unroll]
|
||||||
for(int i = 0; i < 3; i++)
|
for(int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
GS_OUTPUT output;
|
GS_OUTPUT output;
|
||||||
|
|
||||||
output.p = input[i].p;
|
output.p = input[i].p;
|
||||||
output.z = input[i].z;
|
output.z = input[i].z;
|
||||||
output.t = input[i].t;
|
output.t = input[i].t;
|
||||||
output.c = input[i].c;
|
output.c = input[i].c;
|
||||||
output.id = id;
|
output.id = id;
|
||||||
|
|
||||||
#if GS_IIP == 0
|
#if GS_IIP == 0
|
||||||
if(i != 2) output.c = input[2].c;
|
if(i != 2) output.c = input[2].c;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
stream.Append(output);
|
stream.Append(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif GS_PRIM == 3
|
#elif GS_PRIM == 3
|
||||||
|
|
||||||
[maxvertexcount(4)]
|
[maxvertexcount(4)]
|
||||||
void gs_main(line VS_OUTPUT input[2], inout TriangleStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
void gs_main(line VS_OUTPUT input[2], inout TriangleStream<GS_OUTPUT> stream, uint id : SV_PrimitiveID)
|
||||||
{
|
{
|
||||||
GS_OUTPUT lt, rb, lb, rt;
|
GS_OUTPUT lt, rb, lb, rt;
|
||||||
|
|
||||||
lt.p = input[0].p;
|
lt.p = input[0].p;
|
||||||
lt.z = input[1].z;
|
lt.z = input[1].z;
|
||||||
lt.t.xy = input[0].t.xy;
|
lt.t.xy = input[0].t.xy;
|
||||||
lt.t.zw = input[1].t.zw;
|
lt.t.zw = input[1].t.zw;
|
||||||
lt.c = input[0].c;
|
lt.c = input[0].c;
|
||||||
lt.id = id;
|
lt.id = id;
|
||||||
|
|
||||||
#if GS_IIP == 0
|
#if GS_IIP == 0
|
||||||
lt.c = input[1].c;
|
lt.c = input[1].c;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rb.p = input[1].p;
|
rb.p = input[1].p;
|
||||||
rb.z = input[1].z;
|
rb.z = input[1].z;
|
||||||
rb.t = input[1].t;
|
rb.t = input[1].t;
|
||||||
rb.c = input[1].c;
|
rb.c = input[1].c;
|
||||||
rb.id = id;
|
rb.id = id;
|
||||||
|
|
||||||
lb = lt;
|
lb = lt;
|
||||||
lb.p.y = rb.p.y;
|
lb.p.y = rb.p.y;
|
||||||
lb.t.y = rb.t.y;
|
lb.t.y = rb.t.y;
|
||||||
|
|
||||||
rt = rb;
|
rt = rb;
|
||||||
rt.p.y = lt.p.y;
|
rt.p.y = lt.p.y;
|
||||||
rt.t.y = lt.t.y;
|
rt.t.y = lt.t.y;
|
||||||
|
|
||||||
stream.Append(lt);
|
stream.Append(lt);
|
||||||
stream.Append(lb);
|
stream.Append(lb);
|
||||||
stream.Append(rt);
|
stream.Append(rt);
|
||||||
stream.Append(rb);
|
stream.Append(rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint CompressColor32(float4 f)
|
uint CompressColor32(float4 f)
|
||||||
{
|
{
|
||||||
uint4 c = (uint4)(f * 0xff) << uint4(0, 8, 16, 24);
|
uint4 c = (uint4)(f * 0xff) << uint4(0, 8, 16, 24);
|
||||||
|
|
||||||
return c.r | c.g | c.b | c.a;
|
return c.r | c.g | c.b | c.a;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint DecompressColor16(uint c)
|
uint DecompressColor16(uint c)
|
||||||
{
|
{
|
||||||
uint r = (c & 0x001f) << 3;
|
uint r = (c & 0x001f) << 3;
|
||||||
uint g = (c & 0x03e0) << 6;
|
uint g = (c & 0x03e0) << 6;
|
||||||
uint b = (c & 0x7c00) << 9;
|
uint b = (c & 0x7c00) << 9;
|
||||||
uint a = (c & 0x8000) << 15;
|
uint a = (c & 0x8000) << 15;
|
||||||
|
|
||||||
return r | g | b | a;
|
return r | g | b | a;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint ReadPixel(uint addr)
|
uint ReadPixel(uint addr)
|
||||||
{
|
{
|
||||||
return VideoMemory.Load(addr) >> ((addr & 2) << 3);
|
return VideoMemory.Load(addr) >> ((addr & 2) << 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WritePixel(uint addr, uint value, uint psm)
|
void WritePixel(uint addr, uint value, uint psm)
|
||||||
{
|
{
|
||||||
uint tmp;
|
uint tmp;
|
||||||
|
|
||||||
switch(psm)
|
switch(psm)
|
||||||
{
|
{
|
||||||
case PSM_PSMCT32:
|
case PSM_PSMCT32:
|
||||||
case PSM_PSMZ32:
|
case PSM_PSMZ32:
|
||||||
case PSM_PSMCT24:
|
case PSM_PSMCT24:
|
||||||
case PSM_PSMZ24:
|
case PSM_PSMZ24:
|
||||||
VideoMemory.Store(addr, value);
|
VideoMemory.Store(addr, value);
|
||||||
break;
|
break;
|
||||||
case PSM_PSMCT16:
|
case PSM_PSMCT16:
|
||||||
case PSM_PSMCT16S:
|
case PSM_PSMCT16S:
|
||||||
case PSM_PSMZ16:
|
case PSM_PSMZ16:
|
||||||
case PSM_PSMZ16S:
|
case PSM_PSMZ16S:
|
||||||
tmp = (addr & 2) << 3;
|
tmp = (addr & 2) << 3;
|
||||||
value = ((value << tmp) ^ VideoMemory.Load(addr)) & (0x0000ffff << tmp);
|
value = ((value << tmp) ^ VideoMemory.Load(addr)) & (0x0000ffff << tmp);
|
||||||
VideoMemory.InterlockedXor(addr, value, tmp);
|
VideoMemory.InterlockedXor(addr, value, tmp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ps_main0(GS_OUTPUT input)
|
void ps_main0(GS_OUTPUT input)
|
||||||
{
|
{
|
||||||
uint x = (uint)input.p.x;
|
uint x = (uint)input.p.x;
|
||||||
uint y = (uint)input.p.y;
|
uint y = (uint)input.p.y;
|
||||||
|
|
||||||
uint tail = FragmentLinkBuffer.IncrementCounter();
|
uint tail = FragmentLinkBuffer.IncrementCounter();
|
||||||
|
|
||||||
uint index = (y << 11) + x;
|
uint index = (y << 11) + x;
|
||||||
uint next = 0;
|
uint next = 0;
|
||||||
|
|
||||||
StartOffsetBuffer.InterlockedExchange(index * 4, tail, next);
|
StartOffsetBuffer.InterlockedExchange(index * 4, tail, next);
|
||||||
|
|
||||||
FragmentLinkItem item;
|
FragmentLinkItem item;
|
||||||
|
|
||||||
// TODO: preprocess color (tfx, alpha test), z-test
|
// TODO: preprocess color (tfx, alpha test), z-test
|
||||||
|
|
||||||
item.c = CompressColor32(input.c);
|
item.c = CompressColor32(input.c);
|
||||||
item.z = (uint)(input.z.y * 0x10000 + input.z.x);
|
item.z = (uint)(input.z.y * 0x10000 + input.z.x);
|
||||||
item.id = input.id;
|
item.id = input.id;
|
||||||
item.next = next;
|
item.next = next;
|
||||||
|
|
||||||
FragmentLinkBuffer[tail] = item;
|
FragmentLinkBuffer[tail] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ps_main1(GS_OUTPUT input)
|
void ps_main1(GS_OUTPUT input)
|
||||||
{
|
{
|
||||||
uint2 pos = (uint2)input.p.xy;
|
uint2 pos = (uint2)input.p.xy;
|
||||||
|
|
||||||
// sort fragments
|
// sort fragments
|
||||||
|
|
||||||
uint StartOffsetIndex = (pos.y << 11) + pos.x;
|
uint StartOffsetIndex = (pos.y << 11) + pos.x;
|
||||||
|
|
||||||
int index[PS_BATCH_SIZE];
|
int index[PS_BATCH_SIZE];
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
uint next = StartOffsetBuffer.Load(StartOffsetIndex * 4);
|
uint next = StartOffsetBuffer.Load(StartOffsetIndex * 4);
|
||||||
|
|
||||||
StartOffsetBuffer.Store(StartOffsetIndex * 4, 0);
|
StartOffsetBuffer.Store(StartOffsetIndex * 4, 0);
|
||||||
|
|
||||||
[allow_uav_condition]
|
[allow_uav_condition]
|
||||||
while(next != 0)
|
while(next != 0)
|
||||||
{
|
{
|
||||||
index[count++] = next;
|
index[count++] = next;
|
||||||
|
|
||||||
next = FragmentLinkBuffer[next].next;
|
next = FragmentLinkBuffer[next].next;
|
||||||
}
|
}
|
||||||
|
|
||||||
int N2 = 1 << (int)(ceil(log2(count)));
|
int N2 = 1 << (int)(ceil(log2(count)));
|
||||||
|
|
||||||
[allow_uav_condition]
|
[allow_uav_condition]
|
||||||
for(int i = count; i < N2; i++)
|
for(int i = count; i < N2; i++)
|
||||||
{
|
{
|
||||||
index[i] = 0;
|
index[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[allow_uav_condition]
|
[allow_uav_condition]
|
||||||
for(int k = 2; k <= N2; k = 2 * k)
|
for(int k = 2; k <= N2; k = 2 * k)
|
||||||
{
|
{
|
||||||
[allow_uav_condition]
|
[allow_uav_condition]
|
||||||
for(int j = k >> 1; j > 0 ; j = j >> 1)
|
for(int j = k >> 1; j > 0 ; j = j >> 1)
|
||||||
{
|
{
|
||||||
[allow_uav_condition]
|
[allow_uav_condition]
|
||||||
for(int i = 0; i < N2; i++)
|
for(int i = 0; i < N2; i++)
|
||||||
{
|
{
|
||||||
uint i_id = FragmentLinkBuffer[index[i]].id;
|
uint i_id = FragmentLinkBuffer[index[i]].id;
|
||||||
|
|
||||||
int ixj = i ^ j;
|
int ixj = i ^ j;
|
||||||
|
|
||||||
if(ixj > i)
|
if(ixj > i)
|
||||||
{
|
{
|
||||||
uint ixj_id = FragmentLinkBuffer[index[ixj]].id;
|
uint ixj_id = FragmentLinkBuffer[index[ixj]].id;
|
||||||
|
|
||||||
if((i & k) == 0 && i_id > ixj_id)
|
if((i & k) == 0 && i_id > ixj_id)
|
||||||
{
|
{
|
||||||
int temp = index[i];
|
int temp = index[i];
|
||||||
index[i] = index[ixj];
|
index[i] = index[ixj];
|
||||||
index[ixj] = temp;
|
index[ixj] = temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((i & k) != 0 && i_id < ixj_id)
|
if((i & k) != 0 && i_id < ixj_id)
|
||||||
{
|
{
|
||||||
int temp = index[i];
|
int temp = index[i];
|
||||||
index[i] = index[ixj];
|
index[i] = index[ixj];
|
||||||
index[ixj] = temp;
|
index[ixj] = temp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint2 addr = (uint2)(FZRowOffset[pos.y] + FZColOffset[pos.x]) << 1;
|
uint2 addr = (uint2)(FZRowOffset[pos.y] + FZColOffset[pos.x]) << 1;
|
||||||
|
|
||||||
uint dc = ReadPixel(addr.x);
|
uint dc = ReadPixel(addr.x);
|
||||||
uint dz = ReadPixel(addr.y);
|
uint dz = ReadPixel(addr.y);
|
||||||
|
|
||||||
uint sc = dc;
|
uint sc = dc;
|
||||||
uint sz = dz;
|
uint sz = dz;
|
||||||
|
|
||||||
[allow_uav_condition]
|
[allow_uav_condition]
|
||||||
while(--count >= 0)
|
while(--count >= 0)
|
||||||
{
|
{
|
||||||
FragmentLinkItem f = FragmentLinkBuffer[index[count]];
|
FragmentLinkItem f = FragmentLinkBuffer[index[count]];
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
||||||
if(sz < f.z)
|
if(sz < f.z)
|
||||||
{
|
{
|
||||||
sc = f.c;
|
sc = f.c;
|
||||||
sz = f.z;
|
sz = f.z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint c = sc; // (dc & ~WriteMask.x) | (sc & WriteMask.x);
|
uint c = sc; // (dc & ~WriteMask.x) | (sc & WriteMask.x);
|
||||||
uint z = 0;//sz; //(dz & ~WriteMask.y) | (sz & WriteMask.y);
|
uint z = 0;//sz; //(dz & ~WriteMask.y) | (sz & WriteMask.y);
|
||||||
|
|
||||||
WritePixel(addr.x, c, PS_FPSM);
|
WritePixel(addr.x, c, PS_FPSM);
|
||||||
WritePixel(addr.y, z, PS_ZPSM);
|
WritePixel(addr.y, z, PS_ZPSM);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,76 +1,76 @@
|
||||||
#ifdef SHADER_MODEL // make safe to include in resource file to enforce dependency
|
#ifdef SHADER_MODEL // make safe to include in resource file to enforce dependency
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Contrast, saturation, brightness
|
** Contrast, saturation, brightness
|
||||||
** Code of this function is from TGM's shader pack
|
** Code of this function is from TGM's shader pack
|
||||||
** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057
|
** http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
|
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
|
||||||
float4 ContrastSaturationBrightness(float4 color) // Ported to HLSL
|
float4 ContrastSaturationBrightness(float4 color) // Ported to HLSL
|
||||||
{
|
{
|
||||||
const float sat = SB_SATURATION / 50.0;
|
const float sat = SB_SATURATION / 50.0;
|
||||||
const float brt = SB_BRIGHTNESS / 50.0;
|
const float brt = SB_BRIGHTNESS / 50.0;
|
||||||
const float con = SB_CONTRAST / 50.0;
|
const float con = SB_CONTRAST / 50.0;
|
||||||
|
|
||||||
// Increase or decrease theese values to adjust r, g and b color channels seperately
|
// Increase or decrease theese values to adjust r, g and b color channels seperately
|
||||||
const float AvgLumR = 0.5;
|
const float AvgLumR = 0.5;
|
||||||
const float AvgLumG = 0.5;
|
const float AvgLumG = 0.5;
|
||||||
const float AvgLumB = 0.5;
|
const float AvgLumB = 0.5;
|
||||||
|
|
||||||
const float3 LumCoeff = float3(0.2125, 0.7154, 0.0721);
|
const float3 LumCoeff = float3(0.2125, 0.7154, 0.0721);
|
||||||
|
|
||||||
float3 AvgLumin = float3(AvgLumR, AvgLumG, AvgLumB);
|
float3 AvgLumin = float3(AvgLumR, AvgLumG, AvgLumB);
|
||||||
float3 brtColor = color.rgb * brt;
|
float3 brtColor = color.rgb * brt;
|
||||||
float3 intensity = dot(brtColor, LumCoeff);
|
float3 intensity = dot(brtColor, LumCoeff);
|
||||||
float3 satColor = lerp(intensity, brtColor, sat);
|
float3 satColor = lerp(intensity, brtColor, sat);
|
||||||
float3 conColor = lerp(AvgLumin, satColor, con);
|
float3 conColor = lerp(AvgLumin, satColor, con);
|
||||||
|
|
||||||
color.rgb = conColor;
|
color.rgb = conColor;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SHADER_MODEL >= 0x400
|
#if SHADER_MODEL >= 0x400
|
||||||
|
|
||||||
Texture2D Texture;
|
Texture2D Texture;
|
||||||
SamplerState Sampler;
|
SamplerState Sampler;
|
||||||
|
|
||||||
cbuffer cb0
|
cbuffer cb0
|
||||||
{
|
{
|
||||||
float4 BGColor;
|
float4 BGColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
{
|
{
|
||||||
float4 p : SV_Position;
|
float4 p : SV_Position;
|
||||||
float2 t : TEXCOORD0;
|
float2 t : TEXCOORD0;
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 ps_main(PS_INPUT input) : SV_Target0
|
float4 ps_main(PS_INPUT input) : SV_Target0
|
||||||
{
|
{
|
||||||
float4 c = Texture.Sample(Sampler, input.t);
|
float4 c = Texture.Sample(Sampler, input.t);
|
||||||
return ContrastSaturationBrightness(c);
|
return ContrastSaturationBrightness(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#elif SHADER_MODEL <= 0x300
|
#elif SHADER_MODEL <= 0x300
|
||||||
|
|
||||||
sampler Texture : register(s0);
|
sampler Texture : register(s0);
|
||||||
|
|
||||||
float4 g_params[1];
|
float4 g_params[1];
|
||||||
|
|
||||||
#define BGColor (g_params[0])
|
#define BGColor (g_params[0])
|
||||||
|
|
||||||
struct PS_INPUT
|
struct PS_INPUT
|
||||||
{
|
{
|
||||||
float2 t : TEXCOORD0;
|
float2 t : TEXCOORD0;
|
||||||
};
|
};
|
||||||
|
|
||||||
float4 ps_main(PS_INPUT input) : COLOR
|
float4 ps_main(PS_INPUT input) : COLOR
|
||||||
{
|
{
|
||||||
float4 c = tex2D(Texture, input.t);
|
float4 c = tex2D(Texture, input.t);
|
||||||
return ContrastSaturationBrightness(c);
|
return ContrastSaturationBrightness(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue