mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 14:19:46 -06:00
Merge pull request #1706 from Armada651/line-width
VideoCommon: Merge LineGeometryShader into GeometryShaderGen.
This commit is contained in:
@ -44,12 +44,10 @@
|
||||
<ClCompile Include="D3DUtil.cpp" />
|
||||
<ClCompile Include="FramebufferManager.cpp" />
|
||||
<ClCompile Include="GeometryShaderCache.cpp" />
|
||||
<ClCompile Include="LineGeometryShader.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="NativeVertexFormat.cpp" />
|
||||
<ClCompile Include="PerfQuery.cpp" />
|
||||
<ClCompile Include="PixelShaderCache.cpp" />
|
||||
<ClCompile Include="PointGeometryShader.cpp" />
|
||||
<ClCompile Include="PSTextureEncoder.cpp" />
|
||||
<ClCompile Include="Render.cpp" />
|
||||
<ClCompile Include="Television.cpp" />
|
||||
@ -69,11 +67,9 @@
|
||||
<ClInclude Include="FramebufferManager.h" />
|
||||
<ClInclude Include="GeometryShaderCache.h" />
|
||||
<ClInclude Include="Globals.h" />
|
||||
<ClInclude Include="LineGeometryShader.h" />
|
||||
<ClInclude Include="main.h" />
|
||||
<ClInclude Include="PerfQuery.h" />
|
||||
<ClInclude Include="PixelShaderCache.h" />
|
||||
<ClInclude Include="PointGeometryShader.h" />
|
||||
<ClInclude Include="PSTextureEncoder.h" />
|
||||
<ClInclude Include="Render.h" />
|
||||
<ClInclude Include="Television.h" />
|
||||
|
@ -33,9 +33,6 @@
|
||||
<ClCompile Include="GeometryShaderCache.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LineGeometryShader.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="NativeVertexFormat.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
@ -45,9 +42,6 @@
|
||||
<ClCompile Include="PixelShaderCache.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PointGeometryShader.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="PSTextureEncoder.cpp">
|
||||
<Filter>Render</Filter>
|
||||
</ClCompile>
|
||||
@ -99,18 +93,12 @@
|
||||
<ClInclude Include="GeometryShaderCache.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LineGeometryShader.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PerfQuery.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PixelShaderCache.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PointGeometryShader.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="PSTextureEncoder.h">
|
||||
<Filter>Render</Filter>
|
||||
</ClInclude>
|
||||
|
@ -350,6 +350,7 @@ int CD3DFont::DrawTextScaled(float x, float y, float size, float spacing, u32 dw
|
||||
|
||||
D3D::stateman->SetPixelShader(m_pshader);
|
||||
D3D::stateman->SetVertexShader(m_vshader);
|
||||
D3D::stateman->SetGeometryShader(nullptr);
|
||||
|
||||
D3D::stateman->SetInputLayout(m_InputLayout);
|
||||
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
#include "VideoCommon/Debugger.h"
|
||||
#include "VideoCommon/GeometryShaderGen.h"
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
#include "VideoCommon/Statistics.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace DX11
|
||||
@ -26,6 +28,7 @@ GeometryShaderCache::GSCache GeometryShaderCache::GeometryShaders;
|
||||
const GeometryShaderCache::GSCacheEntry* GeometryShaderCache::last_entry;
|
||||
GeometryShaderUid GeometryShaderCache::last_uid;
|
||||
UidChecker<GeometryShaderUid,ShaderCode> GeometryShaderCache::geometry_uid_checker;
|
||||
const GeometryShaderCache::GSCacheEntry GeometryShaderCache::pass_entry;
|
||||
|
||||
ID3D11GeometryShader* ClearGeometryShader = nullptr;
|
||||
ID3D11GeometryShader* CopyGeometryShader = nullptr;
|
||||
@ -37,6 +40,22 @@ ID3D11GeometryShader* GeometryShaderCache::GetCopyGeometryShader() { return Copy
|
||||
|
||||
ID3D11Buffer* gscbuf = nullptr;
|
||||
|
||||
ID3D11Buffer* &GeometryShaderCache::GetConstantBuffer()
|
||||
{
|
||||
// TODO: divide the global variables of the generated shaders into about 5 constant buffers to speed this up
|
||||
if (GeometryShaderManager::dirty)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
D3D::context->Map(gscbuf, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
memcpy(map.pData, &GeometryShaderManager::constants, sizeof(GeometryShaderConstants));
|
||||
D3D::context->Unmap(gscbuf, 0);
|
||||
GeometryShaderManager::dirty = false;
|
||||
|
||||
ADDSTAT(stats.thisFrame.bytesUniformStreamed, sizeof(GeometryShaderConstants));
|
||||
}
|
||||
return gscbuf;
|
||||
}
|
||||
|
||||
// this class will load the precompiled shaders into our cache
|
||||
class GeometryShaderCacheInserter : public LinearDiskCacheReader<GeometryShaderUid, u8>
|
||||
{
|
||||
@ -113,6 +132,12 @@ const char copy_shader_code[] = {
|
||||
|
||||
void GeometryShaderCache::Init()
|
||||
{
|
||||
unsigned int gbsize = ROUND_UP(sizeof(GeometryShaderConstants), 16); // must be a multiple of 16
|
||||
D3D11_BUFFER_DESC gbdesc = CD3D11_BUFFER_DESC(gbsize, D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
HRESULT hr = D3D::device->CreateBuffer(&gbdesc, nullptr, &gscbuf);
|
||||
CHECK(hr == S_OK, "Create geometry shader constant buffer (size=%u)", gbsize);
|
||||
D3D::SetDebugObjectName((ID3D11DeviceChild*)gscbuf, "geometry shader constant buffer used to emulate the GX pipeline");
|
||||
|
||||
// used when drawing clear quads
|
||||
ClearGeometryShader = D3D::CompileAndCreateGeometryShader(clear_shader_code);
|
||||
CHECK(ClearGeometryShader != nullptr, "Create clear geometry shader");
|
||||
@ -152,6 +177,8 @@ void GeometryShaderCache::Clear()
|
||||
|
||||
void GeometryShaderCache::Shutdown()
|
||||
{
|
||||
SAFE_RELEASE(gscbuf);
|
||||
|
||||
SAFE_RELEASE(ClearGeometryShader);
|
||||
SAFE_RELEASE(CopyGeometryShader);
|
||||
|
||||
@ -160,14 +187,14 @@ void GeometryShaderCache::Shutdown()
|
||||
g_gs_disk_cache.Close();
|
||||
}
|
||||
|
||||
bool GeometryShaderCache::SetShader(u32 components)
|
||||
bool GeometryShaderCache::SetShader(u32 primitive_type)
|
||||
{
|
||||
GeometryShaderUid uid;
|
||||
GetGeometryShaderUid(uid, components, API_D3D);
|
||||
GetGeometryShaderUid(uid, primitive_type, API_D3D);
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code;
|
||||
GenerateGeometryShaderCode(code, components, API_D3D);
|
||||
GenerateGeometryShaderCode(code, primitive_type, API_D3D);
|
||||
geometry_uid_checker.AddToIndexAndCheck(code, uid, "Geometry", "g");
|
||||
}
|
||||
|
||||
@ -177,12 +204,20 @@ bool GeometryShaderCache::SetShader(u32 components)
|
||||
if (uid == last_uid)
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE,true);
|
||||
return (last_entry->shader != nullptr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
last_uid = uid;
|
||||
|
||||
// Check if the shader is a pass-through shader
|
||||
if (IsPassthroughGeometryShader(uid))
|
||||
{
|
||||
// Return the default pass-through shader
|
||||
last_entry = &pass_entry;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if the shader is already in the cache
|
||||
GSCache::iterator iter;
|
||||
iter = GeometryShaders.find(uid);
|
||||
@ -196,7 +231,7 @@ bool GeometryShaderCache::SetShader(u32 components)
|
||||
|
||||
// Need to compile a new shader
|
||||
ShaderCode code;
|
||||
GenerateGeometryShaderCode(code, components, API_D3D);
|
||||
GenerateGeometryShaderCode(code, primitive_type, API_D3D);
|
||||
|
||||
D3DBlob* pbytecode;
|
||||
if (!D3D::CompileGeometryShader(code.GetBuffer(), &pbytecode))
|
||||
|
@ -18,13 +18,14 @@ public:
|
||||
static void Init();
|
||||
static void Clear();
|
||||
static void Shutdown();
|
||||
static bool SetShader(u32 components); // TODO: Should be renamed to LoadShader
|
||||
static bool SetShader(u32 primitive_type); // TODO: Should be renamed to LoadShader
|
||||
static bool InsertByteCode(const GeometryShaderUid &uid, const void* bytecode, unsigned int bytecodelen);
|
||||
|
||||
static ID3D11GeometryShader* GeometryShaderCache::GetClearGeometryShader();
|
||||
static ID3D11GeometryShader* GeometryShaderCache::GetCopyGeometryShader();
|
||||
|
||||
static ID3D11GeometryShader* GetActiveShader() { return last_entry->shader; }
|
||||
static ID3D11Buffer* &GetConstantBuffer();
|
||||
|
||||
private:
|
||||
struct GSCacheEntry
|
||||
@ -42,6 +43,7 @@ private:
|
||||
static GSCache GeometryShaders;
|
||||
static const GSCacheEntry* last_entry;
|
||||
static GeometryShaderUid last_uid;
|
||||
static const GSCacheEntry pass_entry;
|
||||
|
||||
static UidChecker<GeometryShaderUid, ShaderCode> geometry_uid_checker;
|
||||
};
|
||||
|
@ -1,239 +0,0 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DShader.h"
|
||||
#include "VideoBackends/D3D/D3DState.h"
|
||||
#include "VideoBackends/D3D/LineGeometryShader.h"
|
||||
#include "VideoCommon/VertexShaderGen.h"
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
|
||||
struct LineGSParams
|
||||
{
|
||||
FLOAT LineWidth; // In units of 1/6 of an EFB pixel
|
||||
FLOAT TexOffset;
|
||||
FLOAT VpWidth; // Width and height of the viewport in EFB pixels
|
||||
FLOAT VpHeight;
|
||||
FLOAT TexOffsetEnable[8]; // For each tex coordinate, whether to apply offset to it (1 on, 0 off)
|
||||
};
|
||||
|
||||
union LineGSParams_Padded
|
||||
{
|
||||
LineGSParams params;
|
||||
// Constant buffers must be a multiple of 16 bytes in size.
|
||||
u8 pad[(sizeof(LineGSParams) + 15) & ~15];
|
||||
};
|
||||
|
||||
static const char LINE_GS_COMMON[] =
|
||||
// The struct VS_OUTPUT used by the vertex shader goes here.
|
||||
"// dolphin-emu line geometry shader common part\n"
|
||||
|
||||
"cbuffer cbParams : register(b0)\n"
|
||||
"{\n"
|
||||
"struct\n" // Should match LineGSParams above
|
||||
"{\n"
|
||||
"float LineWidth;\n"
|
||||
"float TexOffset;\n"
|
||||
"float VpWidth;\n"
|
||||
"float VpHeight;\n"
|
||||
"float TexOffsetEnable[8];\n"
|
||||
"} Params;\n"
|
||||
"}\n"
|
||||
|
||||
"[maxvertexcount(4)]\n"
|
||||
"void main(line VS_OUTPUT input[2], inout TriangleStream<VS_OUTPUT> outStream)\n"
|
||||
"{\n"
|
||||
// Pretend input[0] is on the bottom and input[1] is on top.
|
||||
// We generate vertices to the left and right.
|
||||
|
||||
"VS_OUTPUT l0 = input[0];\n"
|
||||
"VS_OUTPUT r0 = l0;\n"
|
||||
"VS_OUTPUT l1 = input[1];\n"
|
||||
"VS_OUTPUT r1 = l1;\n"
|
||||
|
||||
// GameCube/Wii's line drawing algorithm is a little quirky. It does not
|
||||
// use the correct line caps. Instead, the line caps are vertical or
|
||||
// horizontal depending the slope of the line.
|
||||
|
||||
"float2 offset;\n"
|
||||
"float2 to = abs(input[1].pos.xy - input[0].pos.xy);\n"
|
||||
// FIXME: What does real hardware do when line is at a 45-degree angle?
|
||||
// FIXME: Lines aren't drawn at the correct width. See Twilight Princess map.
|
||||
"if (Params.VpHeight*to.y > Params.VpWidth*to.x) {\n"
|
||||
// Line is more tall. Extend geometry left and right.
|
||||
// Lerp Params.LineWidth/2 from [0..VpWidth] to [-1..1]
|
||||
"offset = float2(Params.LineWidth/Params.VpWidth, 0);\n"
|
||||
"} else {\n"
|
||||
// Line is more wide. Extend geometry up and down.
|
||||
// Lerp Params.LineWidth/2 from [0..VpHeight] to [1..-1]
|
||||
"offset = float2(0, -Params.LineWidth/Params.VpHeight);\n"
|
||||
"}\n"
|
||||
|
||||
"l0.pos.xy -= offset * input[0].pos.w;\n"
|
||||
"r0.pos.xy += offset * input[0].pos.w;\n"
|
||||
"l1.pos.xy -= offset * input[1].pos.w;\n"
|
||||
"r1.pos.xy += offset * input[1].pos.w;\n"
|
||||
|
||||
"#ifndef NUM_TEXCOORDS\n"
|
||||
"#error NUM_TEXCOORDS not defined\n"
|
||||
"#endif\n"
|
||||
|
||||
// Apply TexOffset to all tex coordinates in the vertex.
|
||||
// They can each be enabled separately.
|
||||
"#if NUM_TEXCOORDS >= 1\n"
|
||||
"r0.tex0.x += Params.TexOffset * Params.TexOffsetEnable[0];\n"
|
||||
"r1.tex0.x += Params.TexOffset * Params.TexOffsetEnable[0];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 2\n"
|
||||
"r0.tex1.x += Params.TexOffset * Params.TexOffsetEnable[1];\n"
|
||||
"r1.tex1.x += Params.TexOffset * Params.TexOffsetEnable[1];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 3\n"
|
||||
"r0.tex2.x += Params.TexOffset * Params.TexOffsetEnable[2];\n"
|
||||
"r1.tex2.x += Params.TexOffset * Params.TexOffsetEnable[2];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 4\n"
|
||||
"r0.tex3.x += Params.TexOffset * Params.TexOffsetEnable[3];\n"
|
||||
"r1.tex3.x += Params.TexOffset * Params.TexOffsetEnable[3];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 5\n"
|
||||
"r0.tex4.x += Params.TexOffset * Params.TexOffsetEnable[4];\n"
|
||||
"r1.tex4.x += Params.TexOffset * Params.TexOffsetEnable[4];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 6\n"
|
||||
"r0.tex5.x += Params.TexOffset * Params.TexOffsetEnable[5];\n"
|
||||
"r1.tex5.x += Params.TexOffset * Params.TexOffsetEnable[5];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 7\n"
|
||||
"r0.tex6.x += Params.TexOffset * Params.TexOffsetEnable[6];\n"
|
||||
"r1.tex6.x += Params.TexOffset * Params.TexOffsetEnable[6];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 8\n"
|
||||
"r0.tex7.x += Params.TexOffset * Params.TexOffsetEnable[7];\n"
|
||||
"r1.tex7.x += Params.TexOffset * Params.TexOffsetEnable[7];\n"
|
||||
"#endif\n"
|
||||
|
||||
"outStream.Append(l0);\n"
|
||||
"outStream.Append(r0);\n"
|
||||
"outStream.Append(l1);\n"
|
||||
"outStream.Append(r1);\n"
|
||||
"}\n"
|
||||
;
|
||||
|
||||
LineGeometryShader::LineGeometryShader()
|
||||
: m_ready(false), m_paramsBuffer(nullptr)
|
||||
{ }
|
||||
|
||||
void LineGeometryShader::Init()
|
||||
{
|
||||
m_ready = false;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
// Create constant buffer for uploading data to geometry shader
|
||||
|
||||
D3D11_BUFFER_DESC bd = CD3D11_BUFFER_DESC(sizeof(LineGSParams_Padded),
|
||||
D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
hr = D3D::device->CreateBuffer(&bd, nullptr, &m_paramsBuffer);
|
||||
CHECK(SUCCEEDED(hr), "create line geometry shader params buffer");
|
||||
D3D::SetDebugObjectName(m_paramsBuffer, "line geometry shader params buffer");
|
||||
|
||||
m_ready = true;
|
||||
}
|
||||
|
||||
void LineGeometryShader::Shutdown()
|
||||
{
|
||||
m_ready = false;
|
||||
|
||||
for (auto& it : m_shaders)
|
||||
{
|
||||
SAFE_RELEASE(it.second);
|
||||
}
|
||||
m_shaders.clear();
|
||||
|
||||
SAFE_RELEASE(m_paramsBuffer);
|
||||
}
|
||||
|
||||
bool LineGeometryShader::SetShader(u32 components, float lineWidth,
|
||||
float texOffset, float vpWidth, float vpHeight, const bool* texOffsetEnable)
|
||||
{
|
||||
if (!m_ready)
|
||||
return false;
|
||||
|
||||
// Make sure geometry shader for "components" is available
|
||||
ComboMap::iterator shaderIt = m_shaders.find(components);
|
||||
if (shaderIt == m_shaders.end())
|
||||
{
|
||||
// Generate new shader. Warning: not thread-safe.
|
||||
static char buffer[16384];
|
||||
ShaderCode code;
|
||||
code.SetBuffer(buffer);
|
||||
GenerateVSOutputStruct<ShaderCode>(code, API_D3D);
|
||||
code.Write("\n%s", LINE_GS_COMMON);
|
||||
|
||||
std::stringstream numTexCoordsStream;
|
||||
numTexCoordsStream << xfmem.numTexGen.numTexGens;
|
||||
|
||||
INFO_LOG(VIDEO, "Compiling line geometry shader for components 0x%.08X (num texcoords %d)",
|
||||
components, xfmem.numTexGen.numTexGens);
|
||||
|
||||
const std::string& numTexCoordsStr = numTexCoordsStream.str();
|
||||
D3D_SHADER_MACRO macros[] = {
|
||||
{ "NUM_TEXCOORDS", numTexCoordsStr.c_str() },
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
ID3D11GeometryShader* newShader = D3D::CompileAndCreateGeometryShader(code.GetBuffer(), macros);
|
||||
if (!newShader)
|
||||
{
|
||||
WARN_LOG(VIDEO, "Line geometry shader for components 0x%.08X failed to compile", components);
|
||||
// Add dummy shader to prevent trying to compile again
|
||||
m_shaders[components] = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
shaderIt = m_shaders.insert(std::make_pair(components, newShader)).first;
|
||||
}
|
||||
|
||||
if (shaderIt != m_shaders.end())
|
||||
{
|
||||
if (shaderIt->second)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
HRESULT hr = D3D::context->Map(m_paramsBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
LineGSParams* params = (LineGSParams*)map.pData;
|
||||
params->LineWidth = lineWidth;
|
||||
|
||||
params->TexOffset = texOffset;
|
||||
params->VpWidth = vpWidth;
|
||||
params->VpHeight = vpHeight;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
params->TexOffsetEnable[i] = texOffsetEnable[i] ? 1.f : 0.f;
|
||||
|
||||
D3D::context->Unmap(m_paramsBuffer, 0);
|
||||
}
|
||||
else
|
||||
ERROR_LOG(VIDEO, "Failed to map line gs params buffer");
|
||||
|
||||
DEBUG_LOG(VIDEO, "Line params: width %f, texOffset %f, vpWidth %f, vpHeight %f",
|
||||
lineWidth, texOffset, vpWidth, vpHeight);
|
||||
|
||||
D3D::stateman->SetGeometryShader(shaderIt->second);
|
||||
D3D::stateman->SetGeometryConstants(m_paramsBuffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
|
||||
struct ID3D11Buffer;
|
||||
struct ID3D11GeometryShader;
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
|
||||
// This class manages a collection of line geometry shaders, one for each
|
||||
// vertex format.
|
||||
class LineGeometryShader
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
LineGeometryShader();
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
// Returns true on success, false on failure
|
||||
bool SetShader(u32 components, float lineWidth, float texOffset,
|
||||
float vpWidth, float vpHeight, const bool* texOffsetEnable);
|
||||
|
||||
private:
|
||||
|
||||
bool m_ready;
|
||||
|
||||
ID3D11Buffer* m_paramsBuffer;
|
||||
|
||||
typedef std::map<u32, ID3D11GeometryShader*> ComboMap;
|
||||
|
||||
ComboMap m_shaders;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1084,6 +1084,7 @@ size_t PSTextureEncoder::Encode(u8* dst, unsigned int dstFormat,
|
||||
#endif
|
||||
{
|
||||
D3D::stateman->SetVertexShader(m_vShader);
|
||||
D3D::stateman->SetGeometryShader(nullptr);
|
||||
|
||||
D3D::stateman->PushBlendState(m_efbEncodeBlendState);
|
||||
D3D::stateman->PushDepthState(m_efbEncodeDepthState);
|
||||
|
@ -432,7 +432,7 @@ public:
|
||||
|
||||
void PixelShaderCache::Init()
|
||||
{
|
||||
unsigned int cbsize = ((sizeof(PixelShaderConstants))&(~0xf))+0x10; // must be a multiple of 16
|
||||
unsigned int cbsize = ROUND_UP(sizeof(PixelShaderConstants), 16); // must be a multiple of 16
|
||||
D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(cbsize, D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
D3D::device->CreateBuffer(&cbdesc, nullptr, &pscbuf);
|
||||
CHECK(pscbuf!=nullptr, "Create pixel shader constant buffer");
|
||||
|
@ -1,233 +0,0 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DShader.h"
|
||||
#include "VideoBackends/D3D/D3DState.h"
|
||||
#include "VideoBackends/D3D/PointGeometryShader.h"
|
||||
#include "VideoCommon/VertexShaderGen.h"
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
|
||||
struct PointGSParams
|
||||
{
|
||||
FLOAT PointSize; // In units of 1/6 of an EFB pixel
|
||||
FLOAT TexOffset;
|
||||
FLOAT VpWidth; // Width and height of viewport in EFB pixels
|
||||
FLOAT VpHeight;
|
||||
FLOAT TexOffsetEnable[8]; // For each tex coordinate, whether to apply offset to it (1 on, 0 off)
|
||||
};
|
||||
|
||||
union PointGSParams_Padded
|
||||
{
|
||||
PointGSParams params;
|
||||
// Constant buffers must be a multiple of 16 bytes in size.
|
||||
u8 pad[(sizeof(PointGSParams) + 15) & ~15];
|
||||
};
|
||||
|
||||
static const char POINT_GS_COMMON[] =
|
||||
// The struct VS_OUTPUT used by the vertex shader goes here.
|
||||
"// dolphin-emu point geometry shader common part\n"
|
||||
|
||||
"cbuffer cbParams : register(b0)\n"
|
||||
"{\n"
|
||||
"struct\n" // Should match PointGSParams above
|
||||
"{\n"
|
||||
"float PointSize;\n"
|
||||
"float TexOffset;\n"
|
||||
"float VpWidth;\n"
|
||||
"float VpHeight;\n"
|
||||
"float TexOffsetEnable[8];\n"
|
||||
"} Params;\n"
|
||||
"}\n"
|
||||
|
||||
"[maxvertexcount(4)]\n"
|
||||
"void main(point VS_OUTPUT input[1], inout TriangleStream<VS_OUTPUT> outStream)\n"
|
||||
"{\n"
|
||||
"VS_OUTPUT ptLL = input[0];\n"
|
||||
"VS_OUTPUT ptLR = ptLL;\n"
|
||||
"VS_OUTPUT ptUL = ptLL;\n"
|
||||
"VS_OUTPUT ptUR = ptLL;\n"
|
||||
|
||||
// Offset from center to upper right vertex
|
||||
// Lerp Params.PointSize/2 from [0,0..VpWidth,VpHeight] to [-1,1..1,-1]
|
||||
"float2 offset = float2(Params.PointSize/Params.VpWidth, -Params.PointSize/Params.VpHeight) * input[0].pos.w;\n"
|
||||
|
||||
"ptLL.pos.xy += float2(-1,-1) * offset;\n"
|
||||
"ptLR.pos.xy += float2(1,-1) * offset;\n"
|
||||
"ptUL.pos.xy += float2(-1,1) * offset;\n"
|
||||
"ptUR.pos.xy += offset;\n"
|
||||
|
||||
"float2 texOffset = float2(Params.TexOffset, Params.TexOffset);\n"
|
||||
|
||||
"#ifndef NUM_TEXCOORDS\n"
|
||||
"#error NUM_TEXCOORDS not defined\n"
|
||||
"#endif\n"
|
||||
|
||||
// Apply TexOffset to all tex coordinates in the vertex
|
||||
// FIXME: The game may be able to enable TexOffset for some coords and
|
||||
// disable for others, but where is that information stored?
|
||||
"#if NUM_TEXCOORDS >= 1\n"
|
||||
"ptLL.tex0.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[0];\n"
|
||||
"ptLR.tex0.xy += texOffset * Params.TexOffsetEnable[0];\n"
|
||||
"ptUR.tex0.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[0];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 2\n"
|
||||
"ptLL.tex1.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[1];\n"
|
||||
"ptLR.tex1.xy += texOffset * Params.TexOffsetEnable[1];\n"
|
||||
"ptUR.tex1.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[1];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 3\n"
|
||||
"ptLL.tex2.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[2];\n"
|
||||
"ptLR.tex2.xy += texOffset * Params.TexOffsetEnable[2];\n"
|
||||
"ptUR.tex2.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[2];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 4\n"
|
||||
"ptLL.tex3.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[3];\n"
|
||||
"ptLR.tex3.xy += texOffset * Params.TexOffsetEnable[3];\n"
|
||||
"ptUR.tex3.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[3];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 5\n"
|
||||
"ptLL.tex4.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[4];\n"
|
||||
"ptLR.tex4.xy += texOffset * Params.TexOffsetEnable[4];\n"
|
||||
"ptUR.tex4.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[4];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 6\n"
|
||||
"ptLL.tex5.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[5];\n"
|
||||
"ptLR.tex5.xy += texOffset * Params.TexOffsetEnable[5];\n"
|
||||
"ptUR.tex5.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[5];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 7\n"
|
||||
"ptLL.tex6.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[6];\n"
|
||||
"ptLR.tex6.xy += texOffset * Params.TexOffsetEnable[6];\n"
|
||||
"ptUR.tex6.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[6];\n"
|
||||
"#endif\n"
|
||||
"#if NUM_TEXCOORDS >= 8\n"
|
||||
"ptLL.tex7.xy += float2(0,1) * texOffset * Params.TexOffsetEnable[7];\n"
|
||||
"ptLR.tex7.xy += texOffset * Params.TexOffsetEnable[7];\n"
|
||||
"ptUR.tex7.xy += float2(1,0) * texOffset * Params.TexOffsetEnable[7];\n"
|
||||
"#endif\n"
|
||||
|
||||
"outStream.Append(ptLL);\n"
|
||||
"outStream.Append(ptLR);\n"
|
||||
"outStream.Append(ptUL);\n"
|
||||
"outStream.Append(ptUR);\n"
|
||||
"}\n"
|
||||
;
|
||||
|
||||
PointGeometryShader::PointGeometryShader()
|
||||
: m_ready(false), m_paramsBuffer(nullptr)
|
||||
{ }
|
||||
|
||||
void PointGeometryShader::Init()
|
||||
{
|
||||
m_ready = false;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
// Create constant buffer for uploading data to geometry shader
|
||||
|
||||
D3D11_BUFFER_DESC bd = CD3D11_BUFFER_DESC(sizeof(PointGSParams_Padded),
|
||||
D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
hr = D3D::device->CreateBuffer(&bd, nullptr, &m_paramsBuffer);
|
||||
CHECK(SUCCEEDED(hr), "create point geometry shader params buffer");
|
||||
D3D::SetDebugObjectName(m_paramsBuffer, "point geometry shader params buffer");
|
||||
|
||||
m_ready = true;
|
||||
}
|
||||
|
||||
void PointGeometryShader::Shutdown()
|
||||
{
|
||||
m_ready = false;
|
||||
|
||||
for (auto& it : m_shaders)
|
||||
{
|
||||
SAFE_RELEASE(it.second);
|
||||
}
|
||||
m_shaders.clear();
|
||||
|
||||
SAFE_RELEASE(m_paramsBuffer);
|
||||
}
|
||||
|
||||
bool PointGeometryShader::SetShader(u32 components, float pointSize,
|
||||
float texOffset, float vpWidth, float vpHeight, const bool* texOffsetEnable)
|
||||
{
|
||||
if (!m_ready)
|
||||
return false;
|
||||
|
||||
// Make sure geometry shader for "components" is available
|
||||
ComboMap::iterator shaderIt = m_shaders.find(components);
|
||||
if (shaderIt == m_shaders.end())
|
||||
{
|
||||
// Generate new shader. Warning: not thread-safe.
|
||||
static char buffer[16384];
|
||||
ShaderCode code;
|
||||
code.SetBuffer(buffer);
|
||||
GenerateVSOutputStruct<ShaderCode>(code, API_D3D);
|
||||
code.Write("\n%s", POINT_GS_COMMON);
|
||||
|
||||
std::stringstream numTexCoordsStream;
|
||||
numTexCoordsStream << xfmem.numTexGen.numTexGens;
|
||||
|
||||
INFO_LOG(VIDEO, "Compiling point geometry shader for components 0x%.08X (num texcoords %d)",
|
||||
components, xfmem.numTexGen.numTexGens);
|
||||
|
||||
const std::string& numTexCoordsStr = numTexCoordsStream.str();
|
||||
D3D_SHADER_MACRO macros[] = {
|
||||
{ "NUM_TEXCOORDS", numTexCoordsStr.c_str() },
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
ID3D11GeometryShader* newShader = D3D::CompileAndCreateGeometryShader(code.GetBuffer(), macros);
|
||||
if (!newShader)
|
||||
{
|
||||
WARN_LOG(VIDEO, "Point geometry shader for components 0x%.08X failed to compile", components);
|
||||
// Add dummy shader to prevent trying to compile again
|
||||
m_shaders[components] = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
shaderIt = m_shaders.insert(std::make_pair(components, newShader)).first;
|
||||
}
|
||||
|
||||
if (shaderIt != m_shaders.end())
|
||||
{
|
||||
if (shaderIt->second)
|
||||
{
|
||||
D3D11_MAPPED_SUBRESOURCE map;
|
||||
HRESULT hr = D3D::context->Map(m_paramsBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map);
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
PointGSParams* params = (PointGSParams*)map.pData;
|
||||
params->PointSize = pointSize;
|
||||
|
||||
params->TexOffset = texOffset;
|
||||
params->VpWidth = vpWidth;
|
||||
params->VpHeight = vpHeight;
|
||||
for (int i = 0; i < 8; ++i)
|
||||
params->TexOffsetEnable[i] = texOffsetEnable[i] ? 1.f : 0.f;
|
||||
|
||||
D3D::context->Unmap(m_paramsBuffer, 0);
|
||||
}
|
||||
else
|
||||
ERROR_LOG(VIDEO, "Failed to map point gs params buffer");
|
||||
|
||||
DEBUG_LOG(VIDEO, "Point params: size %f, texOffset %f, vpWidth %f, vpHeight %f",
|
||||
pointSize, texOffset, vpWidth, vpHeight);
|
||||
|
||||
D3D::stateman->SetGeometryShader(shaderIt->second);
|
||||
D3D::stateman->SetGeometryConstants(m_paramsBuffer);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
|
||||
struct ID3D11Buffer;
|
||||
struct ID3D11GeometryShader;
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
|
||||
// This class manages a collection of point geometry shaders, one for each
|
||||
// vertex format.
|
||||
class PointGeometryShader
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
PointGeometryShader();
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
// Returns true on success, false on failure
|
||||
bool SetShader(u32 components, float pointSize, float texOffset,
|
||||
float vpWidth, float vpHeight, const bool* texOffsetEnable);
|
||||
|
||||
private:
|
||||
|
||||
bool m_ready;
|
||||
|
||||
ID3D11Buffer* m_paramsBuffer;
|
||||
|
||||
typedef std::map<u32, ID3D11GeometryShader*> ComboMap;
|
||||
|
||||
ComboMap m_shaders;
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -1105,13 +1105,14 @@ void Renderer::ApplyState(bool bUseDstAlpha)
|
||||
}
|
||||
|
||||
ID3D11Buffer* vertexConstants = VertexShaderCache::GetConstantBuffer();
|
||||
ID3D11Buffer* pixelConstants = PixelShaderCache::GetConstantBuffer();
|
||||
|
||||
D3D::stateman->SetPixelConstants(pixelConstants, g_ActiveConfig.bEnablePixelLighting ? vertexConstants : nullptr);
|
||||
D3D::stateman->SetPixelConstants(PixelShaderCache::GetConstantBuffer(), g_ActiveConfig.bEnablePixelLighting ? vertexConstants : nullptr);
|
||||
D3D::stateman->SetVertexConstants(vertexConstants);
|
||||
D3D::stateman->SetGeometryConstants(GeometryShaderCache::GetConstantBuffer());
|
||||
|
||||
D3D::stateman->SetPixelShader(PixelShaderCache::GetActiveShader());
|
||||
D3D::stateman->SetVertexShader(VertexShaderCache::GetActiveShader());
|
||||
D3D::stateman->SetGeometryShader(GeometryShaderCache::GetActiveShader());
|
||||
}
|
||||
|
||||
void Renderer::RestoreState()
|
||||
@ -1252,11 +1253,6 @@ void Renderer::SetDitherMode()
|
||||
// TODO: Set dither mode to bpmem.blendmode.dither
|
||||
}
|
||||
|
||||
void Renderer::SetLineWidth()
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Renderer::SetSamplerState(int stage, int texindex)
|
||||
{
|
||||
const FourTexUnits &tex = bpmem.tex[texindex];
|
||||
|
@ -19,7 +19,6 @@ public:
|
||||
void SetDepthMode() override;
|
||||
void SetLogicOpMode() override;
|
||||
void SetDitherMode() override;
|
||||
void SetLineWidth() override;
|
||||
void SetSamplerState(int stage,int texindex) override;
|
||||
void SetInterlacingMode() override;
|
||||
void SetViewport() override;
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "VideoBackends/D3D/VertexShaderCache.h"
|
||||
|
||||
#include "VideoCommon/BoundingBox.h"
|
||||
#include "VideoCommon/BPMemory.h"
|
||||
#include "VideoCommon/Debugger.h"
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/MainBase.h"
|
||||
@ -49,16 +48,10 @@ void VertexManager::CreateDeviceObjects()
|
||||
|
||||
m_currentBuffer = 0;
|
||||
m_bufferCursor = MAX_BUFFER_SIZE;
|
||||
|
||||
m_lineShader.Init();
|
||||
m_pointShader.Init();
|
||||
}
|
||||
|
||||
void VertexManager::DestroyDeviceObjects()
|
||||
{
|
||||
m_pointShader.Shutdown();
|
||||
m_lineShader.Shutdown();
|
||||
|
||||
for (int i = 0; i < MAX_BUFFER_COUNT; i++)
|
||||
{
|
||||
SAFE_RELEASE(m_buffers[i]);
|
||||
@ -122,10 +115,6 @@ void VertexManager::PrepareDrawBuffers(u32 stride)
|
||||
ADDSTAT(stats.thisFrame.bytesIndexStreamed, indexBufferSize);
|
||||
}
|
||||
|
||||
static const float LINE_PT_TEX_OFFSETS[8] = {
|
||||
0.f, 0.0625f, 0.125f, 0.25f, 0.5f, 1.f, 1.f, 1.f
|
||||
};
|
||||
|
||||
void VertexManager::Draw(u32 stride)
|
||||
{
|
||||
u32 components = VertexLoaderManager::GetCurrentVertexFormat()->m_components;
|
||||
@ -137,69 +126,28 @@ void VertexManager::Draw(u32 stride)
|
||||
u32 baseVertex = m_vertexDrawOffset / stride;
|
||||
u32 startIndex = m_indexDrawOffset / sizeof(u16);
|
||||
|
||||
if (current_primitive_type == PRIMITIVE_TRIANGLES)
|
||||
switch (current_primitive_type)
|
||||
{
|
||||
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||
D3D::stateman->SetGeometryConstants(VertexShaderCache::GetConstantBuffer());
|
||||
D3D::stateman->SetGeometryShader(g_ActiveConfig.iStereoMode > 0 ? GeometryShaderCache::GetActiveShader() : nullptr);
|
||||
|
||||
D3D::stateman->Apply();
|
||||
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
|
||||
|
||||
INCSTAT(stats.thisFrame.numDrawCalls);
|
||||
|
||||
D3D::stateman->SetGeometryShader(nullptr);
|
||||
}
|
||||
else if (current_primitive_type == PRIMITIVE_LINES)
|
||||
{
|
||||
float lineWidth = float(bpmem.lineptwidth.linesize) / 6.f;
|
||||
float texOffset = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.lineoff];
|
||||
float vpWidth = 2.0f * xfmem.viewport.wd;
|
||||
float vpHeight = -2.0f * xfmem.viewport.ht;
|
||||
|
||||
bool texOffsetEnable[8];
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
texOffsetEnable[i] = bpmem.texcoords[i].s.line_offset;
|
||||
|
||||
if (m_lineShader.SetShader(components, lineWidth,
|
||||
texOffset, vpWidth, vpHeight, texOffsetEnable))
|
||||
{
|
||||
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
|
||||
|
||||
D3D::stateman->Apply();
|
||||
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
|
||||
|
||||
INCSTAT(stats.thisFrame.numDrawCalls);
|
||||
|
||||
D3D::stateman->SetGeometryShader(nullptr);
|
||||
}
|
||||
}
|
||||
else //if (current_primitive_type == PRIMITIVE_POINTS)
|
||||
{
|
||||
float pointSize = float(bpmem.lineptwidth.pointsize) / 6.f;
|
||||
float texOffset = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.pointoff];
|
||||
float vpWidth = 2.0f * xfmem.viewport.wd;
|
||||
float vpHeight = -2.0f * xfmem.viewport.ht;
|
||||
|
||||
bool texOffsetEnable[8];
|
||||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
texOffsetEnable[i] = bpmem.texcoords[i].s.point_offset;
|
||||
|
||||
if (m_pointShader.SetShader(components, pointSize,
|
||||
texOffset, vpWidth, vpHeight, texOffsetEnable))
|
||||
{
|
||||
case PRIMITIVE_POINTS:
|
||||
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST);
|
||||
|
||||
D3D::stateman->Apply();
|
||||
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
|
||||
|
||||
INCSTAT(stats.thisFrame.numDrawCalls);
|
||||
|
||||
D3D::stateman->SetGeometryShader(nullptr);
|
||||
}
|
||||
((DX11::Renderer*)g_renderer)->ApplyCullDisable();
|
||||
break;
|
||||
case PRIMITIVE_LINES:
|
||||
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_LINELIST);
|
||||
((DX11::Renderer*)g_renderer)->ApplyCullDisable();
|
||||
break;
|
||||
case PRIMITIVE_TRIANGLES:
|
||||
D3D::stateman->SetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP);
|
||||
break;
|
||||
}
|
||||
|
||||
D3D::stateman->Apply();
|
||||
D3D::context->DrawIndexed(indices, startIndex, baseVertex);
|
||||
|
||||
INCSTAT(stats.thisFrame.numDrawCalls);
|
||||
|
||||
if (current_primitive_type != PRIMITIVE_TRIANGLES)
|
||||
((DX11::Renderer*)g_renderer)->RestoreCull();
|
||||
}
|
||||
|
||||
void VertexManager::vFlush(bool useDstAlpha)
|
||||
@ -219,13 +167,10 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
if (!GeometryShaderCache::SetShader(current_primitive_type))
|
||||
{
|
||||
if (!GeometryShaderCache::SetShader(components))
|
||||
{
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR, true, { printf("Fail to set pixel shader\n"); });
|
||||
return;
|
||||
}
|
||||
GFX_DEBUGGER_PAUSE_LOG_AT(NEXT_ERROR, true, { printf("Fail to set pixel shader\n"); });
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_ActiveConfig.backend_info.bSupportsBBox && BoundingBox::active)
|
||||
|
@ -4,8 +4,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "VideoBackends/D3D/LineGeometryShader.h"
|
||||
#include "VideoBackends/D3D/PointGeometryShader.h"
|
||||
#include "VideoCommon/VertexManagerBase.h"
|
||||
|
||||
namespace DX11
|
||||
@ -40,9 +38,6 @@ private:
|
||||
enum { MAX_BUFFER_COUNT = 2 };
|
||||
ID3D11Buffer* m_buffers[MAX_BUFFER_COUNT];
|
||||
|
||||
LineGeometryShader m_lineShader;
|
||||
PointGeometryShader m_pointShader;
|
||||
|
||||
std::vector<u8> LocalVBuffer;
|
||||
std::vector<u16> LocalIBuffer;
|
||||
};
|
||||
|
@ -115,7 +115,7 @@ void VertexShaderCache::Init()
|
||||
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
};
|
||||
|
||||
unsigned int cbsize = ((sizeof(VertexShaderConstants))&(~0xf))+0x10; // must be a multiple of 16
|
||||
unsigned int cbsize = ROUND_UP(sizeof(VertexShaderConstants), 16); // must be a multiple of 16
|
||||
D3D11_BUFFER_DESC cbdesc = CD3D11_BUFFER_DESC(cbsize, D3D11_BIND_CONSTANT_BUFFER, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE);
|
||||
HRESULT hr = D3D::device->CreateBuffer(&cbdesc, nullptr, &vscbuf);
|
||||
CHECK(hr==S_OK, "Create vertex shader constant buffer (size=%u)", cbsize);
|
||||
|
@ -282,6 +282,7 @@ void XFBEncoder::Encode(u8* dst, u32 width, u32 height, const EFBRectangle& srcR
|
||||
|
||||
D3D::stateman->SetPixelShader(m_pShader);
|
||||
D3D::stateman->SetVertexShader(m_vShader);
|
||||
D3D::stateman->SetGeometryShader(nullptr);
|
||||
|
||||
D3D::stateman->PushBlendState(m_xfbEncodeBlendState);
|
||||
D3D::stateman->PushDepthState(m_xfbEncodeDepthState);
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "VideoCommon/BPStructs.h"
|
||||
#include "VideoCommon/CommandProcessor.h"
|
||||
#include "VideoCommon/Fifo.h"
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
#include "VideoCommon/OpcodeDecoding.h"
|
||||
@ -79,7 +80,7 @@ void InitBackendInfo()
|
||||
g_Config.backend_info.bSupportsDualSourceBlend = true;
|
||||
g_Config.backend_info.bSupportsPrimitiveRestart = true;
|
||||
g_Config.backend_info.bSupportsOversizedViewports = false;
|
||||
g_Config.backend_info.bSupportsStereoscopy = true;
|
||||
g_Config.backend_info.bSupportsGeometryShaders = true;
|
||||
g_Config.backend_info.bSupports3DVision = true;
|
||||
|
||||
IDXGIFactory* factory;
|
||||
@ -187,6 +188,7 @@ void VideoBackend::Video_Prepare()
|
||||
OpcodeDecoder_Init();
|
||||
VertexShaderManager::Init();
|
||||
PixelShaderManager::Init();
|
||||
GeometryShaderManager::Init();
|
||||
CommandProcessor::Init();
|
||||
PixelEngine::Init();
|
||||
BBox::Init();
|
||||
@ -205,6 +207,7 @@ void VideoBackend::Shutdown()
|
||||
// VideoCommon
|
||||
Fifo_Shutdown();
|
||||
CommandProcessor::Shutdown();
|
||||
GeometryShaderManager::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
OpcodeDecoder_Shutdown();
|
||||
|
Reference in New Issue
Block a user