Misc: Pass string_view by value

This commit is contained in:
Stenzek
2024-05-05 20:21:54 +10:00
parent e4d940a476
commit ca3cfbaa99
111 changed files with 543 additions and 542 deletions
+2 -2
View File
@@ -346,7 +346,7 @@ bool CDImage::HasNonStandardSubchannel() const
return false;
}
std::string CDImage::GetMetadata(const std::string_view& type) const
std::string CDImage::GetMetadata(std::string_view type) const
{
std::string result;
if (type == "title")
@@ -378,7 +378,7 @@ bool CDImage::SwitchSubImage(u32 index, Error* error)
return false;
}
std::string CDImage::GetSubImageMetadata(u32 index, const std::string_view& type) const
std::string CDImage::GetSubImageMetadata(u32 index, std::string_view type) const
{
return {};
}
+2 -2
View File
@@ -307,7 +307,7 @@ public:
virtual bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) = 0;
// Retrieve image metadata.
virtual std::string GetMetadata(const std::string_view& type) const;
virtual std::string GetMetadata(std::string_view type) const;
// Returns true if this image type has sub-images (e.g. m3u).
virtual bool HasSubImages() const;
@@ -322,7 +322,7 @@ public:
virtual bool SwitchSubImage(u32 index, Error* error);
// Retrieve sub-image metadata.
virtual std::string GetSubImageMetadata(u32 index, const std::string_view& type) const;
virtual std::string GetSubImageMetadata(u32 index, std::string_view type) const;
// Returns true if the source supports precaching, which may be more optimal than an in-memory copy.
virtual PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback);
+1 -1
View File
@@ -95,7 +95,7 @@ std::string CDImageHasher::HashToString(const Hash& hash)
hash[11], hash[12], hash[13], hash[14], hash[15]);
}
std::optional<CDImageHasher::Hash> CDImageHasher::HashFromString(const std::string_view& str)
std::optional<CDImageHasher::Hash> CDImageHasher::HashFromString(std::string_view str)
{
auto decoded = StringUtil::DecodeHex(str);
if (decoded && decoded->size() == std::tuple_size_v<Hash>)
+1 -1
View File
@@ -14,7 +14,7 @@ namespace CDImageHasher {
using Hash = std::array<u8, 16>;
std::string HashToString(const Hash& hash);
std::optional<Hash> HashFromString(const std::string_view& str);
std::optional<Hash> HashFromString(std::string_view str);
bool GetImageHash(CDImage* image, Hash* out_hash,
ProgressCallback* progress_callback = ProgressCallback::NullProgressCallback);
+2 -2
View File
@@ -33,7 +33,7 @@ public:
bool HasSubImages() const override;
u32 GetSubImageCount() const override;
u32 GetCurrentSubImage() const override;
std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override;
std::string GetSubImageMetadata(u32 index, std::string_view type) const override;
bool SwitchSubImage(u32 index, Error* error) override;
protected:
@@ -159,7 +159,7 @@ bool CDImageM3u::SwitchSubImage(u32 index, Error* error)
return true;
}
std::string CDImageM3u::GetSubImageMetadata(u32 index, const std::string_view& type) const
std::string CDImageM3u::GetSubImageMetadata(u32 index, std::string_view type) const
{
if (index > m_entries.size())
return {};
+4 -4
View File
@@ -141,8 +141,8 @@ public:
u32 GetSubImageCount() const override;
u32 GetCurrentSubImage() const override;
bool SwitchSubImage(u32 index, Error* error) override;
std::string GetMetadata(const std::string_view& type) const override;
std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override;
std::string GetMetadata(std::string_view type) const override;
std::string GetSubImageMetadata(u32 index, std::string_view type) const override;
protected:
bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) override;
@@ -915,7 +915,7 @@ bool CDImagePBP::HasSubImages() const
return m_disc_offsets.size() > 1;
}
std::string CDImagePBP::GetMetadata(const std::string_view& type) const
std::string CDImagePBP::GetMetadata(std::string_view type) const
{
if (type == "title")
{
@@ -953,7 +953,7 @@ bool CDImagePBP::SwitchSubImage(u32 index, Error* error)
return true;
}
std::string CDImagePBP::GetSubImageMetadata(u32 index, const std::string_view& type) const
std::string CDImagePBP::GetSubImageMetadata(u32 index, std::string_view type) const
{
if (type == "title")
{
+4 -4
View File
@@ -35,8 +35,8 @@ public:
bool HasNonStandardSubchannel() const override;
s64 GetSizeOnDisk() const override;
std::string GetMetadata(const std::string_view& type) const override;
std::string GetSubImageMetadata(u32 index, const std::string_view& type) const override;
std::string GetMetadata(std::string_view type) const override;
std::string GetSubImageMetadata(u32 index, std::string_view type) const override;
PrecacheResult Precache(ProgressCallback* progress = ProgressCallback::NullProgressCallback) override;
@@ -416,12 +416,12 @@ bool CDImagePPF::HasNonStandardSubchannel() const
return m_parent_image->HasNonStandardSubchannel();
}
std::string CDImagePPF::GetMetadata(const std::string_view& type) const
std::string CDImagePPF::GetMetadata(std::string_view type) const
{
return m_parent_image->GetMetadata(type);
}
std::string CDImagePPF::GetSubImageMetadata(u32 index, const std::string_view& type) const
std::string CDImagePPF::GetSubImageMetadata(u32 index, std::string_view type) const
{
// We only support a single sub-image for patched games.
std::string ret;
+3 -3
View File
@@ -12,10 +12,10 @@
Log_SetChannel(CueParser);
namespace CueParser {
static bool TokenMatch(const std::string_view& s1, const char* token);
static bool TokenMatch(std::string_view s1, const char* token);
}
bool CueParser::TokenMatch(const std::string_view& s1, const char* token)
bool CueParser::TokenMatch(std::string_view s1, const char* token)
{
const size_t token_len = std::strlen(token);
if (s1.length() != token_len)
@@ -124,7 +124,7 @@ std::string_view CueParser::File::GetToken(const char*& line)
return ret;
}
std::optional<CueParser::MSF> CueParser::File::GetMSF(const std::string_view& token)
std::optional<CueParser::MSF> CueParser::File::GetMSF(std::string_view token)
{
static const s32 max_values[] = {std::numeric_limits<s32>::max(), 60, 75};
+1 -1
View File
@@ -68,7 +68,7 @@ private:
void SetError(u32 line_number, Error* error, const char* format, ...);
static std::string_view GetToken(const char*& line);
static std::optional<MSF> GetMSF(const std::string_view& token);
static std::optional<MSF> GetMSF(std::string_view token);
bool ParseLine(const char* line, u32 line_number, Error* error);
+4 -3
View File
@@ -31,7 +31,7 @@ static std::mutex s_instance_mutex;
static constexpr std::array<float, 4> s_clear_color = {};
static constexpr GPUTexture::Format s_swap_chain_format = GPUTexture::Format::RGBA8;
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, const std::string_view& name)
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name)
{
#ifdef _DEBUG
// WKPDID_D3DDebugObjectName
@@ -64,7 +64,7 @@ bool D3D11Device::HasSurface() const
return static_cast<bool>(m_swap_chain);
}
bool D3D11Device::CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool D3D11Device::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error)
{
@@ -943,7 +943,8 @@ void D3D11Device::UnmapUniformBuffer(u32 size)
}
}
void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTexture* ds, GPUPipeline::RenderPassFlag feedback_loop)
void D3D11Device::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUTexture* ds,
GPUPipeline::RenderPassFlag feedback_loop)
{
ID3D11RenderTargetView* rtvs[MAX_RENDER_TARGETS];
DebugAssert(!feedback_loop);
+3 -3
View File
@@ -69,7 +69,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, DynamicHeapArray<u8>* binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@@ -111,7 +111,7 @@ public:
static AdapterAndModeList StaticGetAdapterAndModeList();
protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override;
void DestroyDevice() override;
@@ -204,4 +204,4 @@ private:
float m_accumulated_gpu_time = 0.0f;
};
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, const std::string_view& name);
void SetD3DDebugObjectName(ID3D11DeviceChild* obj, std::string_view name);
+3 -3
View File
@@ -46,7 +46,7 @@ ID3D11ComputeShader* D3D11Shader::GetComputeShader() const
return static_cast<ID3D11ComputeShader*>(m_shader.Get());
}
void D3D11Shader::SetDebugName(const std::string_view& name)
void D3D11Shader::SetDebugName(std::string_view name)
{
SetD3DDebugObjectName(m_shader.Get(), name);
}
@@ -92,7 +92,7 @@ std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromBinary(GPUShaderStage st
return std::unique_ptr<GPUShader>(new D3D11Shader(stage, std::move(shader), std::move(bytecode)));
}
std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point,
DynamicHeapArray<u8>* out_binary)
{
@@ -123,7 +123,7 @@ D3D11Pipeline::~D3D11Pipeline()
D3D11Device::GetInstance().UnbindPipeline(this);
}
void D3D11Pipeline::SetDebugName(const std::string_view& name)
void D3D11Pipeline::SetDebugName(std::string_view name)
{
// can't label this directly
}
+2 -2
View File
@@ -30,7 +30,7 @@ public:
ALWAYS_INLINE const std::vector<u8>& GetBytecode() const { return m_bytecode; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
D3D11Shader(GPUShaderStage stage, Microsoft::WRL::ComPtr<ID3D11DeviceChild> shader, std::vector<u8> bytecode);
@@ -49,7 +49,7 @@ class D3D11Pipeline final : public GPUPipeline
public:
~D3D11Pipeline() override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
ALWAYS_INLINE ID3D11RasterizerState* GetRasterizerState() const { return m_rs.Get(); }
ALWAYS_INLINE ID3D11DepthStencilState* GetDepthStencilState() const { return m_ds.Get(); }
+3 -3
View File
@@ -38,7 +38,7 @@ D3D11Sampler::D3D11Sampler(ComPtr<ID3D11SamplerState> ss) : m_ss(std::move(ss))
D3D11Sampler::~D3D11Sampler() = default;
void D3D11Sampler::SetDebugName(const std::string_view& name)
void D3D11Sampler::SetDebugName(std::string_view name)
{
SetD3DDebugObjectName(m_ss.Get(), name);
}
@@ -209,7 +209,7 @@ void D3D11Texture::Unmap()
m_mapped_subresource = 0;
}
void D3D11Texture::SetDebugName(const std::string_view& name)
void D3D11Texture::SetDebugName(std::string_view name)
{
SetD3DDebugObjectName(m_texture.Get(), name);
}
@@ -376,7 +376,7 @@ void D3D11TextureBuffer::Unmap(u32 used_elements)
m_buffer.Unmap(D3D11Device::GetD3DContext(), size);
}
void D3D11TextureBuffer::SetDebugName(const std::string_view& name)
void D3D11TextureBuffer::SetDebugName(std::string_view name)
{
SetD3DDebugObjectName(m_buffer.GetD3DBuffer(), name);
}
+3 -3
View File
@@ -26,7 +26,7 @@ public:
ALWAYS_INLINE ID3D11SamplerState* GetSamplerState() const { return m_ss.Get(); }
ALWAYS_INLINE ID3D11SamplerState* const* GetSamplerStateArray() const { return m_ss.GetAddressOf(); }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
D3D11Sampler(ComPtr<ID3D11SamplerState> ss);
@@ -85,7 +85,7 @@ public:
bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override;
void Unmap() override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
D3D11Texture(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type, Format format,
@@ -113,7 +113,7 @@ public:
void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
D3D11StreamBuffer m_buffer;
+1 -1
View File
@@ -336,7 +336,7 @@ u32 D3D12::RootSignatureBuilder::AddDescriptorTable(D3D12_DESCRIPTOR_RANGE_TYPE
#ifdef _DEBUG
void D3D12::SetObjectName(ID3D12Object* object, const std::string_view& name)
void D3D12::SetObjectName(ID3D12Object* object, std::string_view name)
{
object->SetName(StringUtil::UTF8StringToWideString(name).c_str());
}
+2 -2
View File
@@ -126,10 +126,10 @@ private:
};
#ifdef _DEBUG
void SetObjectName(ID3D12Object* object, const std::string_view& name);
void SetObjectName(ID3D12Object* object, std::string_view name);
void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...);
#else
static inline void SetObjectName(ID3D12Object* object, const std::string_view& name)
static inline void SetObjectName(ID3D12Object* object, std::string_view name)
{
}
static inline void SetObjectNameFormatted(ID3D12Object* object, const char* format, ...)
+1 -1
View File
@@ -117,7 +117,7 @@ D3D12Device::ComPtr<ID3D12RootSignature> D3D12Device::CreateRootSignature(const
return rs;
}
bool D3D12Device::CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error)
{
+2 -2
View File
@@ -91,7 +91,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@@ -180,7 +180,7 @@ public:
void UnbindTextureBuffer(D3D12TextureBuffer* buf);
protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override;
void DestroyDevice() override;
+3 -3
View File
@@ -21,7 +21,7 @@ D3D12Shader::D3D12Shader(GPUShaderStage stage, Bytecode bytecode) : GPUShader(st
D3D12Shader::~D3D12Shader() = default;
void D3D12Shader::SetDebugName(const std::string_view& name)
void D3D12Shader::SetDebugName(std::string_view name)
{
}
@@ -32,7 +32,7 @@ std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromBinary(GPUShaderStage st
return std::unique_ptr<GPUShader>(new D3D12Shader(stage, std::move(bytecode)));
}
std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point,
DynamicHeapArray<u8>* out_binary)
{
@@ -63,7 +63,7 @@ D3D12Pipeline::~D3D12Pipeline()
D3D12Device::GetInstance().DeferObjectDestruction(std::move(m_pipeline));
}
void D3D12Pipeline::SetDebugName(const std::string_view& name)
void D3D12Pipeline::SetDebugName(std::string_view name)
{
D3D12::SetObjectName(m_pipeline.Get(), name);
}
+2 -2
View File
@@ -25,7 +25,7 @@ public:
ALWAYS_INLINE const u8* GetBytecodeData() const { return m_bytecode.data(); }
ALWAYS_INLINE u32 GetBytecodeSize() const { return static_cast<u32>(m_bytecode.size()); }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
D3D12Shader(GPUShaderStage stage, Bytecode bytecode);
@@ -48,7 +48,7 @@ public:
ALWAYS_INLINE const std::array<float, 4>& GetBlendConstantsF() const { return m_blend_constants_f; }
ALWAYS_INLINE bool HasVertexStride() const { return (m_vertex_stride > 0); }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
static std::string GetPipelineName(const GraphicsConfig& config);
+3 -3
View File
@@ -591,7 +591,7 @@ void D3D12Texture::ActuallyCommitClear(ID3D12GraphicsCommandList* cmdlist)
SetState(State::Dirty);
}
void D3D12Texture::SetDebugName(const std::string_view& name)
void D3D12Texture::SetDebugName(std::string_view name)
{
D3D12::SetObjectName(m_resource.Get(), name);
}
@@ -673,7 +673,7 @@ D3D12Sampler::~D3D12Sampler()
// Cleaned up by main class.
}
void D3D12Sampler::SetDebugName(const std::string_view& name)
void D3D12Sampler::SetDebugName(std::string_view name)
{
}
@@ -813,7 +813,7 @@ void D3D12TextureBuffer::Unmap(u32 used_elements)
m_buffer.CommitMemory(size);
}
void D3D12TextureBuffer::SetDebugName(const std::string_view& name)
void D3D12TextureBuffer::SetDebugName(std::string_view name)
{
D3D12::SetObjectName(m_buffer.GetBuffer(), name);
}
+3 -3
View File
@@ -42,7 +42,7 @@ public:
void Unmap() override;
void MakeReadyForSampling() override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
void TransitionToState(D3D12_RESOURCE_STATES state);
void CommitClear();
@@ -115,7 +115,7 @@ public:
ALWAYS_INLINE const D3D12DescriptorHandle& GetDescriptor() const { return m_descriptor; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
D3D12Sampler(D3D12DescriptorHandle descriptor);
@@ -140,7 +140,7 @@ public:
void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
D3D12StreamBuffer m_buffer;
+4 -5
View File
@@ -134,7 +134,7 @@ std::vector<std::string> D3DCommon::GetAdapterNames(IDXGIFactory5* factory)
return adapter_names;
}
std::vector<std::string> D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name)
std::vector<std::string> D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, std::string_view adapter_name)
{
std::vector<std::string> modes;
HRESULT hr;
@@ -250,7 +250,7 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory,
return true;
}
Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name)
Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetAdapterByName(IDXGIFactory5* factory, std::string_view name)
{
if (name.empty())
return {};
@@ -296,8 +296,7 @@ Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetFirstAdapter(IDXGIFactory5*
return adapter;
}
Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetChosenOrFirstAdapter(IDXGIFactory5* factory,
const std::string_view& name)
Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetChosenOrFirstAdapter(IDXGIFactory5* factory, std::string_view name)
{
Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter = GetAdapterByName(factory, name);
if (!adapter)
@@ -374,7 +373,7 @@ std::string D3DCommon::GetDriverVersionFromLUID(const LUID& luid)
}
std::optional<DynamicHeapArray<u8>> D3DCommon::CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device,
GPUShaderStage stage, const std::string_view& source,
GPUShaderStage stage, std::string_view source,
const char* entry_point)
{
const char* target;
+4 -4
View File
@@ -38,7 +38,7 @@ Microsoft::WRL::ComPtr<IDXGIFactory5> CreateFactory(bool debug, Error* error);
std::vector<std::string> GetAdapterNames(IDXGIFactory5* factory);
// returns a list of fullscreen modes for the specified adapter
std::vector<std::string> GetFullscreenModes(IDXGIFactory5* factory, const std::string_view& adapter_name);
std::vector<std::string> GetFullscreenModes(IDXGIFactory5* factory, std::string_view adapter_name);
// returns the fullscreen mode to use for the specified dimensions
bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT& window_rect, u32 width, u32 height,
@@ -46,13 +46,13 @@ bool GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory, const RECT&
IDXGIOutput** output);
// get an adapter based on name
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetAdapterByName(IDXGIFactory5* factory, const std::string_view& name);
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetAdapterByName(IDXGIFactory5* factory, std::string_view name);
// returns the first adapter in the system
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetFirstAdapter(IDXGIFactory5* factory);
// returns the adapter specified in the configuration, or the default
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetChosenOrFirstAdapter(IDXGIFactory5* factory, const std::string_view& name);
Microsoft::WRL::ComPtr<IDXGIAdapter1> GetChosenOrFirstAdapter(IDXGIFactory5* factory, std::string_view name);
// returns a utf-8 string of the specified adapter's name
std::string GetAdapterName(IDXGIAdapter1* adapter);
@@ -61,7 +61,7 @@ std::string GetAdapterName(IDXGIAdapter1* adapter);
std::string GetDriverVersionFromLUID(const LUID& luid);
std::optional<DynamicHeapArray<u8>> CompileShader(D3D_FEATURE_LEVEL feature_level, bool debug_device,
GPUShaderStage stage, const std::string_view& source,
GPUShaderStage stage, std::string_view source,
const char* entry_point);
struct DXGIFormatMapping
+2 -3
View File
@@ -307,7 +307,7 @@ std::vector<InputBindingKey> DInputSource::EnumerateMotors()
return {};
}
bool DInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping)
bool DInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{
return {};
}
@@ -323,8 +323,7 @@ void DInputSource::UpdateMotorState(InputBindingKey large_key, InputBindingKey s
// not supported
}
std::optional<InputBindingKey> DInputSource::ParseKeyString(const std::string_view& device,
const std::string_view& binding)
std::optional<InputBindingKey> DInputSource::ParseKeyString(std::string_view device, std::string_view binding)
{
if (!device.starts_with("DInput-") || binding.empty())
return std::nullopt;
+2 -3
View File
@@ -41,13 +41,12 @@ public:
void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override;
bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity,
float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device,
const std::string_view& binding) override;
std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override;
+6 -6
View File
@@ -270,8 +270,8 @@ bool GPUDevice::IsSameRenderAPI(RenderAPI lhs, RenderAPI rhs)
(rhs == RenderAPI::OpenGL || rhs == RenderAPI::OpenGLES)));
}
bool GPUDevice::Create(const std::string_view& adapter, const std::string_view& shader_cache_path,
u32 shader_cache_version, bool debug_device, bool vsync, bool threaded_presentation,
bool GPUDevice::Create(std::string_view adapter, std::string_view shader_cache_path, u32 shader_cache_version,
bool debug_device, bool vsync, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, Error* error)
{
m_vsync_enabled = vsync;
@@ -318,7 +318,7 @@ bool GPUDevice::SupportsExclusiveFullscreen() const
return false;
}
void GPUDevice::OpenShaderCache(const std::string_view& base_path, u32 version)
void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
{
if (m_features.shader_cache && !base_path.empty())
{
@@ -388,7 +388,7 @@ void GPUDevice::CloseShaderCache()
}
}
std::string GPUDevice::GetShaderCacheBaseName(const std::string_view& type) const
std::string GPUDevice::GetShaderCacheBaseName(std::string_view type) const
{
const std::string_view debug_suffix = m_debug_device ? "_debug" : "";
@@ -641,7 +641,7 @@ void GPUDevice::InvalidateRenderTarget(GPUTexture* t)
t->SetState(GPUTexture::State::Invalidated);
}
std::unique_ptr<GPUShader> GPUDevice::CreateShader(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> GPUDevice::CreateShader(GPUShaderStage stage, std::string_view source,
const char* entry_point /* = "main" */)
{
std::unique_ptr<GPUShader> shader;
@@ -730,7 +730,7 @@ std::string GPUDevice::GetFullscreenModeString(u32 width, u32 height, float refr
return fmt::format("{} x {} @ {} hz", width, height, refresh_rate);
}
std::string GPUDevice::GetShaderDumpPath(const std::string_view& name)
std::string GPUDevice::GetShaderDumpPath(std::string_view name)
{
return Path::Combine(EmuFolders::Dumps, name);
}
+13 -13
View File
@@ -88,7 +88,7 @@ public:
GPUSampler();
virtual ~GPUSampler();
virtual void SetDebugName(const std::string_view& name) = 0;
virtual void SetDebugName(std::string_view name) = 0;
static Config GetNearestConfig();
static Config GetLinearConfig();
@@ -114,7 +114,7 @@ public:
ALWAYS_INLINE GPUShaderStage GetStage() const { return m_stage; }
virtual void SetDebugName(const std::string_view& name) = 0;
virtual void SetDebugName(std::string_view name) = 0;
protected:
GPUShaderStage m_stage;
@@ -397,7 +397,7 @@ public:
GPUPipeline();
virtual ~GPUPipeline();
virtual void SetDebugName(const std::string_view& name) = 0;
virtual void SetDebugName(std::string_view name) = 0;
};
class GPUTextureBuffer
@@ -423,7 +423,7 @@ public:
virtual void* Map(u32 required_elements) = 0;
virtual void Unmap(u32 used_elements) = 0;
virtual void SetDebugName(const std::string_view& name) = 0;
virtual void SetDebugName(std::string_view name) = 0;
protected:
Format m_format;
@@ -527,7 +527,7 @@ public:
static std::string GetFullscreenModeString(u32 width, u32 height, float refresh_rate);
/// Returns the directory bad shaders are saved to.
static std::string GetShaderDumpPath(const std::string_view& name);
static std::string GetShaderDumpPath(std::string_view name);
/// Dumps out a shader that failed compilation.
static void DumpBadShader(std::string_view code, std::string_view errors);
@@ -572,9 +572,9 @@ public:
virtual RenderAPI GetRenderAPI() const = 0;
bool Create(const std::string_view& adapter, const std::string_view& shader_cache_path, u32 shader_cache_version,
bool debug_device, bool vsync, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features, Error* error);
bool Create(std::string_view adapter, std::string_view shader_cache_path, u32 shader_cache_version, bool debug_device,
bool vsync, bool threaded_presentation, std::optional<bool> exclusive_fullscreen_control,
FeatureMask disabled_features, Error* error);
void Destroy();
virtual bool HasSurface() const = 0;
@@ -622,7 +622,7 @@ public:
virtual void InvalidateRenderTarget(GPUTexture* t);
/// Shader abstraction.
std::unique_ptr<GPUShader> CreateShader(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> CreateShader(GPUShaderStage stage, std::string_view source,
const char* entry_point = "main");
virtual std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) = 0;
@@ -701,17 +701,17 @@ public:
static void ResetStatistics();
protected:
virtual bool CreateDevice(const std::string_view& adapter, bool threaded_presentation,
virtual bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) = 0;
virtual void DestroyDevice() = 0;
std::string GetShaderCacheBaseName(const std::string_view& type) const;
std::string GetShaderCacheBaseName(std::string_view type) const;
virtual bool ReadPipelineCache(const std::string& filename);
virtual bool GetPipelineCacheData(DynamicHeapArray<u8>* data);
virtual std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) = 0;
virtual std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
virtual std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point,
DynamicHeapArray<u8>* out_binary) = 0;
@@ -764,7 +764,7 @@ private:
using TexturePool = std::deque<TexturePoolEntry>;
void OpenShaderCache(const std::string_view& base_path, u32 version);
void OpenShaderCache(std::string_view base_path, u32 version);
void CloseShaderCache();
bool CreateResources();
void DestroyResources();
+3 -3
View File
@@ -56,7 +56,7 @@ std::size_t GPUShaderCache::CacheIndexEntryHash::operator()(const CacheIndexKey&
return h;
}
bool GPUShaderCache::Open(const std::string_view& base_filename, u32 version)
bool GPUShaderCache::Open(std::string_view base_filename, u32 version)
{
m_base_filename = base_filename;
m_version = version;
@@ -214,8 +214,8 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
return true;
}
GPUShaderCache::CacheIndexKey GPUShaderCache::GetCacheKey(GPUShaderStage stage, const std::string_view& shader_code,
const std::string_view& entry_point)
GPUShaderCache::CacheIndexKey GPUShaderCache::GetCacheKey(GPUShaderStage stage, std::string_view shader_code,
std::string_view entry_point)
{
union
{
+2 -3
View File
@@ -46,12 +46,11 @@ public:
bool IsOpen() const { return (m_index_file != nullptr); }
bool Open(const std::string_view& base_filename, u32 version);
bool Open(std::string_view base_filename, u32 version);
bool Create();
void Close();
static CacheIndexKey GetCacheKey(GPUShaderStage stage, const std::string_view& shader_code,
const std::string_view& entry_point);
static CacheIndexKey GetCacheKey(GPUShaderStage stage, std::string_view shader_code, std::string_view entry_point);
bool Lookup(const CacheIndexKey& key, ShaderBinary* binary);
bool Insert(const CacheIndexKey& key, const void* data, u32 data_size);
+1 -1
View File
@@ -156,7 +156,7 @@ public:
// Instructs the backend that we're finished rendering to this texture. It may transition it to a new layout.
virtual void MakeReadyForSampling();
virtual void SetDebugName(const std::string_view& name) = 0;
virtual void SetDebugName(std::string_view name) = 0;
protected:
GPUTexture(u16 width, u16 height, u8 layers, u8 levels, u8 samples, Type type, Format format);
+7 -8
View File
@@ -14,8 +14,7 @@
Log_SetChannel(Host);
namespace Host {
static std::pair<const char*, u32> LookupTranslationString(const std::string_view& context,
const std::string_view& msg);
static std::pair<const char*, u32> LookupTranslationString(std::string_view context, std::string_view msg);
static constexpr u32 TRANSLATION_STRING_CACHE_SIZE = 4 * 1024 * 1024;
using TranslationStringMap = PreferUnorderedStringMap<std::pair<u32, u32>>;
@@ -26,7 +25,7 @@ static std::vector<char> s_translation_string_cache;
static u32 s_translation_string_cache_pos;
} // namespace Host
std::pair<const char*, u32> Host::LookupTranslationString(const std::string_view& context, const std::string_view& msg)
std::pair<const char*, u32> Host::LookupTranslationString(std::string_view context, std::string_view msg)
{
// TODO: TranslatableString, compile-time hashing.
@@ -103,18 +102,18 @@ add_string:
return ret;
}
const char* Host::TranslateToCString(const std::string_view& context, const std::string_view& msg)
const char* Host::TranslateToCString(std::string_view context, std::string_view msg)
{
return LookupTranslationString(context, msg).first;
}
std::string_view Host::TranslateToStringView(const std::string_view& context, const std::string_view& msg)
std::string_view Host::TranslateToStringView(std::string_view context, std::string_view msg)
{
const auto mp = LookupTranslationString(context, msg);
return std::string_view(mp.first, mp.second);
}
std::string Host::TranslateToString(const std::string_view& context, const std::string_view& msg)
std::string Host::TranslateToString(std::string_view context, std::string_view msg)
{
return std::string(TranslateToStringView(context, msg));
}
@@ -127,7 +126,7 @@ void Host::ClearTranslationCache()
s_translation_string_mutex.unlock();
}
void Host::ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...)
void Host::ReportFormattedErrorAsync(std::string_view title, const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
@@ -136,7 +135,7 @@ void Host::ReportFormattedErrorAsync(const std::string_view& title, const char*
ReportErrorAsync(title, message);
}
bool Host::ConfirmFormattedMessage(const std::string_view& title, const char* format, ...)
bool Host::ConfirmFormattedMessage(std::string_view title, const char* format, ...)
{
std::va_list ap;
va_start(ap, format);
+12 -13
View File
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
#pragma once
@@ -27,45 +27,44 @@ std::optional<std::time_t> GetResourceFileTimestamp(std::string_view filename, b
/// Reports a fatal error on the main thread. This does not assume that the main window exists,
/// unlike ReportErrorAsync(), and will exit the application after the popup is closed.
void ReportFatalError(const std::string_view& title, const std::string_view& message);
void ReportFatalError(std::string_view title, std::string_view message);
/// Displays an asynchronous error on the UI thread, i.e. doesn't block the caller.
void ReportErrorAsync(const std::string_view& title, const std::string_view& message);
void ReportFormattedErrorAsync(const std::string_view& title, const char* format, ...);
void ReportErrorAsync(std::string_view title, std::string_view message);
void ReportFormattedErrorAsync(std::string_view title, const char* format, ...);
/// Displays a synchronous confirmation on the UI thread, i.e. blocks the caller.
bool ConfirmMessage(const std::string_view& title, const std::string_view& message);
bool ConfirmFormattedMessage(const std::string_view& title, const char* format, ...);
bool ConfirmMessage(std::string_view title, std::string_view message);
bool ConfirmFormattedMessage(std::string_view title, const char* format, ...);
/// Returns the user agent to use for HTTP requests.
std::string GetHTTPUserAgent();
/// Opens a URL, using the default application.
void OpenURL(const std::string_view& url);
void OpenURL(std::string_view url);
/// Copies the provided text to the host's clipboard, if present.
bool CopyTextToClipboard(const std::string_view& text);
bool CopyTextToClipboard(std::string_view text);
/// Returns a localized version of the specified string within the specified context.
/// The pointer is guaranteed to be valid until the next language change.
const char* TranslateToCString(const std::string_view& context, const std::string_view& msg);
const char* TranslateToCString(std::string_view context, std::string_view msg);
/// Returns a localized version of the specified string within the specified context.
/// The view is guaranteed to be valid until the next language change.
/// NOTE: When passing this to fmt, positional arguments should be used in the base string, as
/// not all locales follow the same word ordering.
std::string_view TranslateToStringView(const std::string_view& context, const std::string_view& msg);
std::string_view TranslateToStringView(std::string_view context, std::string_view msg);
/// Returns a localized version of the specified string within the specified context.
std::string TranslateToString(const std::string_view& context, const std::string_view& msg);
std::string TranslateToString(std::string_view context, std::string_view msg);
/// Clears the translation cache. All previously used strings should be considered invalid.
void ClearTranslationCache();
namespace Internal {
/// Implementation to retrieve a translated string.
s32 GetTranslatedStringImpl(const std::string_view& context, const std::string_view& msg, char* tbuf,
size_t tbuf_space);
s32 GetTranslatedStringImpl(std::string_view context, std::string_view msg, char* tbuf, size_t tbuf_space);
} // namespace Internal
} // namespace Host
+23 -23
View File
@@ -27,26 +27,26 @@ Log_SetChannel(Image);
static bool PNGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size);
static bool PNGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality);
static bool PNGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp);
static bool PNGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality);
static bool PNGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp);
static bool PNGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality);
static bool JPEGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size);
static bool JPEGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality);
static bool JPEGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp);
static bool JPEGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality);
static bool JPEGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp);
static bool JPEGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality);
static bool WebPBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size);
static bool WebPBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 quality);
static bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp);
static bool WebPFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality);
static bool WebPFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp);
static bool WebPFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality);
struct FormatHandler
{
const char* extension;
bool (*buffer_loader)(RGBA8Image*, const void*, size_t);
bool (*buffer_saver)(const RGBA8Image&, std::vector<u8>*, u8);
bool (*file_loader)(RGBA8Image*, const char*, std::FILE*);
bool (*file_saver)(const RGBA8Image&, const char*, std::FILE*, u8);
bool (*file_loader)(RGBA8Image*, std::string_view, std::FILE*);
bool (*file_saver)(const RGBA8Image&, std::string_view, std::FILE*, u8);
};
static constexpr FormatHandler s_format_handlers[] = {
@@ -56,7 +56,7 @@ static constexpr FormatHandler s_format_handlers[] = {
{"webp", WebPBufferLoader, WebPBufferSaver, WebPFileLoader, WebPFileSaver},
};
static const FormatHandler* GetFormatHandler(const std::string_view& extension)
static const FormatHandler* GetFormatHandler(std::string_view extension)
{
for (const FormatHandler& handler : s_format_handlers)
{
@@ -125,39 +125,39 @@ bool RGBA8Image::SaveToFile(const char* filename, u8 quality) const
return false;
}
bool RGBA8Image::LoadFromFile(const char* filename, std::FILE* fp)
bool RGBA8Image::LoadFromFile(std::string_view filename, std::FILE* fp)
{
const std::string_view extension(Path::GetExtension(filename));
const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->file_loader)
{
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data());
Log_ErrorFmt("Unknown extension '{}'", extension);
return false;
}
return handler->file_loader(this, filename, fp);
}
bool RGBA8Image::LoadFromBuffer(const char* filename, const void* buffer, size_t buffer_size)
bool RGBA8Image::LoadFromBuffer(std::string_view filename, const void* buffer, size_t buffer_size)
{
const std::string_view extension(Path::GetExtension(filename));
const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->buffer_loader)
{
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data());
Log_ErrorFmt("Unknown extension '{}'", extension);
return false;
}
return handler->buffer_loader(this, buffer, buffer_size);
}
bool RGBA8Image::SaveToFile(const char* filename, std::FILE* fp, u8 quality) const
bool RGBA8Image::SaveToFile(std::string_view filename, std::FILE* fp, u8 quality) const
{
const std::string_view extension(Path::GetExtension(filename));
const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->file_saver)
{
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data());
Log_ErrorFmt("Unknown extension '{}'", extension);
return false;
}
@@ -167,7 +167,7 @@ bool RGBA8Image::SaveToFile(const char* filename, std::FILE* fp, u8 quality) con
return (std::fflush(fp) == 0);
}
std::optional<std::vector<u8>> RGBA8Image::SaveToBuffer(const char* filename, u8 quality) const
std::optional<std::vector<u8>> RGBA8Image::SaveToBuffer(std::string_view filename, u8 quality) const
{
std::optional<std::vector<u8>> ret;
@@ -175,7 +175,7 @@ std::optional<std::vector<u8>> RGBA8Image::SaveToBuffer(const char* filename, u8
const FormatHandler* handler = GetFormatHandler(extension);
if (!handler || !handler->file_saver)
{
Log_ErrorPrintf("Unknown extension '%.*s'", static_cast<int>(extension.size()), extension.data());
Log_ErrorFmt("Unknown extension '{}'", extension);
return ret;
}
@@ -271,7 +271,7 @@ static bool PNGCommonLoader(RGBA8Image* image, png_structp png_ptr, png_infop in
return true;
}
bool PNGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp)
bool PNGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp)
{
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
if (!png_ptr)
@@ -356,7 +356,7 @@ static void PNGSaveCommon(const RGBA8Image& image, png_structp png_ptr, png_info
png_write_end(png_ptr, nullptr);
}
bool PNGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality)
bool PNGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality)
{
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
png_infop info_ptr = nullptr;
@@ -521,7 +521,7 @@ bool JPEGBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size)
});
}
bool JPEGFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp)
bool JPEGFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp)
{
static constexpr u32 BUFFER_SIZE = 16384;
@@ -671,7 +671,7 @@ bool JPEGBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 qualit
return WrapJPEGCompress(image, quality, [&cb](jpeg_compress_struct& info) { info.dest = &cb.mgr; });
}
bool JPEGFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality)
bool JPEGFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality)
{
static constexpr u32 BUFFER_SIZE = 16384;
@@ -755,7 +755,7 @@ bool WebPBufferSaver(const RGBA8Image& image, std::vector<u8>* buffer, u8 qualit
return true;
}
bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp)
bool WebPFileLoader(RGBA8Image* image, std::string_view filename, std::FILE* fp)
{
std::optional<std::vector<u8>> data = FileSystem::ReadBinaryFile(fp);
if (!data.has_value())
@@ -764,7 +764,7 @@ bool WebPFileLoader(RGBA8Image* image, const char* filename, std::FILE* fp)
return WebPBufferLoader(image, data->data(), data->size());
}
bool WebPFileSaver(const RGBA8Image& image, const char* filename, std::FILE* fp, u8 quality)
bool WebPFileSaver(const RGBA8Image& image, std::string_view filename, std::FILE* fp, u8 quality)
{
std::vector<u8> buffer;
if (!WebPBufferSaver(image, &buffer, quality))
+5 -4
View File
@@ -10,6 +10,7 @@
#include <cstdio>
#include <cstring>
#include <optional>
#include <string_view>
#include <vector>
template<typename PixelType>
@@ -127,10 +128,10 @@ public:
RGBA8Image& operator=(RGBA8Image&& move);
bool LoadFromFile(const char* filename);
bool LoadFromFile(const char* filename, std::FILE* fp);
bool LoadFromBuffer(const char* filename, const void* buffer, size_t buffer_size);
bool LoadFromFile(std::string_view filename, std::FILE* fp);
bool LoadFromBuffer(std::string_view filename, const void* buffer, size_t buffer_size);
bool SaveToFile(const char* filename, u8 quality = DEFAULT_SAVE_QUALITY) const;
bool SaveToFile(const char* filename, std::FILE* fp, u8 quality = DEFAULT_SAVE_QUALITY) const;
std::optional<std::vector<u8>> SaveToBuffer(const char* filename, u8 quality = DEFAULT_SAVE_QUALITY) const;
bool SaveToFile(std::string_view filename, std::FILE* fp, u8 quality = DEFAULT_SAVE_QUALITY) const;
std::optional<std::vector<u8>> SaveToBuffer(std::string_view filename, u8 quality = DEFAULT_SAVE_QUALITY) const;
};
+14 -14
View File
@@ -43,8 +43,8 @@ using MessageDialogCallbackVariant = std::variant<InfoMessageDialogCallback, Con
static constexpr float MENU_BACKGROUND_ANIMATION_TIME = 0.5f;
static std::optional<RGBA8Image> LoadTextureImage(const char* path);
static std::shared_ptr<GPUTexture> UploadTexture(const char* path, const RGBA8Image& image);
static std::optional<RGBA8Image> LoadTextureImage(std::string_view path);
static std::shared_ptr<GPUTexture> UploadTexture(std::string_view path, const RGBA8Image& image);
static void TextureLoaderThread();
static void DrawFileSelector();
@@ -282,17 +282,18 @@ const std::shared_ptr<GPUTexture>& ImGuiFullscreen::GetPlaceholderTexture()
return s_placeholder_texture;
}
std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(const char* path)
std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(std::string_view path)
{
std::optional<RGBA8Image> image;
if (Path::IsAbsolute(path))
{
Error error;
auto fp = FileSystem::OpenManagedCFile(path, "rb", &error);
std::string path_str(path);
auto fp = FileSystem::OpenManagedCFile(path_str.c_str(), "rb", &error);
if (fp)
{
image = RGBA8Image();
if (!image->LoadFromFile(path, fp.get()))
if (!image->LoadFromFile(path_str.c_str(), fp.get()))
Log_ErrorFmt("Failed to read texture file '{}'", path);
}
else
@@ -321,28 +322,27 @@ std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(const char* path)
return image;
}
std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(const char* path, const RGBA8Image& image)
std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(std::string_view path, const RGBA8Image& image)
{
std::unique_ptr<GPUTexture> texture =
g_gpu_device->FetchTexture(image.GetWidth(), image.GetHeight(), 1, 1, 1, GPUTexture::Type::Texture,
GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch());
if (!texture)
{
Log_ErrorPrintf("failed to create %ux%u texture for resource", image.GetWidth(), image.GetHeight());
Log_ErrorFmt("failed to create {}x{} texture for resource", image.GetWidth(), image.GetHeight());
return {};
}
Log_DevPrintf("Uploaded texture resource '%s' (%ux%u)", path, image.GetWidth(), image.GetHeight());
Log_DevFmt("Uploaded texture resource '{}' ({}x{})", path, image.GetWidth(), image.GetHeight());
return std::shared_ptr<GPUTexture>(texture.release(), GPUDevice::PooledTextureDeleter());
}
std::shared_ptr<GPUTexture> ImGuiFullscreen::LoadTexture(const std::string_view& path)
std::shared_ptr<GPUTexture> ImGuiFullscreen::LoadTexture(std::string_view path)
{
std::string path_str(path);
std::optional<RGBA8Image> image(LoadTextureImage(path_str.c_str()));
std::optional<RGBA8Image> image(LoadTextureImage(path));
if (image.has_value())
{
std::shared_ptr<GPUTexture> ret(UploadTexture(path_str.c_str(), image.value()));
std::shared_ptr<GPUTexture> ret(UploadTexture(path, image.value()));
if (ret)
return ret;
}
@@ -350,7 +350,7 @@ std::shared_ptr<GPUTexture> ImGuiFullscreen::LoadTexture(const std::string_view&
return s_placeholder_texture;
}
GPUTexture* ImGuiFullscreen::GetCachedTexture(const std::string_view& name)
GPUTexture* ImGuiFullscreen::GetCachedTexture(std::string_view name)
{
std::shared_ptr<GPUTexture>* tex_ptr = s_texture_cache.Lookup(name);
if (!tex_ptr)
@@ -362,7 +362,7 @@ GPUTexture* ImGuiFullscreen::GetCachedTexture(const std::string_view& name)
return tex_ptr->get();
}
GPUTexture* ImGuiFullscreen::GetCachedTextureAsync(const std::string_view& name)
GPUTexture* ImGuiFullscreen::GetCachedTextureAsync(std::string_view name)
{
std::shared_ptr<GPUTexture>* tex_ptr = s_texture_cache.Lookup(name);
if (!tex_ptr)
+4 -4
View File
@@ -105,7 +105,7 @@ ALWAYS_INLINE static ImVec4 MulAlpha(const ImVec4& v, float a)
return ImVec4(v.x, v.y, v.z, v.w * a);
}
ALWAYS_INLINE static std::string_view RemoveHash(const std::string_view& s)
ALWAYS_INLINE static std::string_view RemoveHash(std::string_view s)
{
const std::string_view::size_type pos = s.find('#');
return (pos != std::string_view::npos) ? s.substr(0, pos) : s;
@@ -127,9 +127,9 @@ void Shutdown();
/// Texture cache.
const std::shared_ptr<GPUTexture>& GetPlaceholderTexture();
std::shared_ptr<GPUTexture> LoadTexture(const std::string_view& path);
GPUTexture* GetCachedTexture(const std::string_view& name);
GPUTexture* GetCachedTextureAsync(const std::string_view& name);
std::shared_ptr<GPUTexture> LoadTexture(std::string_view path);
GPUTexture* GetCachedTexture(std::string_view name);
GPUTexture* GetCachedTextureAsync(std::string_view name);
bool InvalidateCachedTexture(const std::string& path);
void UploadAsyncTextures();
+20 -27
View File
@@ -98,16 +98,13 @@ struct MacroButton
// Forward Declarations (for static qualifier)
// ------------------------------------------------------------------------
namespace InputManager {
static std::optional<InputBindingKey> ParseHostKeyboardKey(const std::string_view& source,
const std::string_view& sub_binding);
static std::optional<InputBindingKey> ParsePointerKey(const std::string_view& source,
const std::string_view& sub_binding);
static std::optional<InputBindingKey> ParseSensorKey(const std::string_view& source,
const std::string_view& sub_binding);
static std::optional<InputBindingKey> ParseHostKeyboardKey(std::string_view source, std::string_view sub_binding);
static std::optional<InputBindingKey> ParsePointerKey(std::string_view source, std::string_view sub_binding);
static std::optional<InputBindingKey> ParseSensorKey(std::string_view source, std::string_view sub_binding);
static std::vector<std::string_view> SplitChord(const std::string_view& binding);
static bool SplitBinding(const std::string_view& binding, std::string_view* source, std::string_view* sub_binding);
static void PrettifyInputBindingPart(const std::string_view binding, SmallString& ret, bool& changed);
static std::vector<std::string_view> SplitChord(std::string_view binding);
static bool SplitBinding(std::string_view binding, std::string_view* source, std::string_view* sub_binding);
static void PrettifyInputBindingPart(std::string_view binding, SmallString& ret, bool& changed);
static void AddBindings(const std::vector<std::string>& bindings, const InputEventHandler& handler);
static bool IsAxisHandler(const InputEventHandler& handler);
@@ -189,7 +186,7 @@ static std::vector<std::pair<u32, PointerMoveCallback>> s_pointer_move_callbacks
// Binding Parsing
// ------------------------------------------------------------------------
std::vector<std::string_view> InputManager::SplitChord(const std::string_view& binding)
std::vector<std::string_view> InputManager::SplitChord(std::string_view binding)
{
std::vector<std::string_view> parts;
@@ -219,8 +216,7 @@ std::vector<std::string_view> InputManager::SplitChord(const std::string_view& b
return parts;
}
bool InputManager::SplitBinding(const std::string_view& binding, std::string_view* source,
std::string_view* sub_binding)
bool InputManager::SplitBinding(std::string_view binding, std::string_view* source, std::string_view* sub_binding)
{
const std::string_view::size_type slash_pos = binding.find('/');
if (slash_pos == std::string_view::npos)
@@ -234,7 +230,7 @@ bool InputManager::SplitBinding(const std::string_view& binding, std::string_vie
return true;
}
std::optional<InputBindingKey> InputManager::ParseInputBindingKey(const std::string_view& binding)
std::optional<InputBindingKey> InputManager::ParseInputBindingKey(std::string_view binding)
{
std::string_view source, sub_binding;
if (!SplitBinding(binding, &source, &sub_binding))
@@ -269,7 +265,7 @@ std::optional<InputBindingKey> InputManager::ParseInputBindingKey(const std::str
return std::nullopt;
}
bool InputManager::ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source)
bool InputManager::ParseBindingAndGetSource(std::string_view binding, InputBindingKey* key, InputSource** source)
{
std::string_view source_string, sub_binding;
if (!SplitBinding(binding, &source_string, &sub_binding))
@@ -486,7 +482,7 @@ void InputManager::AddBindings(const std::vector<std::string>& bindings, const I
AddBinding(binding, handler);
}
void InputManager::AddBinding(const std::string_view& binding, const InputEventHandler& handler)
void InputManager::AddBinding(std::string_view binding, const InputEventHandler& handler)
{
std::shared_ptr<InputBinding> ibinding;
const std::vector<std::string_view> chord_bindings(SplitChord(binding));
@@ -650,7 +646,7 @@ bool InputManager::GetInputSourceDefaultEnabled(InputSourceType type)
}
}
std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::string_view& str)
std::optional<InputSourceType> InputManager::ParseInputSourceString(std::string_view str)
{
for (u32 i = 0; i < static_cast<u32>(InputSourceType::Count); i++)
{
@@ -661,8 +657,7 @@ std::optional<InputSourceType> InputManager::ParseInputSourceString(const std::s
return std::nullopt;
}
std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(const std::string_view& source,
const std::string_view& sub_binding)
std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(std::string_view source, std::string_view sub_binding)
{
if (source != "Keyboard")
return std::nullopt;
@@ -677,8 +672,7 @@ std::optional<InputBindingKey> InputManager::ParseHostKeyboardKey(const std::str
return key;
}
std::optional<InputBindingKey> InputManager::ParsePointerKey(const std::string_view& source,
const std::string_view& sub_binding)
std::optional<InputBindingKey> InputManager::ParsePointerKey(std::string_view source, std::string_view sub_binding)
{
const std::optional<s32> pointer_index = StringUtil::FromChars<s32>(source.substr(8));
if (!pointer_index.has_value() || pointer_index.value() < 0)
@@ -731,7 +725,7 @@ std::optional<InputBindingKey> InputManager::ParsePointerKey(const std::string_v
return std::nullopt;
}
std::optional<u32> InputManager::GetIndexFromPointerBinding(const std::string_view& source)
std::optional<u32> InputManager::GetIndexFromPointerBinding(std::string_view source)
{
if (!source.starts_with("Pointer-"))
return std::nullopt;
@@ -748,8 +742,7 @@ std::string InputManager::GetPointerDeviceName(u32 pointer_index)
return fmt::format("Pointer-{}", pointer_index);
}
std::optional<InputBindingKey> InputManager::ParseSensorKey(const std::string_view& source,
const std::string_view& sub_binding)
std::optional<InputBindingKey> InputManager::ParseSensorKey(std::string_view source, std::string_view sub_binding)
{
if (source != "Sensor")
return std::nullopt;
@@ -1442,12 +1435,12 @@ std::vector<std::string> InputManager::GetInputProfileNames()
return ret;
}
void InputManager::OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name)
void InputManager::OnInputDeviceConnected(std::string_view identifier, std::string_view device_name)
{
Host::OnInputDeviceConnected(identifier, device_name);
}
void InputManager::OnInputDeviceDisconnected(const std::string_view& identifier)
void InputManager::OnInputDeviceDisconnected(std::string_view identifier)
{
Host::OnInputDeviceDisconnected(identifier);
}
@@ -1873,7 +1866,7 @@ static void GetKeyboardGenericBindingMapping(std::vector<std::pair<GenericInputB
mapping->emplace_back(GenericInputBinding::R3, "Keyboard/4");
}
static bool GetInternalGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping)
static bool GetInternalGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{
if (device == "Keyboard")
{
@@ -1884,7 +1877,7 @@ static bool GetInternalGenericBindingMapping(const std::string_view& device, Gen
return false;
}
GenericInputBindingMapping InputManager::GetGenericBindingMapping(const std::string_view& device)
GenericInputBindingMapping InputManager::GetGenericBindingMapping(std::string_view device)
{
GenericInputBindingMapping mapping;
+11 -11
View File
@@ -194,16 +194,16 @@ const char* InputSourceToString(InputSourceType clazz);
bool GetInputSourceDefaultEnabled(InputSourceType type);
/// Parses an input class string.
std::optional<InputSourceType> ParseInputSourceString(const std::string_view& str);
std::optional<InputSourceType> ParseInputSourceString(std::string_view str);
/// Parses a pointer device string, i.e. tells you which pointer is specified.
std::optional<u32> GetIndexFromPointerBinding(const std::string_view& str);
std::optional<u32> GetIndexFromPointerBinding(std::string_view str);
/// Returns the device name for a pointer index (e.g. Pointer-0).
std::string GetPointerDeviceName(u32 pointer_index);
/// Converts a key code from a human-readable string to an identifier.
std::optional<u32> ConvertHostKeyboardStringToCode(const std::string_view& str);
std::optional<u32> ConvertHostKeyboardStringToCode(std::string_view str);
/// Converts a key code from an identifier to a human-readable string.
std::optional<std::string> ConvertHostKeyboardCodeToString(u32 code);
@@ -225,7 +225,7 @@ InputBindingKey MakePointerAxisKey(u32 index, InputPointerAxis axis);
InputBindingKey MakeSensorAxisKey(InputSubclass sensor, u32 axis);
/// Parses an input binding key string.
std::optional<InputBindingKey> ParseInputBindingKey(const std::string_view& binding);
std::optional<InputBindingKey> ParseInputBindingKey(std::string_view binding);
/// Converts a input key to a string.
std::string ConvertInputBindingKeyToString(InputBindingInfo::Type binding_type, InputBindingKey key);
@@ -247,7 +247,7 @@ std::vector<std::pair<std::string, std::string>> EnumerateDevices();
std::vector<InputBindingKey> EnumerateMotors();
/// Retrieves bindings that match the generic bindings for the specified device.
GenericInputBindingMapping GetGenericBindingMapping(const std::string_view& device);
GenericInputBindingMapping GetGenericBindingMapping(std::string_view device);
/// Returns true if the specified input source is enabled.
bool IsInputSourceEnabled(SettingsInterface& si, InputSourceType type);
@@ -277,10 +277,10 @@ bool HasAnyBindingsForKey(InputBindingKey key);
bool HasAnyBindingsForSource(InputBindingKey key);
/// Parses a string binding into its components. Use with external AddBinding().
bool ParseBindingAndGetSource(const std::string_view& binding, InputBindingKey* key, InputSource** source);
bool ParseBindingAndGetSource(std::string_view binding, InputBindingKey* key, InputSource** source);
/// Externally adds a fixed binding. Be sure to call *after* ReloadBindings() otherwise it will be lost.
void AddBinding(const std::string_view& binding, const InputEventHandler& handler);
void AddBinding(std::string_view binding, const InputEventHandler& handler);
/// Adds an external vibration binding.
void AddVibrationBinding(u32 pad_index, const InputBindingKey* motor_0_binding, InputSource* motor_0_source,
@@ -348,10 +348,10 @@ bool MapController(SettingsInterface& si, u32 controller,
std::vector<std::string> GetInputProfileNames();
/// Called when a new input device is connected.
void OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name);
void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name);
/// Called when an input device is disconnected.
void OnInputDeviceDisconnected(const std::string_view& identifier);
void OnInputDeviceDisconnected(std::string_view identifier);
} // namespace InputManager
namespace Host {
@@ -359,10 +359,10 @@ namespace Host {
void AddFixedInputBindings(SettingsInterface& si);
/// Called when a new input device is connected.
void OnInputDeviceConnected(const std::string_view& identifier, const std::string_view& device_name);
void OnInputDeviceConnected(std::string_view identifier, std::string_view device_name);
/// Called when an input device is disconnected.
void OnInputDeviceDisconnected(const std::string_view& identifier);
void OnInputDeviceDisconnected(std::string_view identifier);
/// Enables "relative" mouse mode, locking the cursor position and returning relative coordinates.
void SetMouseMode(bool relative, bool hide_cursor);
+2 -2
View File
@@ -60,8 +60,8 @@ InputBindingKey InputSource::MakeGenericControllerMotorKey(InputSourceType clazz
}
std::optional<InputBindingKey> InputSource::ParseGenericControllerKey(InputSourceType clazz,
const std::string_view& source,
const std::string_view& sub_binding)
std::string_view source,
std::string_view sub_binding)
{
// try to find the number, this function doesn't care about whether it's xinput or sdl or whatever
std::string_view::size_type pos = 0;
+4 -5
View File
@@ -29,8 +29,7 @@ public:
virtual void PollEvents() = 0;
virtual std::optional<InputBindingKey> ParseKeyString(const std::string_view& device,
const std::string_view& binding) = 0;
virtual std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) = 0;
virtual TinyString ConvertKeyToString(InputBindingKey key) = 0;
virtual TinyString ConvertKeyToIcon(InputBindingKey key) = 0;
@@ -42,7 +41,7 @@ public:
/// Retrieves bindings that match the generic bindings for the specified device.
/// Returns false if it's not one of our devices.
virtual bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) = 0;
virtual bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) = 0;
/// Informs the source of a new vibration motor state. Changes may not take effect until the next PollEvents() call.
virtual void UpdateMotorState(InputBindingKey key, float intensity) = 0;
@@ -65,8 +64,8 @@ public:
static InputBindingKey MakeGenericControllerMotorKey(InputSourceType clazz, u32 controller_index, s32 motor_index);
/// Parses a generic controller key string.
static std::optional<InputBindingKey> ParseGenericControllerKey(InputSourceType clazz, const std::string_view& source,
const std::string_view& sub_binding);
static std::optional<InputBindingKey> ParseGenericControllerKey(InputSourceType clazz, std::string_view source,
std::string_view sub_binding);
/// Converts a generic controller key to a string.
static std::string ConvertGenericControllerKeyToString(InputBindingKey key);
+8 -8
View File
@@ -18,7 +18,7 @@ IsoReader::IsoReader() = default;
IsoReader::~IsoReader() = default;
std::string_view IsoReader::RemoveVersionIdentifierFromPath(const std::string_view& path)
std::string_view IsoReader::RemoveVersionIdentifierFromPath(std::string_view path)
{
const std::string_view::size_type pos = path.find(';');
return (pos != std::string_view::npos) ? path.substr(0, pos) : path;
@@ -82,7 +82,7 @@ bool IsoReader::ReadPVD(Error* error)
return false;
}
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::string_view& path, Error* error)
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(std::string_view path, Error* error)
{
const ISODirectoryEntry* root_de = reinterpret_cast<const ISODirectoryEntry*>(m_pvd.root_directory_entry);
if (path.empty() || path == "/" || path == "\\")
@@ -125,7 +125,7 @@ std::string_view IsoReader::GetDirectoryEntryFileName(const u8* sector, u32 de_s
return std::string_view(str, length_without_version);
}
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::string_view& path, u8* sector_buffer,
std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(std::string_view path, u8* sector_buffer,
u32 directory_record_lba, u32 directory_record_size,
Error* error)
{
@@ -206,7 +206,7 @@ std::optional<IsoReader::ISODirectoryEntry> IsoReader::LocateFile(const std::str
return std::nullopt;
}
std::vector<std::string> IsoReader::GetFilesInDirectory(const std::string_view& path, Error* error)
std::vector<std::string> IsoReader::GetFilesInDirectory(std::string_view path, Error* error)
{
std::string base_path(path);
u32 directory_record_lsn;
@@ -268,7 +268,7 @@ std::vector<std::string> IsoReader::GetFilesInDirectory(const std::string_view&
}
std::vector<std::pair<std::string, IsoReader::ISODirectoryEntry>>
IsoReader::GetEntriesInDirectory(const std::string_view& path, Error* error /*= nullptr*/)
IsoReader::GetEntriesInDirectory(std::string_view path, Error* error /*= nullptr*/)
{
std::string base_path(path);
u32 directory_record_lsn;
@@ -329,7 +329,7 @@ IsoReader::GetEntriesInDirectory(const std::string_view& path, Error* error /*=
return files;
}
bool IsoReader::FileExists(const std::string_view& path, Error* error)
bool IsoReader::FileExists(std::string_view path, Error* error)
{
auto de = LocateFile(path, error);
if (!de)
@@ -338,7 +338,7 @@ bool IsoReader::FileExists(const std::string_view& path, Error* error)
return (de->flags & ISODirectoryEntryFlag_Directory) == 0;
}
bool IsoReader::DirectoryExists(const std::string_view& path, Error* error)
bool IsoReader::DirectoryExists(std::string_view path, Error* error)
{
auto de = LocateFile(path, error);
if (!de)
@@ -347,7 +347,7 @@ bool IsoReader::DirectoryExists(const std::string_view& path, Error* error)
return (de->flags & ISODirectoryEntryFlag_Directory) == ISODirectoryEntryFlag_Directory;
}
bool IsoReader::ReadFile(const std::string_view& path, std::vector<u8>* data, Error* error)
bool IsoReader::ReadFile(std::string_view path, std::vector<u8>* data, Error* error)
{
auto de = LocateFile(path, error);
if (!de)
+8 -8
View File
@@ -141,7 +141,7 @@ public:
IsoReader();
~IsoReader();
static std::string_view RemoveVersionIdentifierFromPath(const std::string_view& path);
static std::string_view RemoveVersionIdentifierFromPath(std::string_view path);
ALWAYS_INLINE const CDImage* GetImage() const { return m_image; }
ALWAYS_INLINE u32 GetTrackNumber() const { return m_track_number; }
@@ -150,15 +150,15 @@ public:
bool Open(CDImage* image, u32 track_number, Error* error = nullptr);
std::vector<std::string> GetFilesInDirectory(const std::string_view& path, Error* error = nullptr);
std::vector<std::pair<std::string, ISODirectoryEntry>> GetEntriesInDirectory(const std::string_view& path,
std::vector<std::string> GetFilesInDirectory(std::string_view path, Error* error = nullptr);
std::vector<std::pair<std::string, ISODirectoryEntry>> GetEntriesInDirectory(std::string_view path,
Error* error = nullptr);
std::optional<ISODirectoryEntry> LocateFile(const std::string_view& path, Error* error);
std::optional<ISODirectoryEntry> LocateFile(std::string_view path, Error* error);
bool FileExists(const std::string_view& path, Error* error = nullptr);
bool DirectoryExists(const std::string_view& path, Error* error = nullptr);
bool ReadFile(const std::string_view& path, std::vector<u8>* data, Error* error = nullptr);
bool FileExists(std::string_view path, Error* error = nullptr);
bool DirectoryExists(std::string_view path, Error* error = nullptr);
bool ReadFile(std::string_view path, std::vector<u8>* data, Error* error = nullptr);
bool ReadFile(const ISODirectoryEntry& de, std::vector<u8>* data, Error* error = nullptr);
private:
@@ -167,7 +167,7 @@ private:
bool ReadSector(u8* buf, u32 lsn, Error* error);
bool ReadPVD(Error* error);
std::optional<ISODirectoryEntry> LocateFile(const std::string_view& path, u8* sector_buffer, u32 directory_record_lba,
std::optional<ISODirectoryEntry> LocateFile(std::string_view path, u8* sector_buffer, u32 directory_record_lba,
u32 directory_record_size, Error* error);
CDImage* m_image;
+9 -9
View File
@@ -45,7 +45,7 @@ public:
ALWAYS_INLINE id<MTLSamplerState> GetSamplerState() const { return m_ss; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
MetalSampler(id<MTLSamplerState> ss);
@@ -63,7 +63,7 @@ public:
ALWAYS_INLINE id<MTLLibrary> GetLibrary() const { return m_library; }
ALWAYS_INLINE id<MTLFunction> GetFunction() const { return m_function; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
MetalShader(GPUShaderStage stage, id<MTLLibrary> library, id<MTLFunction> function);
@@ -84,7 +84,7 @@ public:
ALWAYS_INLINE MTLCullMode GetCullMode() const { return m_cull_mode; }
ALWAYS_INLINE MTLPrimitiveType GetPrimitive() const { return m_primitive; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
MetalPipeline(id<MTLRenderPipelineState> pipeline, id<MTLDepthStencilState> depth, MTLCullMode cull_mode,
@@ -114,7 +114,7 @@ public:
void MakeReadyForSampling() override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
// Call when the texture is bound to the pipeline, or read from in a copy.
ALWAYS_INLINE void SetUseFenceCounter(u64 counter) { m_use_fence_counter = counter; }
@@ -179,7 +179,7 @@ public:
void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
MetalStreamBuffer m_buffer;
@@ -232,7 +232,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point,
DynamicHeapArray<u8>* out_binary = nullptr) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@@ -291,7 +291,7 @@ public:
static AdapterAndModeList StaticGetAdapterAndModeList();
protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override;
void DestroyDevice() override;
@@ -329,8 +329,8 @@ private:
ClearPipelineConfig GetCurrentClearPipelineConfig() const;
id<MTLRenderPipelineState> GetClearDepthPipeline(const ClearPipelineConfig& config);
std::unique_ptr<GPUShader> CreateShaderFromMSL(GPUShaderStage stage, const std::string_view& source,
const std::string_view& entry_point);
std::unique_ptr<GPUShader> CreateShaderFromMSL(GPUShaderStage stage, std::string_view source,
std::string_view entry_point);
id<MTLDepthStencilState> GetDepthState(const GPUPipeline::DepthState& ds);
+11 -11
View File
@@ -61,7 +61,7 @@ static constexpr std::array<MTLPixelFormat, static_cast<u32>(GPUTexture::Format:
static std::unique_ptr<shaderc::Compiler> s_shaderc_compiler;
static NSString* StringViewToNSString(const std::string_view& str)
static NSString* StringViewToNSString(std::string_view str)
{
if (str.empty())
return nil;
@@ -137,7 +137,7 @@ void MetalDevice::SetVSyncEnabled(bool enabled)
[m_layer setDisplaySyncEnabled:enabled];
}
bool MetalDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool MetalDevice::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error)
{
@@ -592,7 +592,7 @@ MetalShader::~MetalShader()
MetalDevice::DeferRelease(m_library);
}
void MetalShader::SetDebugName(const std::string_view& name)
void MetalShader::SetDebugName(std::string_view name)
{
@autoreleasepool
{
@@ -604,7 +604,7 @@ void MetalShader::SetDebugName(const std::string_view& name)
namespace EmuFolders {
extern std::string DataRoot;
}
static void DumpShader(u32 n, const std::string_view& suffix, const std::string_view& data)
static void DumpShader(u32 n, std::string_view suffix, std::string_view data)
{
if (data.empty())
return;
@@ -617,8 +617,8 @@ static void DumpShader(u32 n, const std::string_view& suffix, const std::string_
std::fwrite(data.data(), data.length(), 1, fp.get());
}
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, const std::string_view& source,
const std::string_view& entry_point)
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage, std::string_view source,
std::string_view entry_point)
{
@autoreleasepool
{
@@ -651,7 +651,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromBinary(GPUShaderStage st
return CreateShaderFromMSL(stage, str_data, "main0");
}
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point,
DynamicHeapArray<u8>* out_binary /* = nullptr */)
{
@@ -839,7 +839,7 @@ MetalPipeline::~MetalPipeline()
MetalDevice::DeferRelease(m_pipeline);
}
void MetalPipeline::SetDebugName(const std::string_view& name)
void MetalPipeline::SetDebugName(std::string_view name)
{
// readonly property :/
}
@@ -1188,7 +1188,7 @@ void MetalTexture::MakeReadyForSampling()
dev.EndRenderPass();
}
void MetalTexture::SetDebugName(const std::string_view& name)
void MetalTexture::SetDebugName(std::string_view name)
{
@autoreleasepool
{
@@ -1434,7 +1434,7 @@ MetalSampler::MetalSampler(id<MTLSamplerState> ss) : m_ss(ss)
MetalSampler::~MetalSampler() = default;
void MetalSampler::SetDebugName(const std::string_view& name)
void MetalSampler::SetDebugName(std::string_view name)
{
// lame.. have to put it on the descriptor :/
}
@@ -1831,7 +1831,7 @@ void MetalTextureBuffer::Unmap(u32 used_elements)
m_buffer.CommitMemory(size);
}
void MetalTextureBuffer::SetDebugName(const std::string_view& name)
void MetalTextureBuffer::SetDebugName(std::string_view name)
{
@autoreleasepool
{
+1 -1
View File
@@ -272,7 +272,7 @@ bool OpenGLDevice::HasSurface() const
return m_window_info.type != WindowInfo::Type::Surfaceless;
}
bool OpenGLDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool OpenGLDevice::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error)
{
+2 -2
View File
@@ -73,7 +73,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@@ -130,7 +130,7 @@ public:
void UnbindPipeline(const OpenGLPipeline* pl);
protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override;
void DestroyDevice() override;
+5 -4
View File
@@ -78,7 +78,7 @@ OpenGLShader::~OpenGLShader()
glDeleteShader(m_id.value());
}
void OpenGLShader::SetDebugName(const std::string_view& name)
void OpenGLShader::SetDebugName(std::string_view name)
{
#ifdef _DEBUG
if (glObjectLabel)
@@ -163,7 +163,7 @@ std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromBinary(GPUShaderStage s
return {};
}
std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point,
DynamicHeapArray<u8>* out_binary)
{
@@ -440,7 +440,8 @@ void OpenGLDevice::UnrefProgram(const OpenGLPipeline::ProgramCacheKey& key)
m_program_cache.erase(it);
}
OpenGLPipeline::VertexArrayCache::const_iterator OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key)
OpenGLPipeline::VertexArrayCache::const_iterator
OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key)
{
OpenGLPipeline::VertexArrayCache::iterator it = m_vao_cache.find(key);
if (it != m_vao_cache.end())
@@ -546,7 +547,7 @@ OpenGLPipeline::~OpenGLPipeline()
dev.UnrefVAO(m_key.va_key);
}
void OpenGLPipeline::SetDebugName(const std::string_view& name)
void OpenGLPipeline::SetDebugName(std::string_view name)
{
#ifdef _DEBUG
if (glObjectLabel)
+2 -2
View File
@@ -16,7 +16,7 @@ class OpenGLShader final : public GPUShader
public:
~OpenGLShader() override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
bool Compile();
@@ -103,7 +103,7 @@ public:
ALWAYS_INLINE const BlendState& GetBlendState() const { return m_blend_state; }
ALWAYS_INLINE GLenum GetTopology() const { return m_topology; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
OpenGLPipeline(const ProgramCacheKey& key, GLuint program, VertexArrayCache::const_iterator vao,
+1 -1
View File
@@ -29,7 +29,7 @@ void OpenGLStreamBuffer::Unbind()
glBindBuffer(m_target, 0);
}
void OpenGLStreamBuffer::SetDebugName(const std::string_view& name)
void OpenGLStreamBuffer::SetDebugName(std::string_view name)
{
#ifdef _DEBUG
if (glObjectLabel)
+1 -1
View File
@@ -24,7 +24,7 @@ public:
void Bind();
void Unbind();
void SetDebugName(const std::string_view& name);
void SetDebugName(std::string_view name);
struct MappingResult
{
+3 -3
View File
@@ -350,7 +350,7 @@ void OpenGLTexture::Unmap()
sb->Unbind();
}
void OpenGLTexture::SetDebugName(const std::string_view& name)
void OpenGLTexture::SetDebugName(std::string_view name)
{
#ifdef _DEBUG
if (glObjectLabel)
@@ -375,7 +375,7 @@ OpenGLSampler::~OpenGLSampler()
OpenGLDevice::GetInstance().UnbindSampler(m_id);
}
void OpenGLSampler::SetDebugName(const std::string_view& name)
void OpenGLSampler::SetDebugName(std::string_view name)
{
#ifdef _DEBUG
if (glObjectLabel)
@@ -660,7 +660,7 @@ void OpenGLTextureBuffer::Unmap(u32 used_elements)
m_buffer->Unmap(size);
}
void OpenGLTextureBuffer::SetDebugName(const std::string_view& name)
void OpenGLTextureBuffer::SetDebugName(std::string_view name)
{
#ifdef _DEBUG
if (glObjectLabel)
+3 -3
View File
@@ -27,7 +27,7 @@ public:
bool Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32 height, u32 layer = 0, u32 level = 0) override;
void Unmap() override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
static std::unique_ptr<OpenGLTexture> Create(u32 width, u32 height, u32 layers, u32 levels, u32 samples, Type type,
Format format, const void* data = nullptr, u32 data_pitch = 0);
@@ -73,7 +73,7 @@ public:
void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
OpenGLTextureBuffer(Format format, u32 size_in_elements, std::unique_ptr<OpenGLStreamBuffer> buffer,
@@ -92,7 +92,7 @@ public:
ALWAYS_INLINE GLuint GetID() const { return m_id; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
OpenGLSampler(GLuint id);
+4 -4
View File
@@ -33,7 +33,7 @@ Log_SetChannel(PostProcessing);
namespace PostProcessing {
template<typename T>
static u32 ParseVector(const std::string_view& line, ShaderOption::ValueVector* values);
static u32 ParseVector(std::string_view line, ShaderOption::ValueVector* values);
static TinyString ValueToString(ShaderOption::Type type, u32 vector_size, const ShaderOption::ValueVector& value);
@@ -63,7 +63,7 @@ static std::unique_ptr<GPUTexture> s_dummy_texture;
} // namespace PostProcessing
template<typename T>
u32 PostProcessing::ParseVector(const std::string_view& line, ShaderOption::ValueVector* values)
u32 PostProcessing::ParseVector(std::string_view line, ShaderOption::ValueVector* values)
{
u32 index = 0;
size_t start = 0;
@@ -102,12 +102,12 @@ u32 PostProcessing::ParseVector(const std::string_view& line, ShaderOption::Valu
return size;
}
u32 PostProcessing::ShaderOption::ParseFloatVector(const std::string_view& line, ValueVector* values)
u32 PostProcessing::ShaderOption::ParseFloatVector(std::string_view line, ValueVector* values)
{
return ParseVector<float>(line, values);
}
u32 PostProcessing::ShaderOption::ParseIntVector(const std::string_view& line, ValueVector* values)
u32 PostProcessing::ShaderOption::ParseIntVector(std::string_view line, ValueVector* values)
{
return ParseVector<s32>(line, values);
}
+2 -2
View File
@@ -63,8 +63,8 @@ struct ShaderOption
ValueVector value;
std::vector<std::string> choice_options;
static u32 ParseIntVector(const std::string_view& line, ValueVector* values);
static u32 ParseFloatVector(const std::string_view& line, ValueVector* values);
static u32 ParseIntVector(std::string_view line, ValueVector* values);
static u32 ParseFloatVector(std::string_view line, ValueVector* values);
static constexpr ValueVector MakeIntVector(s32 x, s32 y = 0, s32 z = 0, s32 w = 0)
{
+3 -3
View File
@@ -13,7 +13,7 @@
Log_SetChannel(PostProcessing);
void PostProcessing::Shader::ParseKeyValue(const std::string_view& line, std::string_view* key, std::string_view* value)
void PostProcessing::Shader::ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value)
{
size_t key_start = 0;
while (key_start < line.size() && std::isspace(line[key_start]))
@@ -105,7 +105,7 @@ void PostProcessing::Shader::LoadOptions(const SettingsInterface& si, const char
}
}
const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(const std::string_view& name) const
const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(std::string_view name) const
{
for (const ShaderOption& option : m_options)
{
@@ -116,7 +116,7 @@ const PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(cons
return nullptr;
}
PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(const std::string_view& name)
PostProcessing::ShaderOption* PostProcessing::Shader::GetOptionByName(std::string_view name)
{
for (ShaderOption& option : m_options)
{
+3 -3
View File
@@ -41,8 +41,8 @@ public:
std::vector<ShaderOption> TakeOptions();
void LoadOptions(const SettingsInterface& si, const char* section);
const ShaderOption* GetOptionByName(const std::string_view& name) const;
ShaderOption* GetOptionByName(const std::string_view& name);
const ShaderOption* GetOptionByName(std::string_view name) const;
ShaderOption* GetOptionByName(std::string_view name);
virtual bool ResizeOutput(GPUTexture::Format format, u32 width, u32 height) = 0;
@@ -52,7 +52,7 @@ public:
s32 final_height, s32 orig_width, s32 orig_height, u32 target_width, u32 target_height) = 0;
protected:
static void ParseKeyValue(const std::string_view& line, std::string_view* key, std::string_view* value);
static void ParseKeyValue(std::string_view line, std::string_view* key, std::string_view* value);
virtual void OnOptionChanged(const ShaderOption& option);
+1 -1
View File
@@ -438,7 +438,7 @@ bool PostProcessing::ReShadeFXShader::CreateModule(s32 buffer_width, s32 buffer_
return true;
}
static bool HasAnnotationWithName(const reshadefx::uniform_info& uniform, const std::string_view& annotation_name)
static bool HasAnnotationWithName(const reshadefx::uniform_info& uniform, const std::string_view annotation_name)
{
for (const reshadefx::annotation& an : uniform.annotations)
{
+4 -5
View File
@@ -243,7 +243,7 @@ u32 SDLInputSource::GetRGBForPlayerId(SettingsInterface& si, u32 player_id)
player_id);
}
u32 SDLInputSource::ParseRGBForPlayerId(const std::string_view& str, u32 player_id)
u32 SDLInputSource::ParseRGBForPlayerId(std::string_view str, u32 player_id)
{
if (player_id >= MAX_LED_COLORS)
return 0;
@@ -355,8 +355,7 @@ std::vector<std::pair<std::string, std::string>> SDLInputSource::EnumerateDevice
return ret;
}
std::optional<InputBindingKey> SDLInputSource::ParseKeyString(const std::string_view& device,
const std::string_view& binding)
std::optional<InputBindingKey> SDLInputSource::ParseKeyString(std::string_view device, std::string_view binding)
{
if (!device.starts_with("SDL-") || binding.empty())
return std::nullopt;
@@ -638,7 +637,7 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event)
}
}
SDL_Joystick* SDLInputSource::GetJoystickForDevice(const std::string_view& device)
SDL_Joystick* SDLInputSource::GetJoystickForDevice(std::string_view device)
{
if (!device.starts_with("SDL-"))
return nullptr;
@@ -952,7 +951,7 @@ std::vector<InputBindingKey> SDLInputSource::EnumerateMotors()
return ret;
}
bool SDLInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping)
bool SDLInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{
if (!device.starts_with("SDL-"))
return false;
+4 -5
View File
@@ -29,22 +29,21 @@ public:
void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override;
bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity,
float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device,
const std::string_view& binding) override;
std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override;
bool ProcessSDLEvent(const SDL_Event* event);
SDL_Joystick* GetJoystickForDevice(const std::string_view& device);
SDL_Joystick* GetJoystickForDevice(std::string_view device);
static u32 GetRGBForPlayerId(SettingsInterface& si, u32 player_id);
static u32 ParseRGBForPlayerId(const std::string_view& str, u32 player_id);
static u32 ParseRGBForPlayerId(std::string_view str, u32 player_id);
static bool IsHandledInputEvent(const SDL_Event* ev);
+1 -1
View File
@@ -419,7 +419,7 @@ static inline void SetFormattedObjectName(VkDevice device, T object_handle, cons
}
template<typename T>
static inline void SetObjectName(VkDevice device, T object_handle, const std::string_view& sv)
static inline void SetObjectName(VkDevice device, T object_handle, std::string_view sv)
{
#ifdef ENABLE_VULKAN_DEBUG_OBJECTS
SetFormattedObjectName(device, object_handle, "%.*s", static_cast<int>(sv.length()), sv.data());
+1 -1
View File
@@ -1917,7 +1917,7 @@ bool VulkanDevice::HasSurface() const
return static_cast<bool>(m_swap_chain);
}
bool VulkanDevice::CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool VulkanDevice::CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error)
{
+2 -2
View File
@@ -99,7 +99,7 @@ public:
void InvalidateRenderTarget(GPUTexture* t) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data) override;
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@@ -221,7 +221,7 @@ public:
void UnbindTextureBuffer(VulkanTextureBuffer* buf);
protected:
bool CreateDevice(const std::string_view& adapter, bool threaded_presentation,
bool CreateDevice(std::string_view adapter, bool threaded_presentation,
std::optional<bool> exclusive_fullscreen_control, FeatureMask disabled_features,
Error* error) override;
void DestroyDevice() override;
+3 -3
View File
@@ -23,7 +23,7 @@ VulkanShader::~VulkanShader()
vkDestroyShaderModule(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, nullptr);
}
void VulkanShader::SetDebugName(const std::string_view& name)
void VulkanShader::SetDebugName(std::string_view name)
{
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, name);
}
@@ -44,7 +44,7 @@ std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromBinary(GPUShaderStage s
return std::unique_ptr<GPUShader>(new VulkanShader(stage, mod));
}
std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromSource(GPUShaderStage stage, const std::string_view& source,
std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromSource(GPUShaderStage stage, std::string_view source,
const char* entry_point,
DynamicHeapArray<u8>* out_binary)
{
@@ -115,7 +115,7 @@ VulkanPipeline::~VulkanPipeline()
VulkanDevice::GetInstance().DeferPipelineDestruction(m_pipeline);
}
void VulkanPipeline::SetDebugName(const std::string_view& name)
void VulkanPipeline::SetDebugName(std::string_view name)
{
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_pipeline, name);
}
+2 -2
View File
@@ -15,7 +15,7 @@ public:
ALWAYS_INLINE VkShaderModule GetModule() const { return m_module; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
VulkanShader(GPUShaderStage stage, VkShaderModule mod);
@@ -34,7 +34,7 @@ public:
ALWAYS_INLINE Layout GetLayout() const { return m_layout; }
ALWAYS_INLINE u8 GetVerticesPerPrimitive() const { return m_vertices_per_primitive; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
VulkanPipeline(VkPipeline pipeline, Layout layout, u8 vertices_per_primitive, RenderPassFlag render_pass_flags);
+3 -3
View File
@@ -474,7 +474,7 @@ void VulkanTexture::OverrideImageLayout(Layout new_layout)
m_layout = new_layout;
}
void VulkanTexture::SetDebugName(const std::string_view& name)
void VulkanTexture::SetDebugName(std::string_view name)
{
VulkanDevice& dev = VulkanDevice::GetInstance();
Vulkan::SetObjectName(dev.GetVulkanDevice(), m_image, name);
@@ -751,7 +751,7 @@ VulkanSampler::~VulkanSampler()
// Cleaned up by main class.
}
void VulkanSampler::SetDebugName(const std::string_view& name)
void VulkanSampler::SetDebugName(std::string_view name)
{
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_sampler, name);
}
@@ -915,7 +915,7 @@ void VulkanTextureBuffer::Unmap(u32 used_elements)
m_buffer.CommitMemory(size);
}
void VulkanTextureBuffer::SetDebugName(const std::string_view& name)
void VulkanTextureBuffer::SetDebugName(std::string_view name)
{
VulkanDevice& dev = VulkanDevice::GetInstance();
Vulkan::SetObjectName(dev.GetVulkanDevice(), m_buffer.GetBuffer(), name);
+3 -3
View File
@@ -55,7 +55,7 @@ public:
void Unmap() override;
void MakeReadyForSampling() override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
void TransitionToLayout(Layout layout);
void CommitClear();
@@ -119,7 +119,7 @@ public:
ALWAYS_INLINE VkSampler GetSampler() const { return m_sampler; }
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
VulkanSampler(VkSampler sampler);
@@ -145,7 +145,7 @@ public:
void* Map(u32 required_elements) override;
void Unmap(u32 used_elements) override;
void SetDebugName(const std::string_view& name) override;
void SetDebugName(std::string_view name) override;
private:
VulkanStreamBuffer m_buffer;
+2 -3
View File
@@ -83,8 +83,7 @@ void Win32RawInputSource::UpdateMotorState(InputBindingKey large_key, InputBindi
{
}
std::optional<InputBindingKey> Win32RawInputSource::ParseKeyString(const std::string_view& device,
const std::string_view& binding)
std::optional<InputBindingKey> Win32RawInputSource::ParseKeyString(std::string_view device, std::string_view binding)
{
return std::nullopt;
}
@@ -104,7 +103,7 @@ std::vector<InputBindingKey> Win32RawInputSource::EnumerateMotors()
return {};
}
bool Win32RawInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping)
bool Win32RawInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{
return {};
}
+2 -3
View File
@@ -25,13 +25,12 @@ public:
void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override;
bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity,
float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device,
const std::string_view& binding) override;
std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override;
+3 -4
View File
@@ -250,8 +250,7 @@ std::vector<std::pair<std::string, std::string>> XInputSource::EnumerateDevices(
return ret;
}
std::optional<InputBindingKey> XInputSource::ParseKeyString(const std::string_view& device,
const std::string_view& binding)
std::optional<InputBindingKey> XInputSource::ParseKeyString(std::string_view device, std::string_view binding)
{
if (!device.starts_with("XInput-") || binding.empty())
return std::nullopt;
@@ -351,7 +350,7 @@ TinyString XInputSource::ConvertKeyToIcon(InputBindingKey key)
if (key.data < std::size(s_axis_icons) && key.modifier != InputModifier::FullAxis)
{
ret.format("XInput-{} {}", static_cast<u32>(key.source_index),
s_axis_icons[key.data][key.modifier == InputModifier::None]);
s_axis_icons[key.data][key.modifier == InputModifier::None]);
}
}
else if (key.source_subtype == InputSubclass::ControllerButton)
@@ -384,7 +383,7 @@ std::vector<InputBindingKey> XInputSource::EnumerateMotors()
return ret;
}
bool XInputSource::GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping)
bool XInputSource::GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping)
{
if (!device.starts_with("XInput-"))
return false;
+2 -3
View File
@@ -43,13 +43,12 @@ public:
void PollEvents() override;
std::vector<std::pair<std::string, std::string>> EnumerateDevices() override;
std::vector<InputBindingKey> EnumerateMotors() override;
bool GetGenericBindingMapping(const std::string_view& device, GenericInputBindingMapping* mapping) override;
bool GetGenericBindingMapping(std::string_view device, GenericInputBindingMapping* mapping) override;
void UpdateMotorState(InputBindingKey key, float intensity) override;
void UpdateMotorState(InputBindingKey large_key, InputBindingKey small_key, float large_intensity,
float small_intensity) override;
std::optional<InputBindingKey> ParseKeyString(const std::string_view& device,
const std::string_view& binding) override;
std::optional<InputBindingKey> ParseKeyString(std::string_view device, std::string_view binding) override;
TinyString ConvertKeyToString(InputBindingKey key) override;
TinyString ConvertKeyToIcon(InputBindingKey key) override;