From ab6954e942654fb003964fc95c0846aa8b89ac91 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 18 Dec 2016 16:42:19 -0800 Subject: VideoCore: Rename some types to more accurate names --- src/video_core/shader/shader.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core/shader/shader.h') diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index 44d9f76c3..cb38ec0a6 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -23,7 +23,7 @@ namespace Pica { namespace Shader { -struct InputVertex { +struct AttributeBuffer { alignas(16) Math::Vec4 attr[16]; }; @@ -140,7 +140,7 @@ struct UnitState { * @param input Input vertex into the shader * @param num_attributes The number of vertex shader attributes to load */ - void LoadInputVertex(const InputVertex& input, int num_attributes); + void LoadInput(const AttributeBuffer& input, int num_attributes); }; struct ShaderSetup { -- cgit v1.2.3 From 335df895b9f9e9760ed5cd0d6dfaea8befb94dac Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 18 Dec 2016 17:25:03 -0800 Subject: VideoCore: Consistently use shader configuration to load attributes --- src/video_core/shader/shader.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/video_core/shader/shader.h') diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index cb38ec0a6..43a8b848c 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -137,10 +137,10 @@ struct UnitState { /** * Loads the unit state with an input vertex. * - * @param input Input vertex into the shader - * @param num_attributes The number of vertex shader attributes to load + * @param config Shader configuration registers corresponding to the unit. + * @param input Attribute buffer to load into the input registers. */ - void LoadInput(const AttributeBuffer& input, int num_attributes); + void LoadInput(const Regs::ShaderConfig& config, const AttributeBuffer& input); }; struct ShaderSetup { -- cgit v1.2.3 From 92bf5c88e6f85ebeef161a0056c86c66bc25c6e7 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 18 Dec 2016 17:58:30 -0800 Subject: VideoCore: Split shader output writing from semantic loading --- src/video_core/shader/shader.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/video_core/shader/shader.h') diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index 43a8b848c..00bd723cf 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -74,8 +74,7 @@ struct OutputVertex { return ret; } - static OutputVertex FromRegisters(Math::Vec4 output_regs[16], const Regs& regs, - u32 output_mask); + static OutputVertex FromAttributeBuffer(const Regs& regs, AttributeBuffer& output); }; static_assert(std::is_pod::value, "Structure is not POD"); static_assert(sizeof(OutputVertex) == 32 * sizeof(float), "OutputVertex has invalid size"); @@ -141,6 +140,8 @@ struct UnitState { * @param input Attribute buffer to load into the input registers. */ void LoadInput(const Regs::ShaderConfig& config, const AttributeBuffer& input); + + void WriteOutput(const Regs::ShaderConfig& config, AttributeBuffer& output); }; struct ShaderSetup { -- cgit v1.2.3 From dcdffabfe69d0cecd2d8c0c1f217b884b20af643 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sun, 18 Dec 2016 23:43:37 -0800 Subject: VideoCore: Extract swrast-specific data from OutputVertex --- src/video_core/shader/shader.h | 49 +++++++++++------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) (limited to 'src/video_core/shader/shader.h') diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index 00bd723cf..b188d3edf 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -28,9 +28,6 @@ struct AttributeBuffer { }; struct OutputVertex { - OutputVertex() = default; - - // VS output attributes Math::Vec4 pos; Math::Vec4 quat; Math::Vec4 color; @@ -42,42 +39,22 @@ struct OutputVertex { INSERT_PADDING_WORDS(1); Math::Vec2 tc2; - // Padding for optimal alignment - INSERT_PADDING_WORDS(4); - - // Attributes used to store intermediate results - - // position after perspective divide - Math::Vec3 screenpos; - INSERT_PADDING_WORDS(1); - - // Linear interpolation - // factor: 0=this, 1=vtx - void Lerp(float24 factor, const OutputVertex& vtx) { - pos = pos * factor + vtx.pos * (float24::FromFloat32(1) - factor); - - // TODO: Should perform perspective correct interpolation here... - tc0 = tc0 * factor + vtx.tc0 * (float24::FromFloat32(1) - factor); - tc1 = tc1 * factor + vtx.tc1 * (float24::FromFloat32(1) - factor); - tc2 = tc2 * factor + vtx.tc2 * (float24::FromFloat32(1) - factor); - - screenpos = screenpos * factor + vtx.screenpos * (float24::FromFloat32(1) - factor); - - color = color * factor + vtx.color * (float24::FromFloat32(1) - factor); - } - - // Linear interpolation - // factor: 0=v0, 1=v1 - static OutputVertex Lerp(float24 factor, const OutputVertex& v0, const OutputVertex& v1) { - OutputVertex ret = v0; - ret.Lerp(factor, v1); - return ret; - } - static OutputVertex FromAttributeBuffer(const Regs& regs, AttributeBuffer& output); }; +#define ASSERT_POS(var, pos) \ + static_assert(offsetof(OutputVertex, var) == pos * sizeof(float24), "Semantic at wrong " \ + "offset.") +ASSERT_POS(pos, Regs::VSOutputAttributes::POSITION_X); +ASSERT_POS(quat, Regs::VSOutputAttributes::QUATERNION_X); +ASSERT_POS(color, Regs::VSOutputAttributes::COLOR_R); +ASSERT_POS(tc0, Regs::VSOutputAttributes::TEXCOORD0_U); +ASSERT_POS(tc1, Regs::VSOutputAttributes::TEXCOORD1_U); +ASSERT_POS(tc0_w, Regs::VSOutputAttributes::TEXCOORD0_W); +ASSERT_POS(view, Regs::VSOutputAttributes::VIEW_X); +ASSERT_POS(tc2, Regs::VSOutputAttributes::TEXCOORD2_U); +#undef ASSERT_POS static_assert(std::is_pod::value, "Structure is not POD"); -static_assert(sizeof(OutputVertex) == 32 * sizeof(float), "OutputVertex has invalid size"); +static_assert(sizeof(OutputVertex) == 24 * sizeof(float), "OutputVertex has invalid size"); /** * This structure contains the state information that needs to be unique for a shader unit. The 3DS -- cgit v1.2.3