libobs: Remove "using namespace std" from headers
Some checks are pending
Push / Format 🔍 (push) Waiting to run
Push / Build 🧱 (push) Waiting to run
Push / Validate Compatibility 🕵️ (push) Waiting to run
Push / Validate Services 🕵️ (push) Waiting to run
Push / Update Documentation 📖 (push) Waiting to run
Push / Deploy Documentation to Cloudflare ☁️ (push) Blocked by required conditions
Push / Create Sparkle Appcast 🎙️ (arm64) (push) Blocked by required conditions
Push / Create Sparkle Appcast 🎙️ (x86_64) (push) Blocked by required conditions
Push / merge-appcasts (push) Blocked by required conditions
Push / Windows Signing ✍️ (push) Blocked by required conditions
Push / Create Release 🛫 (push) Blocked by required conditions

This commit is contained in:
Warchamp7 2025-12-17 19:25:30 -05:00 committed by Ryan Foster
parent f6a56227eb
commit 6a64053256
6 changed files with 55 additions and 57 deletions

View File

@ -28,7 +28,7 @@
#include <fstream> #include <fstream>
#include <d3dcompiler.h> #include <d3dcompiler.h>
void gs_vertex_shader::GetBuffersExpected(const vector<D3D11_INPUT_ELEMENT_DESC> &inputs) void gs_vertex_shader::GetBuffersExpected(const std::vector<D3D11_INPUT_ELEMENT_DESC> &inputs)
{ {
for (size_t i = 0; i < inputs.size(); i++) { for (size_t i = 0; i < inputs.size(); i++) {
const D3D11_INPUT_ELEMENT_DESC &input = inputs[i]; const D3D11_INPUT_ELEMENT_DESC &input = inputs[i];
@ -52,7 +52,7 @@ gs_vertex_shader::gs_vertex_shader(gs_device_t *device, const char *file, const
{ {
ShaderProcessor processor(device); ShaderProcessor processor(device);
ComPtr<ID3D10Blob> shaderBlob; ComPtr<ID3D10Blob> shaderBlob;
string outputString; std::string outputString;
HRESULT hr; HRESULT hr;
processor.Process(shaderString, file); processor.Process(shaderString, file);
@ -88,7 +88,7 @@ gs_pixel_shader::gs_pixel_shader(gs_device_t *device, const char *file, const ch
{ {
ShaderProcessor processor(device); ShaderProcessor processor(device);
ComPtr<ID3D10Blob> shaderBlob; ComPtr<ID3D10Blob> shaderBlob;
string outputString; std::string outputString;
HRESULT hr; HRESULT hr;
processor.Process(shaderString, file); processor.Process(shaderString, file);
@ -226,26 +226,26 @@ void gs_shader::Compile(const char *shaderString, const char *file, const char *
snprintf(hashstr, sizeof(hashstr), "%02llx", hash); snprintf(hashstr, sizeof(hashstr), "%02llx", hash);
BPtr program_data = os_get_program_data_path_ptr("obs-studio/shader-cache"); BPtr program_data = os_get_program_data_path_ptr("obs-studio/shader-cache");
auto cachePath = filesystem::u8path(program_data.Get()) / hashstr; auto cachePath = std::filesystem::u8path(program_data.Get()) / hashstr;
// Increment if on-disk format changes // Increment if on-disk format changes
cachePath += ".v2"; cachePath += ".v2";
std::fstream cacheFile; std::fstream cacheFile;
cacheFile.exceptions(fstream::badbit | fstream::eofbit); cacheFile.exceptions(std::fstream::badbit | std::fstream::eofbit);
if (filesystem::exists(cachePath) && !filesystem::is_empty(cachePath)) if (std::filesystem::exists(cachePath) && !std::filesystem::is_empty(cachePath))
cacheFile.open(cachePath, ios::in | ios::binary | ios::ate); cacheFile.open(cachePath, std::ios::in | std::ios::binary | std::ios::ate);
if (cacheFile.is_open()) { if (cacheFile.is_open()) {
uint64_t checksum; uint64_t checksum;
try { try {
streampos len = cacheFile.tellg(); std::streampos len = cacheFile.tellg();
// Not enough data for checksum + shader // Not enough data for checksum + shader
if (len <= sizeof(checksum)) if (len <= sizeof(checksum))
throw length_error("File truncated"); throw std::length_error("File truncated");
cacheFile.seekg(0, ios::beg); cacheFile.seekg(0, std::ios::beg);
len -= sizeof(checksum); len -= sizeof(checksum);
D3DCreateBlob(len, shader); D3DCreateBlob(len, shader);
@ -254,14 +254,14 @@ void gs_shader::Compile(const char *shaderString, const char *file, const char *
cacheFile.read((char *)&checksum, sizeof(checksum)); cacheFile.read((char *)&checksum, sizeof(checksum));
if (calculated_checksum != checksum) if (calculated_checksum != checksum)
throw exception("Checksum mismatch"); throw std::exception("Checksum mismatch");
is_cached = true; is_cached = true;
} catch (const exception &e) { } catch (const std::exception &e) {
// Something went wrong reading the cache file, delete it // Something went wrong reading the cache file, delete it
blog(LOG_WARNING, "Loading shader cache file failed with \"%s\": %s", e.what(), file); blog(LOG_WARNING, "Loading shader cache file failed with \"%s\": %s", e.what(), file);
cacheFile.close(); cacheFile.close();
filesystem::remove(cachePath); std::filesystem::remove(cachePath);
} }
} }
@ -275,7 +275,7 @@ void gs_shader::Compile(const char *shaderString, const char *file, const char *
throw HRError("Failed to compile shader", hr); throw HRError("Failed to compile shader", hr);
} }
cacheFile.open(cachePath, ios::out | ios::binary); cacheFile.open(cachePath, std::ios::out | std::ios::binary);
if (cacheFile.is_open()) { if (cacheFile.is_open()) {
try { try {
uint64_t calculated_checksum = uint64_t calculated_checksum =
@ -283,10 +283,10 @@ void gs_shader::Compile(const char *shaderString, const char *file, const char *
cacheFile.write((char *)(*shader)->GetBufferPointer(), (*shader)->GetBufferSize()); cacheFile.write((char *)(*shader)->GetBufferPointer(), (*shader)->GetBufferSize());
cacheFile.write((char *)&calculated_checksum, sizeof(calculated_checksum)); cacheFile.write((char *)&calculated_checksum, sizeof(calculated_checksum));
} catch (const exception &e) { } catch (const std::exception &e) {
blog(LOG_WARNING, "Writing shader cache file failed with \"%s\": %s", e.what(), file); blog(LOG_WARNING, "Writing shader cache file failed with \"%s\": %s", e.what(), file);
cacheFile.close(); cacheFile.close();
filesystem::remove(cachePath); std::filesystem::remove(cachePath);
} }
} }
} }
@ -303,7 +303,7 @@ void gs_shader::Compile(const char *shaderString, const char *file, const char *
#endif #endif
} }
inline void gs_shader::UpdateParam(vector<uint8_t> &constData, gs_shader_param &param, bool &upload) inline void gs_shader::UpdateParam(std::vector<uint8_t> &constData, gs_shader_param &param, bool &upload)
{ {
if (param.type != GS_SHADER_PARAM_TEXTURE) { if (param.type != GS_SHADER_PARAM_TEXTURE) {
if (!param.curValue.size()) if (!param.curValue.size())
@ -342,7 +342,7 @@ inline void gs_shader::UpdateParam(vector<uint8_t> &constData, gs_shader_param &
void gs_shader::UploadParams() void gs_shader::UploadParams()
{ {
vector<uint8_t> constData; std::vector<uint8_t> constData;
bool upload = false; bool upload = false;
constData.reserve(constantSize); constData.reserve(constantSize);

View File

@ -28,10 +28,10 @@ struct ShaderProcessor {
gs_device_t *device; gs_device_t *device;
ShaderParser parser; ShaderParser parser;
void BuildInputLayout(vector<D3D11_INPUT_ELEMENT_DESC> &inputs); void BuildInputLayout(std::vector<D3D11_INPUT_ELEMENT_DESC> &inputs);
void BuildParams(vector<gs_shader_param> &params); void BuildParams(std::vector<gs_shader_param> &params);
void BuildSamplers(vector<unique_ptr<ShaderSampler>> &samplers); void BuildSamplers(std::vector<std::unique_ptr<ShaderSampler>> &samplers);
void BuildString(string &outputString); void BuildString(std::string &outputString);
void Process(const char *shader_string, const char *file); void Process(const char *shader_string, const char *file);
inline ShaderProcessor(gs_device_t *device) : device(device) {} inline ShaderProcessor(gs_device_t *device) : device(device) {}

View File

@ -479,9 +479,9 @@ struct HagsStatus {
} }
} }
string ToString() const std::string ToString() const
{ {
string status = enabled ? "Enabled" : "Disabled"; std::string status = enabled ? "Enabled" : "Disabled";
status += " (Default: "; status += " (Default: ";
status += enabled_by_default ? "Yes" : "No"; status += enabled_by_default ? "Yes" : "No";
status += ", Driver status: "; status += ", Driver status: ";
@ -509,9 +509,9 @@ private:
} }
}; };
static optional<HagsStatus> GetAdapterHagsStatus(const DXGI_ADAPTER_DESC *desc) static std::optional<HagsStatus> GetAdapterHagsStatus(const DXGI_ADAPTER_DESC *desc)
{ {
optional<HagsStatus> ret; std::optional<HagsStatus> ret;
D3DKMT_OPENADAPTERFROMLUID d3dkmt_openluid{}; D3DKMT_OPENADAPTERFROMLUID d3dkmt_openluid{};
d3dkmt_openluid.AdapterLuid = desc->AdapterLuid; d3dkmt_openluid.AdapterLuid = desc->AdapterLuid;
@ -586,7 +586,7 @@ static bool FastClearSupported(UINT vendorId, uint64_t version)
void gs_device::InitDevice(uint32_t adapterIdx) void gs_device::InitDevice(uint32_t adapterIdx)
{ {
wstring adapterName; std::wstring adapterName;
DXGI_ADAPTER_DESC desc; DXGI_ADAPTER_DESC desc;
D3D_FEATURE_LEVEL levelUsed = D3D_FEATURE_LEVEL_10_0; D3D_FEATURE_LEVEL levelUsed = D3D_FEATURE_LEVEL_10_0;
LARGE_INTEGER umd; LARGE_INTEGER umd;

View File

@ -43,8 +43,6 @@ struct shader_var;
struct shader_sampler; struct shader_sampler;
struct gs_vertex_shader; struct gs_vertex_shader;
using namespace std;
/* /*
* Just to clarify, all structs, and all public. These are exporting only * Just to clarify, all structs, and all public. These are exporting only
* via encapsulated C bindings, not C++ bindings, so the whole concept of * via encapsulated C bindings, not C++ bindings, so the whole concept of
@ -376,12 +374,12 @@ struct gs_vertex_buffer : gs_obj {
ComPtr<ID3D11Buffer> normalBuffer; ComPtr<ID3D11Buffer> normalBuffer;
ComPtr<ID3D11Buffer> colorBuffer; ComPtr<ID3D11Buffer> colorBuffer;
ComPtr<ID3D11Buffer> tangentBuffer; ComPtr<ID3D11Buffer> tangentBuffer;
vector<ComPtr<ID3D11Buffer>> uvBuffers; std::vector<ComPtr<ID3D11Buffer>> uvBuffers;
bool dynamic; bool dynamic;
VBDataPtr vbd; VBDataPtr vbd;
size_t numVerts; size_t numVerts;
vector<size_t> uvSizes; std::vector<size_t> uvSizes;
void FlushBuffer(ID3D11Buffer *buffer, void *array, size_t elementSize); void FlushBuffer(ID3D11Buffer *buffer, void *array, size_t elementSize);
@ -516,11 +514,11 @@ struct gs_texture_2d : gs_texture {
bool chroma = false; bool chroma = false;
bool acquired = false; bool acquired = false;
vector<vector<uint8_t>> data; std::vector<std::vector<uint8_t>> data;
vector<D3D11_SUBRESOURCE_DATA> srd; std::vector<D3D11_SUBRESOURCE_DATA> srd;
D3D11_TEXTURE2D_DESC td = {}; D3D11_TEXTURE2D_DESC td = {};
void InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd); void InitSRD(std::vector<D3D11_SUBRESOURCE_DATA> &srd);
void InitTexture(const uint8_t *const *data); void InitTexture(const uint8_t *const *data);
void InitResourceView(); void InitResourceView();
void InitRenderTargets(); void InitRenderTargets();
@ -571,11 +569,11 @@ struct gs_texture_3d : gs_texture {
bool chroma = false; bool chroma = false;
bool acquired = false; bool acquired = false;
vector<vector<uint8_t>> data; std::vector<std::vector<uint8_t>> data;
vector<D3D11_SUBRESOURCE_DATA> srd; std::vector<D3D11_SUBRESOURCE_DATA> srd;
D3D11_TEXTURE3D_DESC td = {}; D3D11_TEXTURE3D_DESC td = {};
void InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd); void InitSRD(std::vector<D3D11_SUBRESOURCE_DATA> &srd);
void InitTexture(const uint8_t *const *data); void InitTexture(const uint8_t *const *data);
void InitResourceView(); void InitResourceView();
void BackupTexture(const uint8_t *const *data); void BackupTexture(const uint8_t *const *data);
@ -655,7 +653,7 @@ struct gs_sampler_state : gs_obj {
}; };
struct gs_shader_param { struct gs_shader_param {
string name; std::string name;
gs_shader_param_type type; gs_shader_param_type type;
uint32_t textureID; uint32_t textureID;
@ -665,8 +663,8 @@ struct gs_shader_param {
size_t pos; size_t pos;
vector<uint8_t> curValue; std::vector<uint8_t> curValue;
vector<uint8_t> defaultValue; std::vector<uint8_t> defaultValue;
bool changed; bool changed;
gs_shader_param(shader_var &var, uint32_t &texCounter); gs_shader_param(shader_var &var, uint32_t &texCounter);
@ -681,14 +679,14 @@ struct ShaderError {
struct gs_shader : gs_obj { struct gs_shader : gs_obj {
gs_shader_type type; gs_shader_type type;
vector<gs_shader_param> params; std::vector<gs_shader_param> params;
ComPtr<ID3D11Buffer> constants; ComPtr<ID3D11Buffer> constants;
size_t constantSize; size_t constantSize;
D3D11_BUFFER_DESC bd = {}; D3D11_BUFFER_DESC bd = {};
vector<uint8_t> data; std::vector<uint8_t> data;
inline void UpdateParam(vector<uint8_t> &constData, gs_shader_param &param, bool &upload); inline void UpdateParam(std::vector<uint8_t> &constData, gs_shader_param &param, bool &upload);
void UploadParams(); void UploadParams();
void BuildConstantBuffer(); void BuildConstantBuffer();
@ -705,7 +703,7 @@ struct gs_shader : gs_obj {
}; };
struct ShaderSampler { struct ShaderSampler {
string name; std::string name;
gs_sampler_state sampler; gs_sampler_state sampler;
inline ShaderSampler(const char *name, gs_device_t *device, gs_sampler_info *info) inline ShaderSampler(const char *name, gs_device_t *device, gs_sampler_info *info)
@ -721,7 +719,7 @@ struct gs_vertex_shader : gs_shader {
gs_shader_param *world, *viewProj; gs_shader_param *world, *viewProj;
vector<D3D11_INPUT_ELEMENT_DESC> layoutData; std::vector<D3D11_INPUT_ELEMENT_DESC> layoutData;
bool hasNormals; bool hasNormals;
bool hasColors; bool hasColors;
@ -750,7 +748,7 @@ struct gs_vertex_shader : gs_shader {
return count; return count;
} }
void GetBuffersExpected(const vector<D3D11_INPUT_ELEMENT_DESC> &inputs); void GetBuffersExpected(const std::vector<D3D11_INPUT_ELEMENT_DESC> &inputs);
gs_vertex_shader(gs_device_t *device, const char *file, const char *shaderString); gs_vertex_shader(gs_device_t *device, const char *file, const char *shaderString);
}; };
@ -775,7 +773,7 @@ struct gs_duplicator : gs_obj {
struct gs_pixel_shader : gs_shader { struct gs_pixel_shader : gs_shader {
ComPtr<ID3D11PixelShader> shader; ComPtr<ID3D11PixelShader> shader;
vector<unique_ptr<ShaderSampler>> samplers; std::vector<std::unique_ptr<ShaderSampler>> samplers;
void Rebuild(ID3D11Device *dev); void Rebuild(ID3D11Device *dev);
@ -987,9 +985,9 @@ struct gs_device {
ZStencilState zstencilState; ZStencilState zstencilState;
RasterState rasterState; RasterState rasterState;
BlendState blendState; BlendState blendState;
vector<SavedZStencilState> zstencilStates; std::vector<SavedZStencilState> zstencilStates;
vector<SavedRasterState> rasterStates; std::vector<SavedRasterState> rasterStates;
vector<SavedBlendState> blendStates; std::vector<SavedBlendState> blendStates;
ID3D11DepthStencilState *curDepthStencilState = nullptr; ID3D11DepthStencilState *curDepthStencilState = nullptr;
ID3D11RasterizerState *curRasterState = nullptr; ID3D11RasterizerState *curRasterState = nullptr;
ID3D11BlendState *curBlendState = nullptr; ID3D11BlendState *curBlendState = nullptr;
@ -997,16 +995,16 @@ struct gs_device {
gs_rect viewport; gs_rect viewport;
vector<mat4float> projStack; std::vector<mat4float> projStack;
matrix4 curProjMatrix; matrix4 curProjMatrix;
matrix4 curViewMatrix; matrix4 curViewMatrix;
matrix4 curViewProjMatrix; matrix4 curViewProjMatrix;
vector<gs_device_loss> loss_callbacks; std::vector<gs_device_loss> loss_callbacks;
gs_obj *first_obj = nullptr; gs_obj *first_obj = nullptr;
vector<std::pair<HMONITOR, gs_monitor_color_info>> monitor_to_hdr; std::vector<std::pair<HMONITOR, gs_monitor_color_info>> monitor_to_hdr;
void InitFactory(); void InitFactory();
void InitAdapter(uint32_t adapterIdx); void InitAdapter(uint32_t adapterIdx);

View File

@ -18,7 +18,7 @@
#include <util/base.h> #include <util/base.h>
#include "d3d11-subsystem.hpp" #include "d3d11-subsystem.hpp"
void gs_texture_2d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd) void gs_texture_2d::InitSRD(std::vector<D3D11_SUBRESOURCE_DATA> &srd)
{ {
uint32_t rowSizeBytes = width * gs_get_format_bpp(format); uint32_t rowSizeBytes = width * gs_get_format_bpp(format);
uint32_t texSizeBytes = height * rowSizeBytes / 8; uint32_t texSizeBytes = height * rowSizeBytes / 8;
@ -66,7 +66,7 @@ void gs_texture_2d::BackupTexture(const uint8_t *const *data)
uint32_t texSize = bbp * w * h / 8; uint32_t texSize = bbp * w * h / 8;
vector<uint8_t> &subData = this->data[i]; std::vector<uint8_t> &subData = this->data[i];
subData.resize(texSize); subData.resize(texSize);
memcpy(&subData[0], data[i], texSize); memcpy(&subData[0], data[i], texSize);

View File

@ -18,7 +18,7 @@
#include <util/base.h> #include <util/base.h>
#include "d3d11-subsystem.hpp" #include "d3d11-subsystem.hpp"
void gs_texture_3d::InitSRD(vector<D3D11_SUBRESOURCE_DATA> &srd) void gs_texture_3d::InitSRD(std::vector<D3D11_SUBRESOURCE_DATA> &srd)
{ {
uint32_t rowSizeBits = width * gs_get_format_bpp(format); uint32_t rowSizeBits = width * gs_get_format_bpp(format);
uint32_t sliceSizeBytes = height * rowSizeBits / 8; uint32_t sliceSizeBytes = height * rowSizeBits / 8;
@ -58,7 +58,7 @@ void gs_texture_3d::BackupTexture(const uint8_t *const *data)
const uint32_t texSize = bbp * w * h * d / 8; const uint32_t texSize = bbp * w * h * d / 8;
this->data[i].resize(texSize); this->data[i].resize(texSize);
vector<uint8_t> &subData = this->data[i]; std::vector<uint8_t> &subData = this->data[i];
memcpy(&subData[0], data[i], texSize); memcpy(&subData[0], data[i], texSize);
if (w > 1) if (w > 1)