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*>>
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;
ret.reserve(serials.size());

View File

@ -10,11 +10,10 @@
#include "common/string.h"
#include "gsl/span"
#include <ctime>
#include <functional>
#include <mutex>
#include <span>
#include <string>
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,
/// 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*>>
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
/// 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 =
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) :
gsl::span<const GPUPipeline::VertexAttribute>(
std::span<const GPUPipeline::VertexAttribute>(
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.fragment_shader =
@ -856,7 +856,7 @@ bool GPU_HW::CompilePipelines()
GL_OBJECT_NAME(fs, "Batch Wireframe Fragment Shader");
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) ?
GPUPipeline::BlendState::GetAlphaBlendingState() :
GPUPipeline::BlendState::GetNoBlendingState();

View File

@ -30,7 +30,6 @@
#include "IconsFontAwesome5.h"
#include "fmt/chrono.h"
#include "fmt/format.h"
#include "gsl/span"
#include "imgui.h"
#include "imgui_internal.h"
@ -39,6 +38,7 @@
#include <cmath>
#include <deque>
#include <mutex>
#include <span>
#include <unordered_map>
#if defined(CPU_X64)
@ -64,7 +64,7 @@ namespace SaveStateSelectorUI {
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)
__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<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,
const char* entry_point, DynamicHeapArray<u8>* binary) 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);
}
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;
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<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,
const char* entry_point, DynamicHeapArray<u8>* out_binary) 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.
std::vector bytecode(data.begin(), data.end());

View File

@ -12,10 +12,9 @@
#include "common/rectangle.h"
#include "common/types.h"
#include "gsl/span"
#include <memory>
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <tuple>
@ -231,7 +230,7 @@ public:
struct InputLayout
{
gsl::span<const VertexAttribute> vertex_attributes;
std::span<const VertexAttribute> vertex_attributes;
u32 vertex_stride;
bool operator==(const InputLayout& rhs) const;
@ -634,7 +633,7 @@ protected:
virtual bool ReadPipelineCache(const std::string& filename);
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,
const char* entry_point,
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<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,
const char* entry_point,
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());
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<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,
const char* entry_point, DynamicHeapArray<u8>* out_binary) override;
std::unique_ptr<GPUPipeline> CreatePipeline(const GPUPipeline::GraphicsConfig& config) override;
@ -111,7 +111,7 @@ public:
void UnrefProgram(const OpenGLPipeline::ProgramCacheKey& 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 SetActiveTexture(u32 slot);

View File

@ -168,7 +168,7 @@ bool OpenGLShader::Compile()
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...
return {};
@ -455,7 +455,7 @@ GLuint OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& k
OpenGLPipeline::VertexArrayCacheItem item;
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);
if (item.vao_id == 0)
return 0;
@ -465,7 +465,7 @@ GLuint OpenGLDevice::LookupVAOCache(const OpenGLPipeline::VertexArrayCacheKey& k
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();
GLuint vao;

View File

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

View File

@ -173,7 +173,7 @@ std::optional<SPIRVCompiler::SPIRVCodeVector> SPIRVCompiler::CompileShader(GPUSh
#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());
std::string msl = compiler.compile();

View File

@ -5,9 +5,8 @@
#include "common/types.h"
#include "gsl/span"
#include <optional>
#include <span>
#include <string>
#include <string_view>
#include <vector>
@ -43,7 +42,7 @@ std::optional<SPIRVCodeVector> CompileShader(GPUShaderStage stage, std::string_v
#ifdef __APPLE__
// 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

View File

@ -89,7 +89,7 @@ public:
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,
const char* entry_point, DynamicHeapArray<u8>* out_binary) 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);
}
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;
@ -67,7 +67,7 @@ std::unique_ptr<GPUShader> VulkanDevice::CreateShaderFromSource(GPUShaderStage s
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));
}
//////////////////////////////////////////////////////////////////////////