summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/engines/kepler_compute.cpp12
-rw-r--r--src/video_core/engines/kepler_compute.h7
-rw-r--r--src/video_core/engines/maxwell_3d.cpp61
-rw-r--r--src/video_core/engines/maxwell_3d.h8
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp12
-rw-r--r--src/video_core/textures/texture.h1
6 files changed, 20 insertions, 81 deletions
diff --git a/src/video_core/engines/kepler_compute.cpp b/src/video_core/engines/kepler_compute.cpp
index 91adef360..3a39aeabe 100644
--- a/src/video_core/engines/kepler_compute.cpp
+++ b/src/video_core/engines/kepler_compute.cpp
@@ -50,7 +50,7 @@ void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) {
50 } 50 }
51} 51}
52 52
53Tegra::Texture::FullTextureInfo KeplerCompute::GetTexture(std::size_t offset) const { 53Texture::FullTextureInfo KeplerCompute::GetTexture(std::size_t offset) const {
54 const std::bitset<8> cbuf_mask = launch_description.const_buffer_enable_mask.Value(); 54 const std::bitset<8> cbuf_mask = launch_description.const_buffer_enable_mask.Value();
55 ASSERT(cbuf_mask[regs.tex_cb_index]); 55 ASSERT(cbuf_mask[regs.tex_cb_index]);
56 56
@@ -61,13 +61,11 @@ Tegra::Texture::FullTextureInfo KeplerCompute::GetTexture(std::size_t offset) co
61 ASSERT(address < texinfo.Address() + texinfo.size); 61 ASSERT(address < texinfo.Address() + texinfo.size);
62 62
63 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(address)}; 63 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(address)};
64 return GetTextureInfo(tex_handle, offset); 64 return GetTextureInfo(tex_handle);
65} 65}
66 66
67Texture::FullTextureInfo KeplerCompute::GetTextureInfo(const Texture::TextureHandle tex_handle, 67Texture::FullTextureInfo KeplerCompute::GetTextureInfo(Texture::TextureHandle tex_handle) const {
68 std::size_t offset) const { 68 return Texture::FullTextureInfo{GetTICEntry(tex_handle.tic_id), GetTSCEntry(tex_handle.tsc_id)};
69 return Texture::FullTextureInfo{static_cast<u32>(offset), GetTICEntry(tex_handle.tic_id),
70 GetTSCEntry(tex_handle.tsc_id)};
71} 69}
72 70
73u32 KeplerCompute::AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const { 71u32 KeplerCompute::AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const {
@@ -89,7 +87,7 @@ SamplerDescriptor KeplerCompute::AccessBindlessSampler(ShaderType stage, u64 con
89 const GPUVAddr tex_info_address = tex_info_buffer.Address() + offset; 87 const GPUVAddr tex_info_address = tex_info_buffer.Address() + offset;
90 88
91 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)}; 89 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)};
92 const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle, offset); 90 const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle);
93 SamplerDescriptor result = SamplerDescriptor::FromTicTexture(tex_info.tic.texture_type.Value()); 91 SamplerDescriptor result = SamplerDescriptor::FromTicTexture(tex_info.tic.texture_type.Value());
94 result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value()); 92 result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value());
95 return result; 93 return result;
diff --git a/src/video_core/engines/kepler_compute.h b/src/video_core/engines/kepler_compute.h
index 8e7182727..b185c98c7 100644
--- a/src/video_core/engines/kepler_compute.h
+++ b/src/video_core/engines/kepler_compute.h
@@ -196,11 +196,10 @@ public:
196 /// Write the value to the register identified by method. 196 /// Write the value to the register identified by method.
197 void CallMethod(const GPU::MethodCall& method_call); 197 void CallMethod(const GPU::MethodCall& method_call);
198 198
199 Tegra::Texture::FullTextureInfo GetTexture(std::size_t offset) const; 199 Texture::FullTextureInfo GetTexture(std::size_t offset) const;
200 200
201 /// Given a Texture Handle, returns the TSC and TIC entries. 201 /// Given a texture handle, returns the TSC and TIC entries.
202 Texture::FullTextureInfo GetTextureInfo(const Texture::TextureHandle tex_handle, 202 Texture::FullTextureInfo GetTextureInfo(Texture::TextureHandle tex_handle) const;
203 std::size_t offset) const;
204 203
205 u32 AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const override; 204 u32 AccessConstBuffer32(ShaderType stage, u64 const_buffer, u64 offset) const override;
206 205
diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp
index 514ed93fa..2bed6cb38 100644
--- a/src/video_core/engines/maxwell_3d.cpp
+++ b/src/video_core/engines/maxwell_3d.cpp
@@ -760,61 +760,8 @@ Texture::TSCEntry Maxwell3D::GetTSCEntry(u32 tsc_index) const {
760 return tsc_entry; 760 return tsc_entry;
761} 761}
762 762
763std::vector<Texture::FullTextureInfo> Maxwell3D::GetStageTextures(Regs::ShaderStage stage) const { 763Texture::FullTextureInfo Maxwell3D::GetTextureInfo(Texture::TextureHandle tex_handle) const {
764 std::vector<Texture::FullTextureInfo> textures; 764 return Texture::FullTextureInfo{GetTICEntry(tex_handle.tic_id), GetTSCEntry(tex_handle.tsc_id)};
765
766 auto& fragment_shader = state.shader_stages[static_cast<std::size_t>(stage)];
767 auto& tex_info_buffer = fragment_shader.const_buffers[regs.tex_cb_index];
768 ASSERT(tex_info_buffer.enabled && tex_info_buffer.address != 0);
769
770 GPUVAddr tex_info_buffer_end = tex_info_buffer.address + tex_info_buffer.size;
771
772 // Offset into the texture constbuffer where the texture info begins.
773 static constexpr std::size_t TextureInfoOffset = 0x20;
774
775 for (GPUVAddr current_texture = tex_info_buffer.address + TextureInfoOffset;
776 current_texture < tex_info_buffer_end; current_texture += sizeof(Texture::TextureHandle)) {
777
778 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(current_texture)};
779
780 Texture::FullTextureInfo tex_info{};
781 // TODO(Subv): Use the shader to determine which textures are actually accessed.
782 tex_info.index =
783 static_cast<u32>(current_texture - tex_info_buffer.address - TextureInfoOffset) /
784 sizeof(Texture::TextureHandle);
785
786 // Load the TIC data.
787 auto tic_entry = GetTICEntry(tex_handle.tic_id);
788 // TODO(Subv): Workaround for BitField's move constructor being deleted.
789 std::memcpy(&tex_info.tic, &tic_entry, sizeof(tic_entry));
790
791 // Load the TSC data
792 auto tsc_entry = GetTSCEntry(tex_handle.tsc_id);
793 // TODO(Subv): Workaround for BitField's move constructor being deleted.
794 std::memcpy(&tex_info.tsc, &tsc_entry, sizeof(tsc_entry));
795
796 textures.push_back(tex_info);
797 }
798
799 return textures;
800}
801
802Texture::FullTextureInfo Maxwell3D::GetTextureInfo(const Texture::TextureHandle tex_handle,
803 std::size_t offset) const {
804 Texture::FullTextureInfo tex_info{};
805 tex_info.index = static_cast<u32>(offset);
806
807 // Load the TIC data.
808 auto tic_entry = GetTICEntry(tex_handle.tic_id);
809 // TODO(Subv): Workaround for BitField's move constructor being deleted.
810 std::memcpy(&tex_info.tic, &tic_entry, sizeof(tic_entry));
811
812 // Load the TSC data
813 auto tsc_entry = GetTSCEntry(tex_handle.tsc_id);
814 // TODO(Subv): Workaround for BitField's move constructor being deleted.
815 std::memcpy(&tex_info.tsc, &tsc_entry, sizeof(tsc_entry));
816
817 return tex_info;
818} 765}
819 766
820Texture::FullTextureInfo Maxwell3D::GetStageTexture(Regs::ShaderStage stage, 767Texture::FullTextureInfo Maxwell3D::GetStageTexture(Regs::ShaderStage stage,
@@ -830,7 +777,7 @@ Texture::FullTextureInfo Maxwell3D::GetStageTexture(Regs::ShaderStage stage,
830 777
831 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)}; 778 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)};
832 779
833 return GetTextureInfo(tex_handle, offset); 780 return GetTextureInfo(tex_handle);
834} 781}
835 782
836u32 Maxwell3D::GetRegisterValue(u32 method) const { 783u32 Maxwell3D::GetRegisterValue(u32 method) const {
@@ -867,7 +814,7 @@ SamplerDescriptor Maxwell3D::AccessBindlessSampler(ShaderType stage, u64 const_b
867 const GPUVAddr tex_info_address = tex_info_buffer.address + offset; 814 const GPUVAddr tex_info_address = tex_info_buffer.address + offset;
868 815
869 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)}; 816 const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(tex_info_address)};
870 const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle, offset); 817 const Texture::FullTextureInfo tex_info = GetTextureInfo(tex_handle);
871 SamplerDescriptor result = SamplerDescriptor::FromTicTexture(tex_info.tic.texture_type.Value()); 818 SamplerDescriptor result = SamplerDescriptor::FromTicTexture(tex_info.tic.texture_type.Value());
872 result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value()); 819 result.is_shadow.Assign(tex_info.tsc.depth_compare_enabled.Value());
873 return result; 820 return result;
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 987ad77b2..8cc842684 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -1250,12 +1250,8 @@ public:
1250 1250
1251 void FlushMMEInlineDraw(); 1251 void FlushMMEInlineDraw();
1252 1252
1253 /// Given a Texture Handle, returns the TSC and TIC entries. 1253 /// Given a texture handle, returns the TSC and TIC entries.
1254 Texture::FullTextureInfo GetTextureInfo(const Texture::TextureHandle tex_handle, 1254 Texture::FullTextureInfo GetTextureInfo(Texture::TextureHandle tex_handle) const;
1255 std::size_t offset) const;
1256
1257 /// Returns a list of enabled textures for the specified shader stage.
1258 std::vector<Texture::FullTextureInfo> GetStageTextures(Regs::ShaderStage stage) const;
1259 1255
1260 /// Returns the texture information for a specific texture in a specific shader stage. 1256 /// Returns the texture information for a specific texture in a specific shader stage.
1261 Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, std::size_t offset) const; 1257 Texture::FullTextureInfo GetStageTexture(Regs::ShaderStage stage, std::size_t offset) const;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 9431d64ac..43032e9a7 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -969,7 +969,7 @@ TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stag
969 969
970 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { 970 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
971 const auto& entry = entries[bindpoint]; 971 const auto& entry = entries[bindpoint];
972 const auto texture = [&]() { 972 const auto texture = [&] {
973 if (!entry.IsBindless()) { 973 if (!entry.IsBindless()) {
974 return maxwell3d.GetStageTexture(stage, entry.GetOffset()); 974 return maxwell3d.GetStageTexture(stage, entry.GetOffset());
975 } 975 }
@@ -977,7 +977,7 @@ TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stag
977 Tegra::Texture::TextureHandle tex_handle; 977 Tegra::Texture::TextureHandle tex_handle;
978 Tegra::Engines::ShaderType shader_type = static_cast<Tegra::Engines::ShaderType>(stage); 978 Tegra::Engines::ShaderType shader_type = static_cast<Tegra::Engines::ShaderType>(stage);
979 tex_handle.raw = maxwell3d.AccessConstBuffer32(shader_type, cbuf.first, cbuf.second); 979 tex_handle.raw = maxwell3d.AccessConstBuffer32(shader_type, cbuf.first, cbuf.second);
980 return maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset()); 980 return maxwell3d.GetTextureInfo(tex_handle);
981 }(); 981 }();
982 982
983 if (SetupTexture(base_bindings.sampler + bindpoint, texture, entry)) { 983 if (SetupTexture(base_bindings.sampler + bindpoint, texture, entry)) {
@@ -1000,7 +1000,7 @@ TextureBufferUsage RasterizerOpenGL::SetupComputeTextures(const Shader& kernel)
1000 1000
1001 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { 1001 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
1002 const auto& entry = entries[bindpoint]; 1002 const auto& entry = entries[bindpoint];
1003 const auto texture = [&]() { 1003 const auto texture = [&] {
1004 if (!entry.IsBindless()) { 1004 if (!entry.IsBindless()) {
1005 return compute.GetTexture(entry.GetOffset()); 1005 return compute.GetTexture(entry.GetOffset());
1006 } 1006 }
@@ -1008,7 +1008,7 @@ TextureBufferUsage RasterizerOpenGL::SetupComputeTextures(const Shader& kernel)
1008 Tegra::Texture::TextureHandle tex_handle; 1008 Tegra::Texture::TextureHandle tex_handle;
1009 tex_handle.raw = compute.AccessConstBuffer32(Tegra::Engines::ShaderType::Compute, 1009 tex_handle.raw = compute.AccessConstBuffer32(Tegra::Engines::ShaderType::Compute,
1010 cbuf.first, cbuf.second); 1010 cbuf.first, cbuf.second);
1011 return compute.GetTextureInfo(tex_handle, entry.GetOffset()); 1011 return compute.GetTextureInfo(tex_handle);
1012 }(); 1012 }();
1013 1013
1014 if (SetupTexture(bindpoint, texture, entry)) { 1014 if (SetupTexture(bindpoint, texture, entry)) {
@@ -1046,7 +1046,7 @@ void RasterizerOpenGL::SetupComputeImages(const Shader& shader) {
1046 const auto& entries = shader->GetShaderEntries().images; 1046 const auto& entries = shader->GetShaderEntries().images;
1047 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { 1047 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
1048 const auto& entry = entries[bindpoint]; 1048 const auto& entry = entries[bindpoint];
1049 const auto tic = [&]() { 1049 const auto tic = [&] {
1050 if (!entry.IsBindless()) { 1050 if (!entry.IsBindless()) {
1051 return compute.GetTexture(entry.GetOffset()).tic; 1051 return compute.GetTexture(entry.GetOffset()).tic;
1052 } 1052 }
@@ -1054,7 +1054,7 @@ void RasterizerOpenGL::SetupComputeImages(const Shader& shader) {
1054 Tegra::Texture::TextureHandle tex_handle; 1054 Tegra::Texture::TextureHandle tex_handle;
1055 tex_handle.raw = compute.AccessConstBuffer32(Tegra::Engines::ShaderType::Compute, 1055 tex_handle.raw = compute.AccessConstBuffer32(Tegra::Engines::ShaderType::Compute,
1056 cbuf.first, cbuf.second); 1056 cbuf.first, cbuf.second);
1057 return compute.GetTextureInfo(tex_handle, entry.GetOffset()).tic; 1057 return compute.GetTextureInfo(tex_handle).tic;
1058 }(); 1058 }();
1059 SetupImage(bindpoint, tic, entry); 1059 SetupImage(bindpoint, tic, entry);
1060 } 1060 }
diff --git a/src/video_core/textures/texture.h b/src/video_core/textures/texture.h
index e36bc2c04..0429af9c1 100644
--- a/src/video_core/textures/texture.h
+++ b/src/video_core/textures/texture.h
@@ -354,7 +354,6 @@ struct TSCEntry {
354static_assert(sizeof(TSCEntry) == 0x20, "TSCEntry has wrong size"); 354static_assert(sizeof(TSCEntry) == 0x20, "TSCEntry has wrong size");
355 355
356struct FullTextureInfo { 356struct FullTextureInfo {
357 u32 index;
358 TICEntry tic; 357 TICEntry tic;
359 TSCEntry tsc; 358 TSCEntry tsc;
360}; 359};