Misc: Swap gsl::span for std::span

This commit is contained in:
Stenzek 2023-09-05 21:07:20 +10:00
parent 391307efaa
commit 605aa3c53a
18 changed files with 30 additions and 33 deletions

View file

@ -1033,7 +1033,7 @@ TinyString GameList::FormatTimespan(std::time_t timespan, bool long_format)
} }
std::vector<std::pair<std::string, const GameList::Entry*>> std::vector<std::pair<std::string, const GameList::Entry*>>
GameList::GetMatchingEntriesForSerial(const gsl::span<const std::string> serials) GameList::GetMatchingEntriesForSerial(const std::span<const std::string> serials)
{ {
std::vector<std::pair<std::string, const GameList::Entry*>> ret; std::vector<std::pair<std::string, const GameList::Entry*>> ret;
ret.reserve(serials.size()); ret.reserve(serials.size());

View file

@ -10,11 +10,10 @@
#include "common/string.h" #include "common/string.h"
#include "gsl/span"
#include <ctime> #include <ctime>
#include <functional> #include <functional>
#include <mutex> #include <mutex>
#include <span>
#include <string> #include <string>
class ByteStream; class ByteStream;
@ -107,7 +106,7 @@ std::string GetNewCoverImagePathForEntry(const Entry* entry, const char* new_fil
/// Returns a list of (title, entry) for entries matching serials. Titles will match the gamedb title, /// Returns a list of (title, entry) for entries matching serials. Titles will match the gamedb title,
/// except when two files have the same serial, in which case the filename will be used instead. /// except when two files have the same serial, in which case the filename will be used instead.
std::vector<std::pair<std::string, const Entry*>> std::vector<std::pair<std::string, const Entry*>>
GetMatchingEntriesForSerial(const gsl::span<const std::string> serials); GetMatchingEntriesForSerial(const std::span<const std::string> serials);
/// Downloads covers using the specified URL templates. By default, covers are saved by title, but this can be changed /// Downloads covers using the specified URL templates. By default, covers are saved by title, but this can be changed
/// with the use_serial parameter. save_callback optionall takes the entry and the path the new cover is saved to. /// with the use_serial parameter. save_callback optionall takes the entry and the path the new cover is saved to.

View file

@ -774,11 +774,11 @@ bool GPU_HW::CompilePipelines()
plconfig.input_layout.vertex_attributes = plconfig.input_layout.vertex_attributes =
textured ? textured ?
(m_using_uv_limits ? gsl::span<const GPUPipeline::VertexAttribute>( (m_using_uv_limits ? std::span<const GPUPipeline::VertexAttribute>(
vertex_attributes, NUM_BATCH_TEXTURED_LIMITS_VERTEX_ATTRIBUTES) : vertex_attributes, NUM_BATCH_TEXTURED_LIMITS_VERTEX_ATTRIBUTES) :
gsl::span<const GPUPipeline::VertexAttribute>( std::span<const GPUPipeline::VertexAttribute>(
vertex_attributes, NUM_BATCH_TEXTURED_VERTEX_ATTRIBUTES)) : vertex_attributes, NUM_BATCH_TEXTURED_VERTEX_ATTRIBUTES)) :
gsl::span<const GPUPipeline::VertexAttribute>(vertex_attributes, NUM_BATCH_VERTEX_ATTRIBUTES); std::span<const GPUPipeline::VertexAttribute>(vertex_attributes, NUM_BATCH_VERTEX_ATTRIBUTES);
plconfig.vertex_shader = batch_vertex_shaders[BoolToUInt8(textured)].get(); plconfig.vertex_shader = batch_vertex_shaders[BoolToUInt8(textured)].get();
plconfig.fragment_shader = plconfig.fragment_shader =
@ -856,7 +856,7 @@ bool GPU_HW::CompilePipelines()
GL_OBJECT_NAME(fs, "Batch Wireframe Fragment Shader"); GL_OBJECT_NAME(fs, "Batch Wireframe Fragment Shader");
plconfig.input_layout.vertex_attributes = plconfig.input_layout.vertex_attributes =
gsl::span<const GPUPipeline::VertexAttribute>(vertex_attributes, NUM_BATCH_VERTEX_ATTRIBUTES); std::span<const GPUPipeline::VertexAttribute>(vertex_attributes, NUM_BATCH_VERTEX_ATTRIBUTES);
plconfig.blend = (m_wireframe_mode == GPUWireframeMode::OverlayWireframe) ? plconfig.blend = (m_wireframe_mode == GPUWireframeMode::OverlayWireframe) ?
GPUPipeline::BlendState::GetAlphaBlendingState() : GPUPipeline::BlendState::GetAlphaBlendingState() :
GPUPipeline::BlendState::GetNoBlendingState(); GPUPipeline::BlendState::GetNoBlendingState();

View file

@ -30,7 +30,6 @@
#include "IconsFontAwesome5.h" #include "IconsFontAwesome5.h"
#include "fmt/chrono.h" #include "fmt/chrono.h"
#include "fmt/format.h" #include "fmt/format.h"
#include "gsl/span"
#include "imgui.h" #include "imgui.h"
#include "imgui_internal.h" #include "imgui_internal.h"
@ -39,6 +38,7 @@
#include <cmath> #include <cmath>
#include <deque> #include <deque>
#include <mutex> #include <mutex>
#include <span>
#include <unordered_map> #include <unordered_map>
#if defined(CPU_X64) #if defined(CPU_X64)
@ -64,7 +64,7 @@ namespace SaveStateSelectorUI {
static void Draw(); static void Draw();
} }
static std::tuple<float, float> GetMinMax(gsl::span<const float> values) static std::tuple<float, float> GetMinMax(std::span<const float> values)
{ {
#if defined(CPU_X64) #if defined(CPU_X64)
__m128 vmin(_mm_loadu_ps(values.data())); __m128 vmin(_mm_loadu_ps(values.data()));

View file

@ -68,7 +68,7 @@ public:
std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override; std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) 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, const std::string_view& source,
const char* entry_point, DynamicHeapArray<u8>* binary) override; const char* entry_point, DynamicHeapArray<u8>* binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;

View file

@ -51,7 +51,7 @@ void D3D11Shader::SetDebugName(const std::string_view& name)
SetD3DDebugObjectName(m_shader.Get(), name); SetD3DDebugObjectName(m_shader.Get(), name);
} }
std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) std::unique_ptr<GPUShader> D3D11Device::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data)
{ {
ComPtr<ID3D11DeviceChild> shader; ComPtr<ID3D11DeviceChild> shader;
std::vector<u8> bytecode; std::vector<u8> bytecode;

View file

@ -88,7 +88,7 @@ public:
std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override; std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) 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, const std::string_view& source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override; const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;

View file

@ -25,7 +25,7 @@ void D3D12Shader::SetDebugName(const std::string_view& name)
{ {
} }
std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) std::unique_ptr<GPUShader> D3D12Device::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data)
{ {
// Can't do much at this point. // Can't do much at this point.
std::vector bytecode(data.begin(), data.end()); std::vector bytecode(data.begin(), data.end());

View file

@ -12,10 +12,9 @@
#include "common/rectangle.h" #include "common/rectangle.h"
#include "common/types.h" #include "common/types.h"
#include "gsl/span"
#include <memory> #include <memory>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <tuple> #include <tuple>
@ -231,7 +230,7 @@ public:
struct InputLayout struct InputLayout
{ {
gsl::span<const VertexAttribute> vertex_attributes; std::span<const VertexAttribute> vertex_attributes;
u32 vertex_stride; u32 vertex_stride;
bool operator==(const InputLayout& rhs) const; bool operator==(const InputLayout& rhs) const;
@ -634,7 +633,7 @@ protected:
virtual bool ReadPipelineCache(const std::string& filename); virtual bool ReadPipelineCache(const std::string& filename);
virtual bool GetPipelineCacheData(DynamicHeapArray<u8>* data); virtual bool GetPipelineCacheData(DynamicHeapArray<u8>* data);
virtual std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) = 0; 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, const std::string_view& source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary) = 0; DynamicHeapArray<u8>* out_binary) = 0;

View file

@ -224,7 +224,7 @@ public:
std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override; std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) 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, const std::string_view& source,
const char* entry_point, const char* entry_point,
DynamicHeapArray<u8>* out_binary = nullptr) override; DynamicHeapArray<u8>* out_binary = nullptr) override;

View file

@ -637,7 +637,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage
} }
} }
std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data)
{ {
const std::string_view str_data(reinterpret_cast<const char*>(data.data()), data.size()); const std::string_view str_data(reinterpret_cast<const char*>(data.data()), data.size());
return CreateShaderFromMSL(stage, str_data, "main0"); return CreateShaderFromMSL(stage, str_data, "main0");

View file

@ -68,7 +68,7 @@ public:
std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override; std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) 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, const std::string_view& source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override; const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@ -111,7 +111,7 @@ public:
void UnrefProgram(const OpenGLPipeline::ProgramCacheKey& key); void UnrefProgram(const OpenGLPipeline::ProgramCacheKey& key);
GLuint LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key); GLuint LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& key);
GLuint CreateVAO(gsl::span<const GPUPipeline::VertexAttribute> attributes, u32 stride); GLuint CreateVAO(std::span<const GPUPipeline::VertexAttribute> attributes, u32 stride);
void UnrefVAO(const OpenGLPipeline::VertexArrayCacheKey& key); void UnrefVAO(const OpenGLPipeline::VertexArrayCacheKey& key);
void SetActiveTexture(u32 slot); void SetActiveTexture(u32 slot);

View file

@ -168,7 +168,7 @@ bool OpenGLShader::Compile()
return true; return true;
} }
std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data)
{ {
// Not supported.. except spir-v maybe? but no point really... // Not supported.. except spir-v maybe? but no point really...
return {}; return {};
@ -455,7 +455,7 @@ GLuint OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& k
OpenGLPipeline::VertexArrayCacheItem item; OpenGLPipeline::VertexArrayCacheItem item;
item.vao_id = item.vao_id =
CreateVAO(gsl::span<const GPUPipeline::VertexAttribute>(key.vertex_attributes, key.num_vertex_attributes), CreateVAO(std::span<const GPUPipeline::VertexAttribute>(key.vertex_attributes, key.num_vertex_attributes),
key.vertex_attribute_stride); key.vertex_attribute_stride);
if (item.vao_id == 0) if (item.vao_id == 0)
return 0; return 0;
@ -465,7 +465,7 @@ GLuint OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& k
return item.vao_id; return item.vao_id;
} }
GLuint OpenGLDevice::CreateVAO(gsl::span<const GPUPipeline::VertexAttribute> attributes, u32 stride) GLuint OpenGLDevice::CreateVAO(std::span<const GPUPipeline::VertexAttribute> attributes, u32 stride)
{ {
glGetError(); glGetError();
GLuint vao; GLuint vao;

View file

@ -6,7 +6,6 @@
#include "common/types.h" #include "common/types.h"
#include "fmt/format.h" #include "fmt/format.h"
#include "gsl/span"
#include <array> #include <array>
#include <atomic> #include <atomic>
@ -18,6 +17,7 @@
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <tuple> #include <tuple>

View file

@ -173,7 +173,7 @@ std::optional<SPIRVCompiler::SPIRVCodeVector> SPIRVCompiler::CompileShader(GPUSh
#ifdef __APPLE__ #ifdef __APPLE__
std::optional<std::string> SPIRVCompiler::CompileSPIRVToMSL(gsl::span<const SPIRVCodeType> spv) std::optional<std::string> SPIRVCompiler::CompileSPIRVToMSL(std::span<const SPIRVCodeType> spv)
{ {
spirv_cross::CompilerMSL compiler(spv.data(), spv.size()); spirv_cross::CompilerMSL compiler(spv.data(), spv.size());
std::string msl = compiler.compile(); std::string msl = compiler.compile();

View file

@ -5,9 +5,8 @@
#include "common/types.h" #include "common/types.h"
#include "gsl/span"
#include <optional> #include <optional>
#include <span>
#include <string> #include <string>
#include <string_view> #include <string_view>
#include <vector> #include <vector>
@ -43,7 +42,7 @@ std::optional<SPIRVCodeVector> CompileShader(GPUShaderStage stage, std::string_v
#ifdef __APPLE__ #ifdef __APPLE__
// Converts a SPIR-V shader into MSL. // Converts a SPIR-V shader into MSL.
std::optional<std::string> CompileSPIRVToMSL(gsl::span<const SPIRVCodeType> spv); std::optional<std::string> CompileSPIRVToMSL(std::span<const SPIRVCodeType> spv);
#endif #endif

View file

@ -89,7 +89,7 @@ public:
std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override; std::unique_ptr<GPUFramebuffer> CreateFramebuffer(GPUTexture* rt_or_ds, GPUTexture* ds = nullptr) override;
std::unique_ptr<GPUShader> CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) 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, const std::string_view& source,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override; const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override; std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;

View file

@ -25,7 +25,7 @@ void VulkanShader::SetDebugName(const std::string_view& name)
Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, name); Vulkan::SetObjectName(VulkanDevice::GetInstance().GetVulkanDevice(), m_module, name);
} }
std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromBinary(GPUShaderStage stage, gsl::span<const u8> data) std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromBinary(GPUShaderStage stage, std::span<const u8> data)
{ {
VkShaderModule mod; VkShaderModule mod;
@ -67,7 +67,7 @@ std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromSource(GPUShaderStage s
std::memcpy(out_binary->data(), spirv->data(), spirv_size); std::memcpy(out_binary->data(), spirv->data(), spirv_size);
} }
return CreateShaderFromBinary(stage, gsl::span<const u8>(reinterpret_cast<const u8*>(spirv->data()), spirv_size)); return CreateShaderFromBinary(stage, std::span<const u8>(reinterpret_cast<const u8*>(spirv->data()), spirv_size));
} }
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////