Skip to content

Commit

Permalink
VideoCommon: Make IsPassthrough() a function of the ShaderUid.
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossVR committed Dec 19, 2014
1 parent 283cd2c commit bb67b34
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/GeometryShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ bool GeometryShaderCache::SetShader(u32 primitive_type)
last_uid = uid;

// Check if the shader is a pass-through shader
if (IsPassthroughGeometryShader(uid))
if (uid.IsPassthrough())
{
// Return the default pass-through shader
last_entry = &pass_entry;
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/OGL/ProgramShaderCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components
ShaderCode gcode;
GenerateVertexShaderCode(vcode, components, API_OPENGL);
GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL, components);
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders && !IsPassthroughGeometryShader(uid.guid))
if (g_ActiveConfig.backend_info.bSupportsGeometryShaders && !uid.guid.IsPassthrough())
GenerateGeometryShaderCode(gcode, primitive_type, API_OPENGL);

if (g_ActiveConfig.bEnableShaderDebugging)
Expand Down
7 changes: 0 additions & 7 deletions Source/Core/VideoCommon/GeometryShaderGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "VideoCommon/BPMemory.h"
#include "VideoCommon/GeometryShaderGen.h"
#include "VideoCommon/LightingShaderGen.h"
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VertexShaderGen.h"
#include "VideoCommon/VideoConfig.h"

Expand Down Expand Up @@ -302,9 +301,3 @@ void GenerateGeometryShaderCode(ShaderCode& object, u32 primitive_type, API_TYPE
{
GenerateGeometryShader<ShaderCode>(object, primitive_type, ApiType);
}

bool IsPassthroughGeometryShader(GeometryShaderUid& object)
{
geometry_shader_uid_data* uid_data = object.GetUidData<geometry_shader_uid_data>();
return uid_data->primitive_type == PRIMITIVE_TRIANGLES && !uid_data->stereo && !uid_data->wireframe;
}
3 changes: 2 additions & 1 deletion Source/Core/VideoCommon/GeometryShaderGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
#pragma once

#include "VideoCommon/ShaderGenCommon.h"
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoCommon.h"

#pragma pack(1)

struct geometry_shader_uid_data
{
u32 NumValues() const { return sizeof(geometry_shader_uid_data); }
bool IsPassthrough() const { return primitive_type == PRIMITIVE_TRIANGLES && !stereo && !wireframe; }

u32 stereo : 1;
u32 numTexGens : 4;
Expand All @@ -26,4 +28,3 @@ typedef ShaderUid<geometry_shader_uid_data> GeometryShaderUid;

void GenerateGeometryShaderCode(ShaderCode& object, u32 primitive_type, API_TYPE ApiType);
void GetGeometryShaderUid(GeometryShaderUid& object, u32 primitive_type, API_TYPE ApiType);
bool IsPassthroughGeometryShader(GeometryShaderUid& object);
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/PixelShaderGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ struct pixel_shader_uid_data

u32 num_values; // TODO: Shouldn't be a u32
u32 NumValues() const { return num_values; }
bool IsPassthrough() const { return false; }

u32 components : 23;
u32 dstAlphaMode : 2;
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/ShaderGenCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class ShaderUid : public ShaderGeneratorInterface
const u8* GetUidDataRaw() const { return &values[0]; }

size_t GetUidDataSize() const { return sizeof(values); }
bool IsPassthrough() const { return data.IsPassthrough(); }

private:
union
Expand Down
1 change: 1 addition & 0 deletions Source/Core/VideoCommon/VertexShaderGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
struct vertex_shader_uid_data
{
u32 NumValues() const { return sizeof(vertex_shader_uid_data); }
bool IsPassthrough() const { return false; }

u32 components : 23;
u32 numTexGens : 4;
Expand Down

0 comments on commit bb67b34

Please sign in to comment.