diff options
| -rw-r--r-- | src/core/file_sys/disk_filesystem.cpp | 12 | ||||
| -rw-r--r-- | src/core/file_sys/disk_filesystem.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/filesystem.h | 2 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_filesystem.cpp | 2 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_filesystem.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 85 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 13 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.h | 14 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_manager.h | 11 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 2 |
12 files changed, 121 insertions, 45 deletions
diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp index 4235f3935..263392930 100644 --- a/src/core/file_sys/disk_filesystem.cpp +++ b/src/core/file_sys/disk_filesystem.cpp | |||
| @@ -57,10 +57,14 @@ ResultVal<std::unique_ptr<StorageBackend>> Disk_FileSystem::OpenFile(const std:: | |||
| 57 | std::make_unique<Disk_Storage>(std::move(file))); | 57 | std::make_unique<Disk_Storage>(std::move(file))); |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | ResultCode Disk_FileSystem::DeleteFile(const Path& path) const { | 60 | ResultCode Disk_FileSystem::DeleteFile(const std::string& path) const { |
| 61 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 61 | if (!FileUtil::Exists(path)) { |
| 62 | // TODO(bunnei): Use correct error code | 62 | return ERROR_PATH_NOT_FOUND; |
| 63 | return ResultCode(-1); | 63 | } |
| 64 | |||
| 65 | FileUtil::Delete(path); | ||
| 66 | |||
| 67 | return RESULT_SUCCESS; | ||
| 64 | } | 68 | } |
| 65 | 69 | ||
| 66 | ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { | 70 | ResultCode Disk_FileSystem::RenameFile(const Path& src_path, const Path& dest_path) const { |
diff --git a/src/core/file_sys/disk_filesystem.h b/src/core/file_sys/disk_filesystem.h index 742d7db1a..05a29bc3a 100644 --- a/src/core/file_sys/disk_filesystem.h +++ b/src/core/file_sys/disk_filesystem.h | |||
| @@ -25,7 +25,7 @@ public: | |||
| 25 | 25 | ||
| 26 | ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, | 26 | ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, |
| 27 | Mode mode) const override; | 27 | Mode mode) const override; |
| 28 | ResultCode DeleteFile(const Path& path) const override; | 28 | ResultCode DeleteFile(const std::string& path) const override; |
| 29 | ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; | 29 | ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 30 | ResultCode DeleteDirectory(const Path& path) const override; | 30 | ResultCode DeleteDirectory(const Path& path) const override; |
| 31 | ResultCode DeleteDirectoryRecursively(const Path& path) const override; | 31 | ResultCode DeleteDirectoryRecursively(const Path& path) const override; |
diff --git a/src/core/file_sys/filesystem.h b/src/core/file_sys/filesystem.h index 399427ca2..beefcfdb2 100644 --- a/src/core/file_sys/filesystem.h +++ b/src/core/file_sys/filesystem.h | |||
| @@ -97,7 +97,7 @@ public: | |||
| 97 | * @param path Path relative to the archive | 97 | * @param path Path relative to the archive |
| 98 | * @return Result of the operation | 98 | * @return Result of the operation |
| 99 | */ | 99 | */ |
| 100 | virtual ResultCode DeleteFile(const Path& path) const = 0; | 100 | virtual ResultCode DeleteFile(const std::string& path) const = 0; |
| 101 | 101 | ||
| 102 | /** | 102 | /** |
| 103 | * Create a directory specified by its path | 103 | * Create a directory specified by its path |
diff --git a/src/core/file_sys/romfs_filesystem.cpp b/src/core/file_sys/romfs_filesystem.cpp index 0c6cc3157..3d77e2d5f 100644 --- a/src/core/file_sys/romfs_filesystem.cpp +++ b/src/core/file_sys/romfs_filesystem.cpp | |||
| @@ -20,7 +20,7 @@ ResultVal<std::unique_ptr<StorageBackend>> RomFS_FileSystem::OpenFile(const std: | |||
| 20 | std::make_unique<RomFS_Storage>(romfs_file, data_offset, data_size)); | 20 | std::make_unique<RomFS_Storage>(romfs_file, data_offset, data_size)); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | ResultCode RomFS_FileSystem::DeleteFile(const Path& path) const { | 23 | ResultCode RomFS_FileSystem::DeleteFile(const std::string& path) const { |
| 24 | LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).", | 24 | LOG_CRITICAL(Service_FS, "Attempted to delete a file from an ROMFS archive (%s).", |
| 25 | GetName().c_str()); | 25 | GetName().c_str()); |
| 26 | // TODO(bunnei): Use correct error code | 26 | // TODO(bunnei): Use correct error code |
diff --git a/src/core/file_sys/romfs_filesystem.h b/src/core/file_sys/romfs_filesystem.h index 3f94c04d0..1b5cac409 100644 --- a/src/core/file_sys/romfs_filesystem.h +++ b/src/core/file_sys/romfs_filesystem.h | |||
| @@ -31,7 +31,7 @@ public: | |||
| 31 | 31 | ||
| 32 | ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, | 32 | ResultVal<std::unique_ptr<StorageBackend>> OpenFile(const std::string& path, |
| 33 | Mode mode) const override; | 33 | Mode mode) const override; |
| 34 | ResultCode DeleteFile(const Path& path) const override; | 34 | ResultCode DeleteFile(const std::string& path) const override; |
| 35 | ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; | 35 | ResultCode RenameFile(const Path& src_path, const Path& dest_path) const override; |
| 36 | ResultCode DeleteDirectory(const Path& path) const override; | 36 | ResultCode DeleteDirectory(const Path& path) const override; |
| 37 | ResultCode DeleteDirectoryRecursively(const Path& path) const override; | 37 | ResultCode DeleteDirectoryRecursively(const Path& path) const override; |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index 458210a55..45accbf0e 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -236,7 +236,7 @@ public: | |||
| 236 | : ServiceFramework("IFileSystem"), backend(std::move(backend)) { | 236 | : ServiceFramework("IFileSystem"), backend(std::move(backend)) { |
| 237 | static const FunctionInfo functions[] = { | 237 | static const FunctionInfo functions[] = { |
| 238 | {0, &IFileSystem::CreateFile, "CreateFile"}, | 238 | {0, &IFileSystem::CreateFile, "CreateFile"}, |
| 239 | {1, nullptr, "DeleteFile"}, | 239 | {1, &IFileSystem::DeleteFile, "DeleteFile"}, |
| 240 | {2, &IFileSystem::CreateDirectory, "CreateDirectory"}, | 240 | {2, &IFileSystem::CreateDirectory, "CreateDirectory"}, |
| 241 | {3, nullptr, "DeleteDirectory"}, | 241 | {3, nullptr, "DeleteDirectory"}, |
| 242 | {4, nullptr, "DeleteDirectoryRecursively"}, | 242 | {4, nullptr, "DeleteDirectoryRecursively"}, |
| @@ -273,6 +273,20 @@ public: | |||
| 273 | rb.Push(backend->CreateFile(name, size)); | 273 | rb.Push(backend->CreateFile(name, size)); |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | void DeleteFile(Kernel::HLERequestContext& ctx) { | ||
| 277 | IPC::RequestParser rp{ctx}; | ||
| 278 | |||
| 279 | auto file_buffer = ctx.ReadBuffer(); | ||
| 280 | auto end = std::find(file_buffer.begin(), file_buffer.end(), '\0'); | ||
| 281 | |||
| 282 | std::string name(file_buffer.begin(), end); | ||
| 283 | |||
| 284 | LOG_DEBUG(Service_FS, "called file %s", name.c_str()); | ||
| 285 | |||
| 286 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 287 | rb.Push(backend->DeleteFile(name)); | ||
| 288 | } | ||
| 289 | |||
| 276 | void CreateDirectory(Kernel::HLERequestContext& ctx) { | 290 | void CreateDirectory(Kernel::HLERequestContext& ctx) { |
| 277 | IPC::RequestParser rp{ctx}; | 291 | IPC::RequestParser rp{ctx}; |
| 278 | 292 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 2a2268c20..28abc563a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -193,6 +193,9 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size | |||
| 193 | auto& gpu = Core::System().GetInstance().GPU().Maxwell3D(); | 193 | auto& gpu = Core::System().GetInstance().GPU().Maxwell3D(); |
| 194 | ASSERT_MSG(!gpu.regs.shader_config[0].enable, "VertexA is unsupported!"); | 194 | ASSERT_MSG(!gpu.regs.shader_config[0].enable, "VertexA is unsupported!"); |
| 195 | 195 | ||
| 196 | // Next available bindpoint to use when uploading the const buffers to the GLSL shaders. | ||
| 197 | u32 current_constbuffer_bindpoint = 0; | ||
| 198 | |||
| 196 | for (unsigned index = 1; index < Maxwell::MaxShaderProgram; ++index) { | 199 | for (unsigned index = 1; index < Maxwell::MaxShaderProgram; ++index) { |
| 197 | ptr_pos += sizeof(GLShader::MaxwellUniformData); | 200 | ptr_pos += sizeof(GLShader::MaxwellUniformData); |
| 198 | 201 | ||
| @@ -223,15 +226,19 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size | |||
| 223 | Memory::ReadBlock(cpu_address, program_code.data(), program_code.size() * sizeof(u64)); | 226 | Memory::ReadBlock(cpu_address, program_code.data(), program_code.size() * sizeof(u64)); |
| 224 | GLShader::ShaderSetup setup{std::move(program_code)}; | 227 | GLShader::ShaderSetup setup{std::move(program_code)}; |
| 225 | 228 | ||
| 229 | GLShader::ShaderEntries shader_resources; | ||
| 230 | |||
| 226 | switch (program) { | 231 | switch (program) { |
| 227 | case Maxwell::ShaderProgram::VertexB: { | 232 | case Maxwell::ShaderProgram::VertexB: { |
| 228 | GLShader::MaxwellVSConfig vs_config{setup}; | 233 | GLShader::MaxwellVSConfig vs_config{setup}; |
| 229 | shader_program_manager->UseProgrammableVertexShader(vs_config, setup); | 234 | shader_resources = |
| 235 | shader_program_manager->UseProgrammableVertexShader(vs_config, setup); | ||
| 230 | break; | 236 | break; |
| 231 | } | 237 | } |
| 232 | case Maxwell::ShaderProgram::Fragment: { | 238 | case Maxwell::ShaderProgram::Fragment: { |
| 233 | GLShader::MaxwellFSConfig fs_config{setup}; | 239 | GLShader::MaxwellFSConfig fs_config{setup}; |
| 234 | shader_program_manager->UseProgrammableFragmentShader(fs_config, setup); | 240 | shader_resources = |
| 241 | shader_program_manager->UseProgrammableFragmentShader(fs_config, setup); | ||
| 235 | break; | 242 | break; |
| 236 | } | 243 | } |
| 237 | default: | 244 | default: |
| @@ -239,6 +246,14 @@ void RasterizerOpenGL::SetupShaders(u8* buffer_ptr, GLintptr buffer_offset, size | |||
| 239 | shader_config.enable.Value(), shader_config.offset); | 246 | shader_config.enable.Value(), shader_config.offset); |
| 240 | UNREACHABLE(); | 247 | UNREACHABLE(); |
| 241 | } | 248 | } |
| 249 | |||
| 250 | GLuint gl_stage_program = shader_program_manager->GetCurrentProgramStage( | ||
| 251 | static_cast<Maxwell::ShaderStage>(stage)); | ||
| 252 | |||
| 253 | // Configure the const buffers for this shader stage. | ||
| 254 | current_constbuffer_bindpoint = | ||
| 255 | SetupConstBuffers(static_cast<Maxwell::ShaderStage>(stage), gl_stage_program, | ||
| 256 | current_constbuffer_bindpoint, shader_resources.const_buffer_entries); | ||
| 242 | } | 257 | } |
| 243 | 258 | ||
| 244 | shader_program_manager->UseTrivialGeometryShader(); | 259 | shader_program_manager->UseTrivialGeometryShader(); |
| @@ -306,8 +321,6 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 306 | 321 | ||
| 307 | // Sync and bind the texture surfaces | 322 | // Sync and bind the texture surfaces |
| 308 | BindTextures(); | 323 | BindTextures(); |
| 309 | // Configure the constant buffer objects | ||
| 310 | SetupConstBuffers(); | ||
| 311 | 324 | ||
| 312 | // Viewport can have negative offsets or larger dimensions than our framebuffer sub-rect. Enable | 325 | // Viewport can have negative offsets or larger dimensions than our framebuffer sub-rect. Enable |
| 313 | // scissor test to prevent drawing outside of the framebuffer region | 326 | // scissor test to prevent drawing outside of the framebuffer region |
| @@ -537,39 +550,53 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntr | |||
| 537 | } | 550 | } |
| 538 | } | 551 | } |
| 539 | 552 | ||
| 540 | void RasterizerOpenGL::SetupConstBuffers() { | 553 | u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint program, |
| 541 | using Regs = Tegra::Engines::Maxwell3D::Regs; | 554 | u32 current_bindpoint, |
| 555 | const std::vector<GLShader::ConstBufferEntry>& entries) { | ||
| 542 | auto& gpu = Core::System::GetInstance().GPU(); | 556 | auto& gpu = Core::System::GetInstance().GPU(); |
| 543 | auto& maxwell3d = gpu.Get3DEngine(); | 557 | auto& maxwell3d = gpu.Get3DEngine(); |
| 544 | 558 | ||
| 545 | // Upload only the enabled buffers from the 16 constbuffers of each shader stage | 559 | ASSERT_MSG(maxwell3d.IsShaderStageEnabled(stage), |
| 546 | u32 current_bindpoint = 0; | 560 | "Attempted to upload constbuffer of disabled shader stage"); |
| 547 | for (u32 stage = 0; stage < Regs::MaxShaderStage; ++stage) { | ||
| 548 | auto& shader_stage = maxwell3d.state.shader_stages[stage]; | ||
| 549 | bool stage_enabled = maxwell3d.IsShaderStageEnabled(static_cast<Regs::ShaderStage>(stage)); | ||
| 550 | |||
| 551 | for (u32 buffer_id = 0; buffer_id < Regs::MaxConstBuffers; ++buffer_id) { | ||
| 552 | const auto& buffer = shader_stage.const_buffers[buffer_id]; | ||
| 553 | 561 | ||
| 554 | state.draw.const_buffers[stage][buffer_id].enabled = buffer.enabled && stage_enabled; | 562 | // Reset all buffer draw state for this stage. |
| 555 | 563 | for (auto& buffer : state.draw.const_buffers[static_cast<size_t>(stage)]) { | |
| 556 | if (buffer.enabled && stage_enabled) { | 564 | buffer.bindpoint = 0; |
| 557 | state.draw.const_buffers[stage][buffer_id].bindpoint = current_bindpoint; | 565 | buffer.enabled = false; |
| 558 | current_bindpoint++; | 566 | } |
| 559 | 567 | ||
| 560 | VAddr addr = gpu.memory_manager->PhysicalToVirtualAddress(buffer.address); | 568 | // Upload only the enabled buffers from the 16 constbuffers of each shader stage |
| 561 | const u8* data = Memory::GetPointer(addr); | 569 | auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)]; |
| 562 | glBindBuffer(GL_SHADER_STORAGE_BUFFER, | 570 | |
| 563 | state.draw.const_buffers[stage][buffer_id].ssbo); | 571 | for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { |
| 564 | glBufferData(GL_SHADER_STORAGE_BUFFER, buffer.size, data, GL_DYNAMIC_DRAW); | 572 | const auto& used_buffer = entries[bindpoint]; |
| 565 | glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); | 573 | const auto& buffer = shader_stage.const_buffers[used_buffer.GetIndex()]; |
| 566 | } else { | 574 | auto& buffer_draw_state = |
| 567 | state.draw.const_buffers[stage][buffer_id].bindpoint = -1; | 575 | state.draw.const_buffers[static_cast<size_t>(stage)][used_buffer.GetIndex()]; |
| 568 | } | 576 | |
| 569 | } | 577 | ASSERT_MSG(buffer.enabled, "Attempted to upload disabled constbuffer"); |
| 578 | buffer_draw_state.enabled = true; | ||
| 579 | buffer_draw_state.bindpoint = current_bindpoint + bindpoint; | ||
| 580 | |||
| 581 | VAddr addr = gpu.memory_manager->PhysicalToVirtualAddress(buffer.address); | ||
| 582 | std::vector<u8> data(used_buffer.GetSize() * sizeof(float)); | ||
| 583 | Memory::ReadBlock(addr, data.data(), data.size()); | ||
| 584 | |||
| 585 | glBindBuffer(GL_SHADER_STORAGE_BUFFER, buffer_draw_state.ssbo); | ||
| 586 | glBufferData(GL_SHADER_STORAGE_BUFFER, data.size(), data.data(), GL_DYNAMIC_DRAW); | ||
| 587 | glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0); | ||
| 588 | |||
| 589 | // Now configure the bindpoint of the buffer inside the shader | ||
| 590 | std::string buffer_name = used_buffer.GetName(); | ||
| 591 | GLuint index = | ||
| 592 | glGetProgramResourceIndex(program, GL_SHADER_STORAGE_BLOCK, buffer_name.c_str()); | ||
| 593 | if (index != -1) | ||
| 594 | glShaderStorageBlockBinding(program, index, buffer_draw_state.bindpoint); | ||
| 570 | } | 595 | } |
| 571 | 596 | ||
| 572 | state.Apply(); | 597 | state.Apply(); |
| 598 | |||
| 599 | return current_bindpoint + entries.size(); | ||
| 573 | } | 600 | } |
| 574 | 601 | ||
| 575 | void RasterizerOpenGL::BindFramebufferSurfaces(const Surface& color_surface, | 602 | void RasterizerOpenGL::BindFramebufferSurfaces(const Surface& color_surface, |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index bf3308aef..548ce0453 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -87,8 +87,17 @@ private: | |||
| 87 | /// Binds the required textures to OpenGL before drawing a batch. | 87 | /// Binds the required textures to OpenGL before drawing a batch. |
| 88 | void BindTextures(); | 88 | void BindTextures(); |
| 89 | 89 | ||
| 90 | /// Configures the current constbuffers to use for the draw command. | 90 | /* |
| 91 | void SetupConstBuffers(); | 91 | * Configures the current constbuffers to use for the draw command. |
| 92 | * @param stage The shader stage to configure buffers for. | ||
| 93 | * @param program The OpenGL program object that contains the specified stage. | ||
| 94 | * @param current_bindpoint The offset at which to start counting new buffer bindpoints. | ||
| 95 | * @param entries Vector describing the buffers that are actually used in the guest shader. | ||
| 96 | * @returns The next available bindpoint for use in the next shader stage. | ||
| 97 | */ | ||
| 98 | u32 SetupConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage, GLuint program, | ||
| 99 | u32 current_bindpoint, | ||
| 100 | const std::vector<GLShader::ConstBufferEntry>& entries); | ||
| 92 | 101 | ||
| 93 | /// Syncs the viewport to match the guest state | 102 | /// Syncs the viewport to match the guest state |
| 94 | void SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale); | 103 | void SyncViewport(const MathUtil::Rectangle<u32>& surfaces_rect, u16 res_scale); |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 9cf2c6a0c..e11711533 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -192,7 +192,7 @@ private: | |||
| 192 | 192 | ||
| 193 | /// Generates code representing a uniform (C buffer) register. | 193 | /// Generates code representing a uniform (C buffer) register. |
| 194 | std::string GetUniform(const Uniform& reg) { | 194 | std::string GetUniform(const Uniform& reg) { |
| 195 | declr_const_buffers[reg.index].MarkAsUsed(reg.index, reg.offset); | 195 | declr_const_buffers[reg.index].MarkAsUsed(reg.index, reg.offset, stage); |
| 196 | return 'c' + std::to_string(reg.index) + '[' + std::to_string(reg.offset) + ']'; | 196 | return 'c' + std::to_string(reg.index) + '[' + std::to_string(reg.offset) + ']'; |
| 197 | } | 197 | } |
| 198 | 198 | ||
| @@ -478,8 +478,7 @@ private: | |||
| 478 | 478 | ||
| 479 | unsigned const_buffer_layout = 0; | 479 | unsigned const_buffer_layout = 0; |
| 480 | for (const auto& entry : GetConstBuffersDeclarations()) { | 480 | for (const auto& entry : GetConstBuffersDeclarations()) { |
| 481 | declarations.AddLine("layout(std430, binding = " + std::to_string(const_buffer_layout) + | 481 | declarations.AddLine("layout(std430) buffer " + entry.GetName()); |
| 482 | ") buffer c" + std::to_string(entry.GetIndex()) + "_buffer"); | ||
| 483 | declarations.AddLine("{"); | 482 | declarations.AddLine("{"); |
| 484 | declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];"); | 483 | declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];"); |
| 485 | declarations.AddLine("};"); | 484 | declarations.AddLine("};"); |
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 3d9aead74..458032b5c 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.h +++ b/src/video_core/renderer_opengl/gl_shader_gen.h | |||
| @@ -19,10 +19,13 @@ constexpr size_t MAX_PROGRAM_CODE_LENGTH{0x1000}; | |||
| 19 | using ProgramCode = std::array<u64, MAX_PROGRAM_CODE_LENGTH>; | 19 | using ProgramCode = std::array<u64, MAX_PROGRAM_CODE_LENGTH>; |
| 20 | 20 | ||
| 21 | class ConstBufferEntry { | 21 | class ConstBufferEntry { |
| 22 | using Maxwell = Tegra::Engines::Maxwell3D::Regs; | ||
| 23 | |||
| 22 | public: | 24 | public: |
| 23 | void MarkAsUsed(unsigned index, unsigned offset) { | 25 | void MarkAsUsed(unsigned index, unsigned offset, Maxwell::ShaderStage stage) { |
| 24 | is_used = true; | 26 | is_used = true; |
| 25 | this->index = index; | 27 | this->index = index; |
| 28 | this->stage = stage; | ||
| 26 | max_offset = std::max(max_offset, offset); | 29 | max_offset = std::max(max_offset, offset); |
| 27 | } | 30 | } |
| 28 | 31 | ||
| @@ -38,10 +41,19 @@ public: | |||
| 38 | return max_offset + 1; | 41 | return max_offset + 1; |
| 39 | } | 42 | } |
| 40 | 43 | ||
| 44 | std::string GetName() const { | ||
| 45 | return BufferBaseNames[static_cast<size_t>(stage)] + std::to_string(index); | ||
| 46 | } | ||
| 47 | |||
| 41 | private: | 48 | private: |
| 49 | static constexpr std::array<const char*, Maxwell::MaxShaderStage> BufferBaseNames = { | ||
| 50 | "buffer_vs_c", "buffer_tessc_c", "buffer_tesse_c", "buffer_gs_c", "buffer_fs_c", | ||
| 51 | }; | ||
| 52 | |||
| 42 | bool is_used{}; | 53 | bool is_used{}; |
| 43 | unsigned index{}; | 54 | unsigned index{}; |
| 44 | unsigned max_offset{}; | 55 | unsigned max_offset{}; |
| 56 | Maxwell::ShaderStage stage; | ||
| 45 | }; | 57 | }; |
| 46 | 58 | ||
| 47 | struct ShaderEntries { | 59 | struct ShaderEntries { |
diff --git a/src/video_core/renderer_opengl/gl_shader_manager.h b/src/video_core/renderer_opengl/gl_shader_manager.h index ecc92d986..be63320e0 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.h +++ b/src/video_core/renderer_opengl/gl_shader_manager.h | |||
| @@ -121,6 +121,17 @@ public: | |||
| 121 | return result; | 121 | return result; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | GLuint GetCurrentProgramStage(Maxwell3D::Regs::ShaderStage stage) { | ||
| 125 | switch (stage) { | ||
| 126 | case Maxwell3D::Regs::ShaderStage::Vertex: | ||
| 127 | return current.vs; | ||
| 128 | case Maxwell3D::Regs::ShaderStage::Fragment: | ||
| 129 | return current.fs; | ||
| 130 | } | ||
| 131 | |||
| 132 | UNREACHABLE(); | ||
| 133 | } | ||
| 134 | |||
| 124 | void UseTrivialGeometryShader() { | 135 | void UseTrivialGeometryShader() { |
| 125 | current.gs = 0; | 136 | current.gs = 0; |
| 126 | } | 137 | } |
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index 6a80e6a7d..75c08e645 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -124,7 +124,7 @@ public: | |||
| 124 | GLuint shader_program; // GL_CURRENT_PROGRAM | 124 | GLuint shader_program; // GL_CURRENT_PROGRAM |
| 125 | GLuint program_pipeline; // GL_PROGRAM_PIPELINE_BINDING | 125 | GLuint program_pipeline; // GL_PROGRAM_PIPELINE_BINDING |
| 126 | struct ConstBufferConfig { | 126 | struct ConstBufferConfig { |
| 127 | bool enabled; | 127 | bool enabled = false; |
| 128 | GLuint bindpoint; | 128 | GLuint bindpoint; |
| 129 | GLuint ssbo; | 129 | GLuint ssbo; |
| 130 | }; | 130 | }; |