diff options
author | bunnei <bunneidev@gmail.com> | 2018-03-27 04:30:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-27 04:30:03 +0200 |
commit | b4bf099793d8e9a065769c35bb4b8e20bf107549 (patch) | |
tree | 2a9adcdcc7b3947242f3d4717302dc29425e8b0d /src/video_core/engines/maxwell_3d.h | |
parent | Merge pull request #283 from Subv/tsc (diff) | |
parent | renderer_opengl: Use better naming for DrawScreens and DrawSingleScreen. (diff) | |
download | yuzu-b4bf099793d8e9a065769c35bb4b8e20bf107549.tar yuzu-b4bf099793d8e9a065769c35bb4b8e20bf107549.tar.gz yuzu-b4bf099793d8e9a065769c35bb4b8e20bf107549.tar.bz2 yuzu-b4bf099793d8e9a065769c35bb4b8e20bf107549.tar.lz yuzu-b4bf099793d8e9a065769c35bb4b8e20bf107549.tar.xz yuzu-b4bf099793d8e9a065769c35bb4b8e20bf107549.tar.zst yuzu-b4bf099793d8e9a065769c35bb4b8e20bf107549.zip |
Diffstat (limited to 'src/video_core/engines/maxwell_3d.h')
-rw-r--r-- | src/video_core/engines/maxwell_3d.h | 267 |
1 files changed, 178 insertions, 89 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 8e2d888e7..3066bc606 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h @@ -11,6 +11,8 @@ #include "common/bit_field.h" #include "common/common_funcs.h" #include "common/common_types.h" +#include "common/math_util.h" +#include "video_core/gpu.h" #include "video_core/memory_manager.h" #include "video_core/textures/texture.h" @@ -59,88 +61,173 @@ public: Fragment = 4, }; - enum class VertexSize : u32 { - Size_32_32_32_32 = 0x01, - Size_32_32_32 = 0x02, - Size_16_16_16_16 = 0x03, - Size_32_32 = 0x04, - Size_16_16_16 = 0x05, - Size_8_8_8_8 = 0x0a, - Size_16_16 = 0x0f, - Size_32 = 0x12, - Size_8_8_8 = 0x13, - Size_8_8 = 0x18, - Size_16 = 0x1b, - Size_8 = 0x1d, - Size_10_10_10_2 = 0x30, - Size_11_11_10 = 0x31, - }; + struct VertexAttribute { + enum class Size : u32 { + Size_32_32_32_32 = 0x01, + Size_32_32_32 = 0x02, + Size_16_16_16_16 = 0x03, + Size_32_32 = 0x04, + Size_16_16_16 = 0x05, + Size_8_8_8_8 = 0x0a, + Size_16_16 = 0x0f, + Size_32 = 0x12, + Size_8_8_8 = 0x13, + Size_8_8 = 0x18, + Size_16 = 0x1b, + Size_8 = 0x1d, + Size_10_10_10_2 = 0x30, + Size_11_11_10 = 0x31, + }; - static std::string VertexSizeToString(VertexSize vertex_size) { - switch (vertex_size) { - case VertexSize::Size_32_32_32_32: - return "32_32_32_32"; - case VertexSize::Size_32_32_32: - return "32_32_32"; - case VertexSize::Size_16_16_16_16: - return "16_16_16_16"; - case VertexSize::Size_32_32: - return "32_32"; - case VertexSize::Size_16_16_16: - return "16_16_16"; - case VertexSize::Size_8_8_8_8: - return "8_8_8_8"; - case VertexSize::Size_16_16: - return "16_16"; - case VertexSize::Size_32: - return "32"; - case VertexSize::Size_8_8_8: - return "8_8_8"; - case VertexSize::Size_8_8: - return "8_8"; - case VertexSize::Size_16: - return "16"; - case VertexSize::Size_8: - return "8"; - case VertexSize::Size_10_10_10_2: - return "10_10_10_2"; - case VertexSize::Size_11_11_10: - return "11_11_10"; + enum class Type : u32 { + SignedNorm = 1, + UnsignedNorm = 2, + SignedInt = 3, + UnsignedInt = 4, + UnsignedScaled = 5, + SignedScaled = 6, + Float = 7, + }; + + union { + BitField<0, 5, u32> buffer; + BitField<6, 1, u32> constant; + BitField<7, 14, u32> offset; + BitField<21, 6, Size> size; + BitField<27, 3, Type> type; + BitField<31, 1, u32> bgra; + }; + + u32 ComponentCount() const { + switch (size) { + case Size::Size_32_32_32_32: + return 4; + case Size::Size_32_32_32: + return 3; + case Size::Size_16_16_16_16: + return 4; + case Size::Size_32_32: + return 2; + case Size::Size_16_16_16: + return 3; + case Size::Size_8_8_8_8: + return 4; + case Size::Size_16_16: + return 2; + case Size::Size_32: + return 1; + case Size::Size_8_8_8: + return 3; + case Size::Size_8_8: + return 2; + case Size::Size_16: + return 1; + case Size::Size_8: + return 1; + case Size::Size_10_10_10_2: + return 4; + case Size::Size_11_11_10: + return 3; + default: + UNREACHABLE(); + } + } + + u32 SizeInBytes() const { + switch (size) { + case Size::Size_32_32_32_32: + return 16; + case Size::Size_32_32_32: + return 12; + case Size::Size_16_16_16_16: + return 8; + case Size::Size_32_32: + return 8; + case Size::Size_16_16_16: + return 6; + case Size::Size_8_8_8_8: + return 4; + case Size::Size_16_16: + return 4; + case Size::Size_32: + return 4; + case Size::Size_8_8_8: + return 3; + case Size::Size_8_8: + return 2; + case Size::Size_16: + return 2; + case Size::Size_8: + return 1; + case Size::Size_10_10_10_2: + return 4; + case Size::Size_11_11_10: + return 4; + default: + UNREACHABLE(); + } } - UNIMPLEMENTED(); - return {}; - } - - enum class VertexType : u32 { - SignedNorm = 1, - UnsignedNorm = 2, - SignedInt = 3, - UnsignedInt = 4, - UnsignedScaled = 5, - SignedScaled = 6, - Float = 7, - }; - static std::string VertexTypeToString(VertexType vertex_type) { - switch (vertex_type) { - case VertexType::SignedNorm: - return "SignedNorm"; - case VertexType::UnsignedNorm: - return "UnsignedNorm"; - case VertexType::SignedInt: - return "SignedInt"; - case VertexType::UnsignedInt: - return "UnsignedInt"; - case VertexType::UnsignedScaled: - return "UnsignedScaled"; - case VertexType::SignedScaled: - return "SignedScaled"; - case VertexType::Float: - return "Float"; + std::string SizeString() const { + switch (size) { + case Size::Size_32_32_32_32: + return "32_32_32_32"; + case Size::Size_32_32_32: + return "32_32_32"; + case Size::Size_16_16_16_16: + return "16_16_16_16"; + case Size::Size_32_32: + return "32_32"; + case Size::Size_16_16_16: + return "16_16_16"; + case Size::Size_8_8_8_8: + return "8_8_8_8"; + case Size::Size_16_16: + return "16_16"; + case Size::Size_32: + return "32"; + case Size::Size_8_8_8: + return "8_8_8"; + case Size::Size_8_8: + return "8_8"; + case Size::Size_16: + return "16"; + case Size::Size_8: + return "8"; + case Size::Size_10_10_10_2: + return "10_10_10_2"; + case Size::Size_11_11_10: + return "11_11_10"; + } + UNREACHABLE(); + return {}; } - UNIMPLEMENTED(); - return {}; - } + + std::string TypeString() const { + switch (type) { + case Type::SignedNorm: + return "SNORM"; + case Type::UnsignedNorm: + return "UNORM"; + case Type::SignedInt: + return "SINT"; + case Type::UnsignedInt: + return "UINT"; + case Type::UnsignedScaled: + return "USCALED"; + case Type::SignedScaled: + return "SSCALED"; + case Type::Float: + return "FLOAT"; + } + UNREACHABLE(); + return {}; + } + + bool IsNormalized() const { + return (type == Type::SignedNorm) || (type == Type::UnsignedNorm); + } + }; enum class PrimitiveTopology : u32 { Points = 0x0, @@ -167,9 +254,9 @@ public: struct { u32 address_high; u32 address_low; - u32 horiz; - u32 vert; - u32 format; + u32 width; + u32 height; + Tegra::RenderTargetFormat format; u32 block_dimensions; u32 array_mode; u32 layer_stride; @@ -195,6 +282,15 @@ public: }; float depth_range_near; float depth_range_far; + + MathUtil::Rectangle<s32> GetRect() const { + return { + static_cast<s32>(x), // left + static_cast<s32>(y + height), // top + static_cast<s32>(x + width), // right + static_cast<s32>(y) // bottom + }; + }; } viewport[NumViewports]; INSERT_PADDING_WORDS(0x1D); @@ -221,14 +317,7 @@ public: INSERT_PADDING_WORDS(0x5B); - union { - BitField<0, 5, u32> buffer; - BitField<6, 1, u32> constant; - BitField<7, 14, u32> offset; - BitField<21, 6, VertexSize> size; - BitField<27, 3, VertexType> type; - BitField<31, 1, u32> bgra; - } vertex_attrib_format[NumVertexAttributes]; + VertexAttribute vertex_attrib_format[NumVertexAttributes]; INSERT_PADDING_WORDS(0xF); |