diff options
Diffstat (limited to '')
-rw-r--r-- | src/common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/common/code_block.h | 85 | ||||
-rw-r--r-- | src/core/file_sys/disk_filesystem.cpp | 2 | ||||
-rw-r--r-- | src/core/file_sys/disk_filesystem.h | 5 | ||||
-rw-r--r-- | src/core/hle/service/vi/vi.cpp | 14 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 42 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.h | 2 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_stream_buffer.h | 2 |
8 files changed, 42 insertions, 111 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index d6eb9055b..32cb85de0 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -34,7 +34,6 @@ add_library(common STATIC chunk_file.h cityhash.cpp cityhash.h - code_block.h color.h common_funcs.h common_paths.h diff --git a/src/common/code_block.h b/src/common/code_block.h deleted file mode 100644 index 6a55a8e30..000000000 --- a/src/common/code_block.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013 Dolphin Emulator Project -// Licensed under GPLv2 -// Refer to the license.txt file included. - -#pragma once - -#include <cstddef> -#include "common/common_types.h" -#include "common/memory_util.h" - -// Everything that needs to generate code should inherit from this. -// You get memory management for free, plus, you can use all emitter functions without -// having to prefix them with gen-> or something similar. -// Example implementation: -// class JIT : public CodeBlock<ARMXEmitter> {} -template <class T> -class CodeBlock : public T, NonCopyable { -private: - // A privately used function to set the executable RAM space to something invalid. - // For debugging usefulness it should be used to set the RAM to a host specific breakpoint - // instruction - virtual void PoisonMemory() = 0; - -protected: - u8* region; - size_t region_size; - -public: - CodeBlock() : region(nullptr), region_size(0) {} - virtual ~CodeBlock() { - if (region) - FreeCodeSpace(); - } - - // Call this before you generate any code. - void AllocCodeSpace(int size) { - region_size = size; - region = (u8*)AllocateExecutableMemory(region_size); - T::SetCodePtr(region); - } - - // Always clear code space with breakpoints, so that if someone accidentally executes - // uninitialized, it just breaks into the debugger. - void ClearCodeSpace() { - PoisonMemory(); - ResetCodePtr(); - } - - // Call this when shutting down. Don't rely on the destructor, even though it'll do the job. - void FreeCodeSpace() { -#ifdef __SYMBIAN32__ - ResetExecutableMemory(region); -#else - FreeMemoryPages(region, region_size); -#endif - region = nullptr; - region_size = 0; - } - - bool IsInSpace(const u8* ptr) { - return (ptr >= region) && (ptr < (region + region_size)); - } - - // Cannot currently be undone. Will write protect the entire code region. - // Start over if you need to change the code (call FreeCodeSpace(), AllocCodeSpace()). - void WriteProtect() { - WriteProtectMemory(region, region_size, true); - } - - void ResetCodePtr() { - T::SetCodePtr(region); - } - - size_t GetSpaceLeft() const { - return region_size - (T::GetCodePtr() - region); - } - - u8* GetBasePtr() { - return region; - } - - size_t GetOffset(const u8* ptr) const { - return ptr - region; - } -}; diff --git a/src/core/file_sys/disk_filesystem.cpp b/src/core/file_sys/disk_filesystem.cpp index 263392930..ca1323873 100644 --- a/src/core/file_sys/disk_filesystem.cpp +++ b/src/core/file_sys/disk_filesystem.cpp @@ -183,7 +183,7 @@ bool Disk_Storage::SetSize(const u64 size) const { return true; } -Disk_Directory::Disk_Directory(const std::string& path) : directory() { +Disk_Directory::Disk_Directory(const std::string& path) { unsigned size = FileUtil::ScanDirectoryTree(path, directory); directory.size = size; directory.isDirectory = true; diff --git a/src/core/file_sys/disk_filesystem.h b/src/core/file_sys/disk_filesystem.h index 05a29bc3a..8f9e1145a 100644 --- a/src/core/file_sys/disk_filesystem.h +++ b/src/core/file_sys/disk_filesystem.h @@ -43,7 +43,7 @@ protected: class Disk_Storage : public StorageBackend { public: - Disk_Storage(std::shared_ptr<FileUtil::IOFile> file) : file(std::move(file)) {} + explicit Disk_Storage(std::shared_ptr<FileUtil::IOFile> file) : file(std::move(file)) {} ResultVal<size_t> Read(u64 offset, size_t length, u8* buffer) const override; ResultVal<size_t> Write(u64 offset, size_t length, bool flush, const u8* buffer) const override; @@ -60,7 +60,7 @@ private: class Disk_Directory : public DirectoryBackend { public: - Disk_Directory(const std::string& path); + explicit Disk_Directory(const std::string& path); ~Disk_Directory() override { Close(); @@ -74,7 +74,6 @@ public: } protected: - u32 total_entries_in_directory; FileUtil::FSTEntry directory; // We need to remember the last entry we returned, so a subsequent call to Read will continue diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 7c319ee67..b712daa2b 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp @@ -150,7 +150,7 @@ private: class NativeWindow : public Parcel { public: - explicit NativeWindow(u32 id) : Parcel() { + explicit NativeWindow(u32 id) { data.id = id; } ~NativeWindow() override = default; @@ -197,7 +197,7 @@ public: class IGBPConnectResponseParcel : public Parcel { public: - explicit IGBPConnectResponseParcel(u32 width, u32 height) : Parcel() { + explicit IGBPConnectResponseParcel(u32 width, u32 height) { data.width = width; data.height = height; } @@ -247,10 +247,6 @@ public: }; class IGBPSetPreallocatedBufferResponseParcel : public Parcel { -public: - IGBPSetPreallocatedBufferResponseParcel() : Parcel() {} - ~IGBPSetPreallocatedBufferResponseParcel() override = default; - protected: void SerializeData() override { // TODO(Subv): Find out what this means @@ -289,7 +285,7 @@ static_assert(sizeof(BufferProducerFence) == 36, "BufferProducerFence has wrong class IGBPDequeueBufferResponseParcel : public Parcel { public: - explicit IGBPDequeueBufferResponseParcel(u32 slot) : Parcel(), slot(slot) {} + explicit IGBPDequeueBufferResponseParcel(u32 slot) : slot(slot) {} ~IGBPDequeueBufferResponseParcel() override = default; protected: @@ -383,7 +379,7 @@ public: class IGBPQueueBufferResponseParcel : public Parcel { public: - explicit IGBPQueueBufferResponseParcel(u32 width, u32 height) : Parcel() { + explicit IGBPQueueBufferResponseParcel(u32 width, u32 height) { data.width = width; data.height = height; } @@ -424,7 +420,7 @@ public: class IGBPQueryResponseParcel : public Parcel { public: - explicit IGBPQueryResponseParcel(u32 value) : Parcel(), value(value) {} + explicit IGBPQueryResponseParcel(u32 value) : value(value) {} ~IGBPQueryResponseParcel() override = default; protected: diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 4cc617c97..de137558d 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -5,6 +5,7 @@ #include <map> #include <set> #include <string> +#include <string_view> #include "common/assert.h" #include "common/common_types.h" #include "video_core/engines/shader_bytecode.h" @@ -109,12 +110,25 @@ private: class ShaderWriter { public: - void AddLine(const std::string& text) { + void AddLine(std::string_view text) { DEBUG_ASSERT(scope >= 0); if (!text.empty()) { - shader_source += std::string(static_cast<size_t>(scope) * 4, ' '); + AppendIndentation(); } - shader_source += text + '\n'; + shader_source += text; + AddNewLine(); + } + + void AddLine(char character) { + DEBUG_ASSERT(scope >= 0); + AppendIndentation(); + shader_source += character; + AddNewLine(); + } + + void AddNewLine() { + DEBUG_ASSERT(scope >= 0); + shader_source += '\n'; } std::string GetResult() { @@ -124,6 +138,10 @@ public: int scope = 0; private: + void AppendIndentation() { + shader_source.append(static_cast<size_t>(scope) * 4, ' '); + } + std::string shader_source; }; @@ -481,7 +499,7 @@ private: for (const auto& subroutine : subroutines) { shader.AddLine("bool " + subroutine.GetName() + "();"); } - shader.AddLine(""); + shader.AddNewLine(); // Add the main entry point shader.AddLine("bool exec_shader() {"); @@ -524,14 +542,14 @@ private: } --shader.scope; - shader.AddLine("}"); + shader.AddLine('}'); } shader.AddLine("default: return false;"); - shader.AddLine("}"); + shader.AddLine('}'); --shader.scope; - shader.AddLine("}"); + shader.AddLine('}'); shader.AddLine("return false;"); } @@ -558,7 +576,7 @@ private: for (const auto& reg : declr_register) { declarations.AddLine("float " + reg + " = 0.0;"); } - declarations.AddLine(""); + declarations.AddNewLine(); for (const auto& index : declr_input_attribute) { // TODO(bunnei): Use proper number of elements for these @@ -567,7 +585,7 @@ private: static_cast<u32>(Attribute::Index::Attribute_0)) + ") in vec4 " + GetInputAttribute(index) + ";"); } - declarations.AddLine(""); + declarations.AddNewLine(); for (const auto& index : declr_output_attribute) { // TODO(bunnei): Use proper number of elements for these @@ -576,15 +594,15 @@ private: static_cast<u32>(Attribute::Index::Attribute_0)) + ") out vec4 " + GetOutputAttribute(index) + ";"); } - declarations.AddLine(""); + declarations.AddNewLine(); unsigned const_buffer_layout = 0; for (const auto& entry : GetConstBuffersDeclarations()) { declarations.AddLine("layout(std430) buffer " + entry.GetName()); - declarations.AddLine("{"); + declarations.AddLine('{'); declarations.AddLine(" float c" + std::to_string(entry.GetIndex()) + "[];"); declarations.AddLine("};"); - declarations.AddLine(""); + declarations.AddNewLine(); ++const_buffer_layout; } } diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.h b/src/video_core/renderer_opengl/gl_shader_decompiler.h index 9f6e0ef58..382c76b7a 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.h +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.h @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#pragma once + #include <array> #include <functional> #include <string> diff --git a/src/video_core/renderer_opengl/gl_stream_buffer.h b/src/video_core/renderer_opengl/gl_stream_buffer.h index 4bc2f52e0..e78dc5784 100644 --- a/src/video_core/renderer_opengl/gl_stream_buffer.h +++ b/src/video_core/renderer_opengl/gl_stream_buffer.h @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#pragma once + #include <memory> #include <glad/glad.h> #include "common/common_types.h" |