GeometryShaderManager: Upload Line/Point width constants.
This commit is contained in:
parent
aa4242fd9c
commit
332ba4b210
|
@ -130,6 +130,7 @@ static void BPWritten(const BPCmd& bp)
|
||||||
return;
|
return;
|
||||||
case BPMEM_LINEPTWIDTH: // Line Width
|
case BPMEM_LINEPTWIDTH: // Line Width
|
||||||
SetLineWidth();
|
SetLineWidth();
|
||||||
|
GeometryShaderManager::SetLinePtWidthChanged();
|
||||||
return;
|
return;
|
||||||
case BPMEM_ZMODE: // Depth Control
|
case BPMEM_ZMODE: // Depth Control
|
||||||
PRIM_LOG("zmode: test=%d, func=%d, upd=%d", (int)bpmem.zmode.testenable,
|
PRIM_LOG("zmode: test=%d, func=%d, upd=%d", (int)bpmem.zmode.testenable,
|
||||||
|
@ -572,7 +573,10 @@ static void BPWritten(const BPCmd& bp)
|
||||||
case BPMEM_SU_SSIZE+14:
|
case BPMEM_SU_SSIZE+14:
|
||||||
case BPMEM_SU_TSIZE+14:
|
case BPMEM_SU_TSIZE+14:
|
||||||
if (bp.changes)
|
if (bp.changes)
|
||||||
|
{
|
||||||
PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
|
PixelShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
|
||||||
|
GeometryShaderManager::SetTexCoordChanged((bp.address - BPMEM_SU_SSIZE) >> 1);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
// ------------------------
|
// ------------------------
|
||||||
// BPMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS, DiagLoad, Min Filter, Mag Filter, Wrap T, S
|
// BPMEM_TX_SETMODE0 - (Texture lookup and filtering mode) LOD/BIAS Clamp, MaxAnsio, LODBIAS, DiagLoad, Min Filter, Mag Filter, Wrap T, S
|
||||||
|
|
|
@ -48,4 +48,7 @@ struct VertexShaderConstants
|
||||||
struct GeometryShaderConstants
|
struct GeometryShaderConstants
|
||||||
{
|
{
|
||||||
float4 stereoparams;
|
float4 stereoparams;
|
||||||
|
float4 lineptwidth;
|
||||||
|
float4 viewport;
|
||||||
|
u32 texoffsetflags[8];
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,9 +47,12 @@ static inline void GenerateGeometryShader(T& out, u32 primitive_type, API_TYPE A
|
||||||
out.Write("cbuffer GSBlock {\n");
|
out.Write("cbuffer GSBlock {\n");
|
||||||
out.Write(
|
out.Write(
|
||||||
"\tfloat4 " I_STEREOPARAMS";\n"
|
"\tfloat4 " I_STEREOPARAMS";\n"
|
||||||
|
"\tfloat4 " I_LINEPTWIDTH";\n"
|
||||||
|
"\tfloat4 " I_VIEWPORT";\n"
|
||||||
|
"\tuint " I_TEXOFFSETFLAGS"[8];\n"
|
||||||
"};\n");
|
"};\n");
|
||||||
|
|
||||||
uid_data->numTexGens = xfmem.numTexGen.numTexGens;
|
uid_data->numTexGens = bpmem.genMode.numtexgens;
|
||||||
uid_data->pixel_lighting = g_ActiveConfig.bEnablePixelLighting;
|
uid_data->pixel_lighting = g_ActiveConfig.bEnablePixelLighting;
|
||||||
|
|
||||||
GenerateVSOutputStruct<T>(out, ApiType);
|
GenerateVSOutputStruct<T>(out, ApiType);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "VideoCommon/BPMemory.h"
|
||||||
#include "VideoCommon/GeometryShaderGen.h"
|
#include "VideoCommon/GeometryShaderGen.h"
|
||||||
#include "VideoCommon/GeometryShaderManager.h"
|
#include "VideoCommon/GeometryShaderManager.h"
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
@ -12,7 +13,11 @@
|
||||||
#include "VideoCommon/XFMemory.h"
|
#include "VideoCommon/XFMemory.h"
|
||||||
|
|
||||||
// track changes
|
// track changes
|
||||||
static bool s_projection_changed, s_viewport_changed;
|
static bool s_projection_changed, s_viewport_changed, s_lineptwidth_changed;
|
||||||
|
|
||||||
|
static const float LINE_PT_TEX_OFFSETS[8] = {
|
||||||
|
0.f, 0.0625f, 0.125f, 0.25f, 0.5f, 1.f, 1.f, 1.f
|
||||||
|
};
|
||||||
|
|
||||||
GeometryShaderConstants GeometryShaderManager::constants;
|
GeometryShaderConstants GeometryShaderManager::constants;
|
||||||
bool GeometryShaderManager::dirty;
|
bool GeometryShaderManager::dirty;
|
||||||
|
@ -32,6 +37,16 @@ void GeometryShaderManager::Dirty()
|
||||||
{
|
{
|
||||||
s_projection_changed = true;
|
s_projection_changed = true;
|
||||||
s_viewport_changed = true;
|
s_viewport_changed = true;
|
||||||
|
s_lineptwidth_changed = true;
|
||||||
|
|
||||||
|
SetTexCoordChanged(0);
|
||||||
|
SetTexCoordChanged(1);
|
||||||
|
SetTexCoordChanged(2);
|
||||||
|
SetTexCoordChanged(3);
|
||||||
|
SetTexCoordChanged(4);
|
||||||
|
SetTexCoordChanged(5);
|
||||||
|
SetTexCoordChanged(6);
|
||||||
|
SetTexCoordChanged(7);
|
||||||
|
|
||||||
dirty = true;
|
dirty = true;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +54,20 @@ void GeometryShaderManager::Dirty()
|
||||||
// Syncs the shader constant buffers with xfmem
|
// Syncs the shader constant buffers with xfmem
|
||||||
void GeometryShaderManager::SetConstants()
|
void GeometryShaderManager::SetConstants()
|
||||||
{
|
{
|
||||||
|
if (s_lineptwidth_changed)
|
||||||
|
{
|
||||||
|
constants.lineptwidth[0] = bpmem.lineptwidth.linesize / 6.f;
|
||||||
|
constants.lineptwidth[1] = bpmem.lineptwidth.pointsize / 6.f;
|
||||||
|
constants.lineptwidth[2] = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.lineoff];
|
||||||
|
constants.lineptwidth[3] = LINE_PT_TEX_OFFSETS[bpmem.lineptwidth.pointoff];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s_viewport_changed)
|
||||||
|
{
|
||||||
|
constants.viewport[0] = 2.0f * xfmem.viewport.wd;
|
||||||
|
constants.viewport[1] = -2.0f * xfmem.viewport.ht;
|
||||||
|
}
|
||||||
|
|
||||||
if (s_projection_changed)
|
if (s_projection_changed)
|
||||||
{
|
{
|
||||||
s_projection_changed = false;
|
s_projection_changed = false;
|
||||||
|
@ -69,6 +98,18 @@ void GeometryShaderManager::SetProjectionChanged()
|
||||||
s_projection_changed = true;
|
s_projection_changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GeometryShaderManager::SetLinePtWidthChanged()
|
||||||
|
{
|
||||||
|
s_lineptwidth_changed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GeometryShaderManager::SetTexCoordChanged(u8 texmapid)
|
||||||
|
{
|
||||||
|
TCoordInfo& tc = bpmem.texcoords[texmapid];
|
||||||
|
constants.texoffsetflags[texmapid] = tc.s.line_offset + tc.s.point_offset * 2;
|
||||||
|
dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
void GeometryShaderManager::DoState(PointerWrap &p)
|
void GeometryShaderManager::DoState(PointerWrap &p)
|
||||||
{
|
{
|
||||||
p.Do(dirty);
|
p.Do(dirty);
|
||||||
|
|
|
@ -23,6 +23,8 @@ public:
|
||||||
|
|
||||||
static void SetViewportChanged();
|
static void SetViewportChanged();
|
||||||
static void SetProjectionChanged();
|
static void SetProjectionChanged();
|
||||||
|
static void SetLinePtWidthChanged();
|
||||||
|
static void SetTexCoordChanged(u8 texmapid);
|
||||||
|
|
||||||
static GeometryShaderConstants constants;
|
static GeometryShaderConstants constants;
|
||||||
static bool dirty;
|
static bool dirty;
|
||||||
|
|
|
@ -280,7 +280,10 @@ static inline void GenerateVSOutputStruct(T& object, API_TYPE api_type)
|
||||||
#define I_POSTTRANSFORMMATRICES "cpostmtx"
|
#define I_POSTTRANSFORMMATRICES "cpostmtx"
|
||||||
#define I_PIXELCENTERCORRECTION "cpixelcenter"
|
#define I_PIXELCENTERCORRECTION "cpixelcenter"
|
||||||
|
|
||||||
#define I_STEREOPARAMS "cstereo"
|
#define I_STEREOPARAMS "cstereo"
|
||||||
|
#define I_LINEPTWIDTH "clinept"
|
||||||
|
#define I_VIEWPORT "cviewport"
|
||||||
|
#define I_TEXOFFSETFLAGS "ctexoffset"
|
||||||
|
|
||||||
static const char s_shader_uniforms[] =
|
static const char s_shader_uniforms[] =
|
||||||
"\tfloat4 " I_POSNORMALMATRIX"[6];\n"
|
"\tfloat4 " I_POSNORMALMATRIX"[6];\n"
|
||||||
|
|
Loading…
Reference in New Issue