mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Merge pull request #1706 from Armada651/line-width
VideoCommon: Merge LineGeometryShader into GeometryShaderGen.
This commit is contained in:
@ -13,6 +13,7 @@
|
||||
|
||||
#include "VideoCommon/Debugger.h"
|
||||
#include "VideoCommon/DriverDetails.h"
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
#include "VideoCommon/ImageWrite.h"
|
||||
#include "VideoCommon/PixelShaderManager.h"
|
||||
#include "VideoCommon/Statistics.h"
|
||||
@ -71,11 +72,14 @@ void SHADER::SetProgramVariables()
|
||||
|
||||
GLint PSBlock_id = glGetUniformBlockIndex(glprogid, "PSBlock");
|
||||
GLint VSBlock_id = glGetUniformBlockIndex(glprogid, "VSBlock");
|
||||
GLint GSBlock_id = glGetUniformBlockIndex(glprogid, "GSBlock");
|
||||
|
||||
if (PSBlock_id != -1)
|
||||
glUniformBlockBinding(glprogid, PSBlock_id, 1);
|
||||
if (VSBlock_id != -1)
|
||||
glUniformBlockBinding(glprogid, VSBlock_id, 2);
|
||||
if (GSBlock_id != -1)
|
||||
glUniformBlockBinding(glprogid, GSBlock_id, 3);
|
||||
|
||||
// Bind Texture Sampler
|
||||
for (int a = 0; a <= 9; ++a)
|
||||
@ -133,7 +137,7 @@ void SHADER::Bind()
|
||||
|
||||
void ProgramShaderCache::UploadConstants()
|
||||
{
|
||||
if (PixelShaderManager::dirty || VertexShaderManager::dirty)
|
||||
if (PixelShaderManager::dirty || VertexShaderManager::dirty || GeometryShaderManager::dirty)
|
||||
{
|
||||
auto buffer = s_buffer->Map(s_ubo_buffer_size, s_ubo_align);
|
||||
|
||||
@ -143,14 +147,20 @@ void ProgramShaderCache::UploadConstants()
|
||||
memcpy(buffer.first + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align),
|
||||
&VertexShaderManager::constants, sizeof(VertexShaderConstants));
|
||||
|
||||
memcpy(buffer.first + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align) + ROUND_UP(sizeof(VertexShaderConstants), s_ubo_align),
|
||||
&GeometryShaderManager::constants, sizeof(GeometryShaderConstants));
|
||||
|
||||
s_buffer->Unmap(s_ubo_buffer_size);
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 1, s_buffer->m_buffer, buffer.second,
|
||||
sizeof(PixelShaderConstants));
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 2, s_buffer->m_buffer, buffer.second + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align),
|
||||
sizeof(VertexShaderConstants));
|
||||
glBindBufferRange(GL_UNIFORM_BUFFER, 3, s_buffer->m_buffer, buffer.second + ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align) + ROUND_UP(sizeof(VertexShaderConstants), s_ubo_align),
|
||||
sizeof(GeometryShaderConstants));
|
||||
|
||||
PixelShaderManager::dirty = false;
|
||||
VertexShaderManager::dirty = false;
|
||||
GeometryShaderManager::dirty = false;
|
||||
|
||||
ADDSTAT(stats.thisFrame.bytesUniformStreamed, s_ubo_buffer_size);
|
||||
}
|
||||
@ -161,10 +171,10 @@ GLuint ProgramShaderCache::GetCurrentProgram()
|
||||
return CurrentProgram;
|
||||
}
|
||||
|
||||
SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||
SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type)
|
||||
{
|
||||
SHADERUID uid;
|
||||
GetShaderId(&uid, dstAlphaMode, components);
|
||||
GetShaderId(&uid, dstAlphaMode, components, primitive_type);
|
||||
|
||||
// Check if the shader is already set
|
||||
if (last_entry)
|
||||
@ -201,8 +211,8 @@ SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components
|
||||
ShaderCode gcode;
|
||||
GenerateVertexShaderCode(vcode, components, API_OPENGL);
|
||||
GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL, components);
|
||||
if (g_ActiveConfig.iStereoMode > 0)
|
||||
GenerateGeometryShaderCode(gcode, components, API_OPENGL);
|
||||
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders && !IsPassthroughGeometryShader(uid.guid))
|
||||
GenerateGeometryShaderCode(gcode, primitive_type, API_OPENGL);
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
@ -385,11 +395,11 @@ GLuint ProgramShaderCache::CompileSingleShader(GLuint type, const char* code)
|
||||
return result;
|
||||
}
|
||||
|
||||
void ProgramShaderCache::GetShaderId(SHADERUID* uid, DSTALPHA_MODE dstAlphaMode, u32 components)
|
||||
void ProgramShaderCache::GetShaderId(SHADERUID* uid, DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type)
|
||||
{
|
||||
GetPixelShaderUid(uid->puid, dstAlphaMode, API_OPENGL, components);
|
||||
GetVertexShaderUid(uid->vuid, components, API_OPENGL);
|
||||
GetGeometryShaderUid(uid->guid, components, API_OPENGL);
|
||||
GetGeometryShaderUid(uid->guid, primitive_type, API_OPENGL);
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
@ -402,7 +412,7 @@ void ProgramShaderCache::GetShaderId(SHADERUID* uid, DSTALPHA_MODE dstAlphaMode,
|
||||
vertex_uid_checker.AddToIndexAndCheck(vcode, uid->vuid, "Vertex", "v");
|
||||
|
||||
ShaderCode gcode;
|
||||
GenerateGeometryShaderCode(gcode, components, API_OPENGL);
|
||||
GenerateGeometryShaderCode(gcode, primitive_type, API_OPENGL);
|
||||
geometry_uid_checker.AddToIndexAndCheck(gcode, uid->guid, "Geometry", "g");
|
||||
}
|
||||
}
|
||||
@ -419,7 +429,7 @@ void ProgramShaderCache::Init()
|
||||
// then the UBO will fail.
|
||||
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &s_ubo_align);
|
||||
|
||||
s_ubo_buffer_size = ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align) + ROUND_UP(sizeof(VertexShaderConstants), s_ubo_align);
|
||||
s_ubo_buffer_size = ROUND_UP(sizeof(PixelShaderConstants), s_ubo_align) + ROUND_UP(sizeof(VertexShaderConstants), s_ubo_align) + ROUND_UP(sizeof(GeometryShaderConstants), s_ubo_align);
|
||||
|
||||
// We multiply by *4*4 because we need to get down to basic machine units.
|
||||
// So multiply by four to get how many floats we have from vec4s
|
||||
|
@ -88,8 +88,8 @@ public:
|
||||
|
||||
static PCacheEntry GetShaderProgram();
|
||||
static GLuint GetCurrentProgram();
|
||||
static SHADER* SetShader(DSTALPHA_MODE dstAlphaMode, u32 components);
|
||||
static void GetShaderId(SHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 components);
|
||||
static SHADER* SetShader(DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type);
|
||||
static void GetShaderId(SHADERUID *uid, DSTALPHA_MODE dstAlphaMode, u32 components, u32 primitive_type);
|
||||
|
||||
static bool CompileShader(SHADER &shader, const char* vcode, const char* pcode, const char* gcode = nullptr);
|
||||
static GLuint CompileSingleShader(GLuint type, const char *code);
|
||||
|
@ -476,6 +476,7 @@ Renderer::Renderer()
|
||||
g_Config.backend_info.bSupportsEarlyZ = GLExtensions::Supports("GL_ARB_shader_image_load_store");
|
||||
g_Config.backend_info.bSupportsBBox = GLExtensions::Supports("GL_ARB_shader_storage_buffer_object");
|
||||
g_Config.backend_info.bSupportsGSInstancing = GLExtensions::Supports("GL_ARB_gpu_shader5");
|
||||
g_Config.backend_info.bSupportsGeometryShaders = (GLExtensions::Version() >= 320);
|
||||
|
||||
// Desktop OpenGL supports the binding layout if it supports 420pack
|
||||
// OpenGL ES 3.1 supports it implicitly without an extension
|
||||
@ -498,7 +499,7 @@ Renderer::Renderer()
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSLES_300;
|
||||
g_ogl_config.bSupportsAEP = false;
|
||||
g_Config.backend_info.bSupportsStereoscopy = false;
|
||||
g_Config.backend_info.bSupportsGeometryShaders = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -506,7 +507,7 @@ Renderer::Renderer()
|
||||
g_ogl_config.bSupportsAEP = GLExtensions::Supports("GL_ANDROID_extension_pack_es31a");
|
||||
g_Config.backend_info.bSupportsBindingLayout = true;
|
||||
g_Config.backend_info.bSupportsEarlyZ = true;
|
||||
g_Config.backend_info.bSupportsStereoscopy = g_ogl_config.bSupportsAEP;
|
||||
g_Config.backend_info.bSupportsGeometryShaders = g_ogl_config.bSupportsAEP;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -522,13 +523,13 @@ Renderer::Renderer()
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_130;
|
||||
g_Config.backend_info.bSupportsEarlyZ = false; // layout keyword is only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsStereoscopy = false; // geometry shaders are only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsGeometryShaders = false; // geometry shaders are only supported on glsl150+
|
||||
}
|
||||
else if (strstr(g_ogl_config.glsl_version, "1.40"))
|
||||
{
|
||||
g_ogl_config.eSupportedGLSLVersion = GLSL_140;
|
||||
g_Config.backend_info.bSupportsEarlyZ = false; // layout keyword is only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsStereoscopy = false; // geometry shaders are only supported on glsl150+
|
||||
g_Config.backend_info.bSupportsGeometryShaders = false; // geometry shaders are only supported on glsl150+
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -565,7 +566,7 @@ Renderer::Renderer()
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
if (g_Config.iStereoMode > 0 && !g_Config.backend_info.bSupportsStereoscopy)
|
||||
if (g_Config.iStereoMode > 0 && !g_Config.backend_info.bSupportsGeometryShaders)
|
||||
OSD::AddMessage("Stereoscopic 3D isn't supported by your GPU, support for OpenGL 3.2 is required.", 10000);
|
||||
|
||||
if (!bSuccess)
|
||||
@ -881,9 +882,6 @@ void Renderer::DrawDebugInfo()
|
||||
GLsizei count = static_cast<GLsizei>(stats.efb_regions.size() * 2*6);
|
||||
glDrawArrays(GL_LINES, 0, count);
|
||||
|
||||
// Restore Line Size
|
||||
SetLineWidth();
|
||||
|
||||
// Clear stored regions
|
||||
stats.efb_regions.clear();
|
||||
}
|
||||
@ -1901,17 +1899,6 @@ void Renderer::SetDitherMode()
|
||||
glDisable(GL_DITHER);
|
||||
}
|
||||
|
||||
void Renderer::SetLineWidth()
|
||||
{
|
||||
float fratio = xfmem.viewport.wd != 0 ?
|
||||
((float)Renderer::GetTargetWidth() / EFB_WIDTH) : 1.0f;
|
||||
if (bpmem.lineptwidth.linesize > 0)
|
||||
// scale by ratio of widths
|
||||
glLineWidth((float)bpmem.lineptwidth.linesize * fratio / 6.0f);
|
||||
if (GLInterface->GetMode() == GLInterfaceMode::MODE_OPENGL && bpmem.lineptwidth.pointsize > 0)
|
||||
glPointSize((float)bpmem.lineptwidth.pointsize * fratio / 6.0f);
|
||||
}
|
||||
|
||||
void Renderer::SetSamplerState(int stage, int texindex)
|
||||
{
|
||||
auto const& tex = bpmem.tex[texindex];
|
||||
|
@ -57,7 +57,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;
|
||||
|
@ -101,9 +101,11 @@ void VertexManager::Draw(u32 stride)
|
||||
{
|
||||
case PRIMITIVE_POINTS:
|
||||
primitive_mode = GL_POINTS;
|
||||
glDisable(GL_CULL_FACE);
|
||||
break;
|
||||
case PRIMITIVE_LINES:
|
||||
primitive_mode = GL_LINES;
|
||||
glDisable(GL_CULL_FACE);
|
||||
break;
|
||||
case PRIMITIVE_TRIANGLES:
|
||||
primitive_mode = g_ActiveConfig.backend_info.bSupportsPrimitiveRestart ? GL_TRIANGLE_STRIP : GL_TRIANGLES;
|
||||
@ -120,6 +122,9 @@ void VertexManager::Draw(u32 stride)
|
||||
}
|
||||
|
||||
INCSTAT(stats.thisFrame.numDrawCalls);
|
||||
|
||||
if (current_primitive_type != PRIMITIVE_TRIANGLES)
|
||||
((OGL::Renderer*)g_renderer)->SetGenerationMode();
|
||||
}
|
||||
|
||||
void VertexManager::vFlush(bool useDstAlpha)
|
||||
@ -142,11 +147,11 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
// the same pass as regular rendering.
|
||||
if (useDstAlpha && dualSourcePossible)
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, nativeVertexFmt->m_components);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_DUAL_SOURCE_BLEND, nativeVertexFmt->m_components, current_primitive_type);
|
||||
}
|
||||
else
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_NONE, nativeVertexFmt->m_components);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_NONE, nativeVertexFmt->m_components, current_primitive_type);
|
||||
}
|
||||
|
||||
// upload global constants
|
||||
@ -160,7 +165,7 @@ void VertexManager::vFlush(bool useDstAlpha)
|
||||
// run through vertex groups again to set alpha
|
||||
if (useDstAlpha && !dualSourcePossible)
|
||||
{
|
||||
ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, nativeVertexFmt->m_components);
|
||||
ProgramShaderCache::SetShader(DSTALPHA_ALPHA_PASS, nativeVertexFmt->m_components, current_primitive_type);
|
||||
|
||||
// only update alpha
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
|
||||
|
@ -65,6 +65,7 @@ Make AA apply instantly during gameplay if possible
|
||||
#include "VideoCommon/BPStructs.h"
|
||||
#include "VideoCommon/CommandProcessor.h"
|
||||
#include "VideoCommon/Fifo.h"
|
||||
#include "VideoCommon/GeometryShaderManager.h"
|
||||
#include "VideoCommon/ImageWrite.h"
|
||||
#include "VideoCommon/IndexGenerator.h"
|
||||
#include "VideoCommon/LookUpTables.h"
|
||||
@ -138,7 +139,7 @@ static void InitBackendInfo()
|
||||
//g_Config.backend_info.bSupportsDualSourceBlend = true; // is gpu dependent and must be set in renderer
|
||||
//g_Config.backend_info.bSupportsEarlyZ = true; // is gpu dependent and must be set in renderer
|
||||
g_Config.backend_info.bSupportsOversizedViewports = true;
|
||||
g_Config.backend_info.bSupportsStereoscopy = true;
|
||||
g_Config.backend_info.bSupportsGeometryShaders = true;
|
||||
g_Config.backend_info.bSupports3DVision = false;
|
||||
|
||||
g_Config.backend_info.Adapters.clear();
|
||||
@ -202,6 +203,7 @@ void VideoBackend::Video_Prepare()
|
||||
IndexGenerator::Init();
|
||||
VertexShaderManager::Init();
|
||||
PixelShaderManager::Init();
|
||||
GeometryShaderManager::Init();
|
||||
ProgramShaderCache::Init();
|
||||
g_texture_cache = new TextureCache();
|
||||
g_sampler_cache = new SamplerCache();
|
||||
@ -243,6 +245,7 @@ void VideoBackend::Video_Cleanup()
|
||||
ProgramShaderCache::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
GeometryShaderManager::Shutdown();
|
||||
delete g_perf_query;
|
||||
g_perf_query = nullptr;
|
||||
delete g_vertex_manager;
|
||||
|
Reference in New Issue
Block a user