Massive fmtlib refactor

This commit is contained in:
Jack Andersen
2019-07-19 18:22:36 -10:00
parent b2bf7549f5
commit deefc8e995
38 changed files with 364 additions and 400 deletions

View File

@@ -184,7 +184,7 @@ class D3D11TextureS : public GraphicsDataNode<ITextureS> {
pxTilePitch = 4;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
CD3D11_TEXTURE2D_DESC desc(pfmt, width, height, 1, mips, D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_IMMUTABLE);
@@ -237,7 +237,7 @@ class D3D11TextureSA : public GraphicsDataNode<ITextureSA> {
pixelFmt = DXGI_FORMAT_R16_UNORM;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
CD3D11_TEXTURE2D_DESC desc(pixelFmt, width, height, layers, mips, D3D11_BIND_SHADER_RESOURCE,
@@ -299,7 +299,7 @@ class D3D11TextureD : public GraphicsDataNode<ITextureD> {
m_pxPitch = 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_cpuSz = width * height * m_pxPitch;
@@ -388,9 +388,9 @@ class D3D11TextureR : public GraphicsDataNode<ITextureR> {
, m_colorBindCount(colorBindCount)
, m_depthBindCount(depthBindCount) {
if (colorBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many color bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
if (depthBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
if (samples == 0)
m_samples = 1;
@@ -776,7 +776,7 @@ struct D3D11ShaderDataBinding : public GraphicsDataNode<IShaderDataBinding> {
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (ubufOffs[i] % 256)
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding"),
int(i));
#endif
m_ubufFirstConsts[i] = ubufOffs[i] / 16;
@@ -786,7 +786,7 @@ struct D3D11ShaderDataBinding : public GraphicsDataNode<IShaderDataBinding> {
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (!ubufs[i])
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
Log.report(logvisor::Fatal, fmt("null uniform-buffer %d provided to newShaderDataBinding"), int(i));
#endif
m_ubufs.push_back(ubufs[i]);
}
@@ -1507,7 +1507,7 @@ void D3D11CommandQueue::RenderingWorker(D3D11CommandQueue* self) {
if (D3D11TextureR* csource = CmdList.workDoPresent.cast<D3D11TextureR>()) {
#ifndef NDEBUG
if (!csource->m_colorBindCount)
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
#endif
if (dataFactory->m_gamma != 1.f) {
@@ -1621,8 +1621,8 @@ std::vector<uint8_t> D3D11DataFactory::CompileHLSL(const char* source, PipelineS
ComPtr<ID3DBlob> blobOut;
if (FAILED(D3DCompilePROC(source, strlen(source), "Boo HLSL Source", nullptr, nullptr, "main",
D3DShaderTypes[int(stage)], BOO_D3DCOMPILE_FLAG, 0, &blobOut, &errBlob))) {
printf("%s\n", source);
Log.report(logvisor::Fatal, "error compiling shader: %s", errBlob->GetBufferPointer());
fmt::print(fmt("{}\n"), source);
Log.report(logvisor::Fatal, fmt("error compiling shader: %s"), errBlob->GetBufferPointer());
return {};
}
std::vector<uint8_t> ret(blobOut->GetBufferSize());

View File

@@ -76,7 +76,7 @@ class GLDataFactoryImpl : public GLDataFactory, public GraphicsDataFactoryHead {
void SetupGammaResources() {
/* Good enough place for this */
if (!glslang::InitializeProcess())
Log.report(logvisor::Error, "unable to initialize glslang");
Log.report(logvisor::Error, fmt("unable to initialize glslang"));
if (GLEW_ARB_tessellation_shader) {
m_hasTessellation = true;
@@ -320,7 +320,7 @@ class GLTextureS : public GraphicsDataNode<ITextureS> {
pxPitch = 1;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
if (compressed) {
@@ -404,7 +404,7 @@ class GLTextureSA : public GraphicsDataNode<ITextureSA> {
pxPitch = 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
GLenum compType = intFormat == GL_R16 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
@@ -467,7 +467,7 @@ class GLTextureD : public GraphicsDataNode<ITextureD> {
pxPitch = 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_cpuSz = width * height * pxPitch;
m_cpuBuf.reset(new uint8_t[m_cpuSz]);
@@ -710,15 +710,15 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
glslang::TShader shader(lang);
shader.setStrings(&source, 1);
if (!shader.parse(&glslang::DefaultTBuiltInResource, 110, false, messages)) {
printf("%s\n", source);
Log.report(logvisor::Fatal, "unable to compile shader\n%s", shader.getInfoLog());
fmt::print(fmt("{}\n"), source);
Log.report(logvisor::Fatal, fmt("unable to compile shader\n{}"), shader.getInfoLog());
}
glslang::TProgram prog;
prog.addShader(&shader);
if (!prog.link(messages)) {
printf("%s\n", source);
Log.report(logvisor::Fatal, "unable to link shader program\n%s", prog.getInfoLog());
fmt::print(fmt("{}\n"), source);
Log.report(logvisor::Fatal, fmt("unable to link shader program\n{}"), prog.getInfoLog());
}
prog.buildReflection();
@@ -729,7 +729,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
continue;
const auto& qual = tp->getQualifier();
if (!qual.hasBinding())
Log.report(logvisor::Fatal, "shader uniform %s does not have layout binding", prog.getUniformName(i));
Log.report(logvisor::Fatal, fmt("shader uniform {} does not have layout binding"), prog.getUniformName(i));
m_texNames.emplace_back(std::make_pair(prog.getUniformName(i), qual.layoutBinding - BOO_GLSL_MAX_UNIFORM_COUNT));
}
count = prog.getNumLiveUniformBlocks();
@@ -738,7 +738,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
const glslang::TType* tp = prog.getUniformBlockTType(i);
const auto& qual = tp->getQualifier();
if (!qual.hasBinding())
Log.report(logvisor::Fatal, "shader uniform %s does not have layout binding", prog.getUniformBlockName(i));
Log.report(logvisor::Fatal, fmt("shader uniform {} does not have layout binding"), prog.getUniformBlockName(i));
m_blockNames.emplace_back(std::make_pair(prog.getUniformBlockName(i), qual.layoutBinding));
}
}
@@ -749,7 +749,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
m_shad = glCreateShader(SHADER_STAGE_TABLE[int(stage)]);
if (!m_shad) {
Log.report(logvisor::Fatal, "unable to create shader");
Log.report(logvisor::Fatal, fmt("unable to create shader"));
return;
}
@@ -762,7 +762,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
glGetShaderiv(m_shad, GL_INFO_LOG_LENGTH, &logLen);
std::unique_ptr<char[]> log(new char[logLen]);
glGetShaderInfoLog(m_shad, logLen, nullptr, log.get());
Log.report(logvisor::Fatal, "unable to compile source\n%s\n%s\n", log.get(), source);
Log.report(logvisor::Fatal, fmt("unable to compile source\n{}\n{}\n"), log.get(), source);
return;
}
}
@@ -853,7 +853,7 @@ public:
if (!m_prog) {
m_prog = glCreateProgram();
if (!m_prog) {
Log.report(logvisor::Error, "unable to create shader program");
Log.report(logvisor::Error, fmt("unable to create shader program"));
return 0;
}
@@ -888,7 +888,7 @@ public:
glGetProgramiv(m_prog, GL_INFO_LOG_LENGTH, &logLen);
std::unique_ptr<char[]> log(new char[logLen]);
glGetProgramInfoLog(m_prog, logLen, nullptr, log.get());
Log.report(logvisor::Fatal, "unable to link shader program\n%s\n", log.get());
Log.report(logvisor::Fatal, fmt("unable to link shader program\n{}\n"), log.get());
return 0;
}
@@ -899,12 +899,12 @@ public:
for (const auto& name : stage->getBlockNames()) {
GLint uniLoc = glGetUniformBlockIndex(m_prog, name.first.c_str());
// if (uniLoc < 0)
// Log.report(logvisor::Warning, "unable to find uniform block '%s'", uniformBlockNames[i]);
// Log.report(logvisor::Warning, fmt("unable to find uniform block '%s'"), uniformBlockNames[i]);
m_uniLocs[name.second] = uniLoc;
}
for (const auto& name : stage->getTexNames()) {
GLint texLoc = glGetUniformLocation(m_prog, name.first.c_str());
if (texLoc < 0) { /* Log.report(logvisor::Warning, "unable to find sampler variable '%s'", texNames[i]); */
if (texLoc < 0) { /* Log.report(logvisor::Warning, fmt("unable to find sampler variable '%s'"), texNames[i]); */
} else
glUniform1i(texLoc, name.second);
}
@@ -975,7 +975,7 @@ ObjToken<IShaderStage> GLDataFactory::Context::newShaderStage(const uint8_t* dat
if (stage == PipelineStage::Control || stage == PipelineStage::Evaluation) {
if (!factory.m_hasTessellation)
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
}
BOO_MSAN_NO_INTERCEPT
@@ -990,9 +990,9 @@ ObjToken<IShaderPipeline> GLDataFactory::Context::newShaderPipeline(
if (control || evaluation) {
if (!factory.m_hasTessellation)
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
if (additionalInfo.patchSize > factory.m_maxPatchSize)
Log.report(logvisor::Fatal, "Device supports %d patch vertices, %d requested", int(factory.m_maxPatchSize),
Log.report(logvisor::Fatal, fmt("Device supports {} patch vertices, {} requested"), int(factory.m_maxPatchSize),
int(additionalInfo.patchSize));
}
@@ -1301,7 +1301,7 @@ struct GLCommandQueue : IGraphicsCommandQueue {
std::unique_lock<std::mutex> lk(self->m_initmt);
self->m_parent->makeCurrent();
const GLubyte* version = glGetString(GL_VERSION);
Log.report(logvisor::Info, "OpenGL Version: %s", version);
Log.report(logvisor::Info, fmt("OpenGL Version: {}"), version);
self->m_parent->postInit();
glClearColor(0.f, 0.f, 0.f, 0.f);
if (GLEW_EXT_texture_filter_anisotropic) {
@@ -1493,7 +1493,7 @@ struct GLCommandQueue : IGraphicsCommandQueue {
if (const GLTextureR* tex = cmd.source.cast<GLTextureR>()) {
#ifndef NDEBUG
if (!tex->m_colorBindCount)
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
#endif
if (dataFactory->m_gamma != 1.f) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, tex->m_fbo);
@@ -1799,12 +1799,12 @@ GLTextureR::GLTextureR(const ObjToken<BaseGraphicsData>& parent, GLCommandQueue*
glGenTextures(2, m_texs);
if (colorBindingCount) {
if (colorBindingCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many color bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
glGenTextures(colorBindingCount, m_bindTexs[0]);
}
if (depthBindingCount) {
if (depthBindingCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
glGenTextures(depthBindingCount, m_bindTexs[1]);
}
@@ -1918,8 +1918,7 @@ GLShaderDataBinding(const ObjToken<BaseGraphicsData>& d, const ObjToken<IShaderP
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (ubufOffs[i] % 256)
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
int(i));
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset {} provided to newShaderDataBinding"), int(i));
#endif
m_ubufOffs.emplace_back(ubufOffs[i], (ubufSizes[i] + 255) & ~255);
}
@@ -1928,7 +1927,7 @@ GLShaderDataBinding(const ObjToken<BaseGraphicsData>& d, const ObjToken<IShaderP
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (!ubufs[i])
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
Log.report(logvisor::Fatal, fmt("null uniform-buffer {} provided to newShaderDataBinding"), int(i));
#endif
m_ubufs.push_back(ubufs[i]);
}

View File

@@ -6,9 +6,9 @@ static logvisor::Module Log("boo::GLX");
void GLXExtensionCheck() {
if (!GLXEW_SGI_video_sync)
Log.report(logvisor::Fatal, "GLX_SGI_video_sync not available");
Log.report(logvisor::Fatal, fmt("GLX_SGI_video_sync not available"));
if (!GLXEW_EXT_swap_control && !GLXEW_MESA_swap_control && !GLXEW_SGI_swap_control)
Log.report(logvisor::Fatal, "swap_control not available");
Log.report(logvisor::Fatal, fmt("swap_control not available"));
}
void GLXEnableVSync(Display* disp, GLXWindow drawable) {

View File

@@ -386,7 +386,7 @@ class MetalTextureD : public GraphicsDataNode<ITextureD> {
m_pxPitch = 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
return;
}
@@ -450,9 +450,9 @@ class MetalTextureR : public GraphicsDataNode<ITextureR> {
void Setup(MetalContext* ctx) {
if (m_colorBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many color bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
if (m_depthBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
@autoreleasepool {
MTLTextureDescriptor* desc =
@@ -903,10 +903,10 @@ class MetalShaderStage : public GraphicsDataNode<IShaderStage> {
options:compOpts
error:&err];
if (!shaderLib)
printf("%s\n", data + 1);
fmt::print(fmt("{}\n"), data + 1);
}
if (!shaderLib)
Log.report(logvisor::Fatal, "error creating library: %s", [[err localizedDescription] UTF8String]);
Log.report(logvisor::Fatal, fmt("error creating library: %s"), [[err localizedDescription] UTF8String]);
NSString* funcName;
switch (stage) {
@@ -1024,7 +1024,7 @@ protected:
NSError* err = nullptr;
m_state = [ctx->m_dev newRenderPipelineStateWithDescriptor:desc error:&err];
if (err)
Log.report(logvisor::Fatal, "error making shader pipeline: %s",
Log.report(logvisor::Fatal, fmt("error making shader pipeline: %s"),
[[err localizedDescription] UTF8String]);
MTLDepthStencilDescriptor* dsDesc = [MTLDepthStencilDescriptor new];
@@ -1098,7 +1098,7 @@ class MetalTessellationShaderPipeline : public MetalShaderPipeline {
m_computeState = [ctx->m_dev newComputePipelineStateWithDescriptor:compDesc options:MTLPipelineOptionNone
reflection:nil error:&err];
if (err)
Log.report(logvisor::Fatal, "error making compute pipeline: %s",
Log.report(logvisor::Fatal, fmt("error making compute pipeline: %s"),
[[err localizedDescription] UTF8String]);
}
@@ -1202,7 +1202,7 @@ struct MetalShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (ubufOffs[i] % 256)
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding"),
int(i));
#endif
m_ubufOffs.push_back(ubufOffs[i]);
@@ -1212,7 +1212,7 @@ struct MetalShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (!ubufs[i])
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
Log.report(logvisor::Fatal, fmt("null uniform-buffer %d provided to newShaderDataBinding"), int(i));
#endif
m_ubufs.push_back(ubufs[i]);
}
@@ -2078,7 +2078,7 @@ void MetalDataFactoryImpl::SetupGammaResources() {
NSError* err = nullptr;
m_cubeFlipShader = [m_ctx->m_dev newRenderPipelineStateWithDescriptor:desc error:&err];
if (err)
Log.report(logvisor::Fatal, "error making shader pipeline: %s",
Log.report(logvisor::Fatal, fmt("error making shader pipeline: %s"),
[[err localizedDescription] UTF8String]);
}

View File

@@ -153,24 +153,24 @@ public:
}
};
static inline void ThrowIfFailed(VkResult res) {
static void ThrowIfFailed(VkResult res) {
if (res != VK_SUCCESS)
Log.report(logvisor::Fatal, "%d\n", res);
Log.report(logvisor::Fatal, fmt("{}\n"), res);
}
static VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkDebugReportFlagsEXT msgFlags, VkDebugReportObjectTypeEXT objType,
uint64_t srcObject, size_t location, int32_t msgCode,
const char* pLayerPrefix, const char* pMsg, void* pUserData) {
if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
Log.report(logvisor::Error, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Error, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
Log.report(logvisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Warning, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
Log.report(logvisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Warning, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
Log.report(logvisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Info, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
} else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
Log.report(logvisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
Log.report(logvisor::Info, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
}
/*
@@ -305,7 +305,7 @@ static void demo_check_layers(const std::vector<VulkanContext::LayerProperties>&
}
}
if (!found) {
Log.report(logvisor::Fatal, "Cannot find layer: %s", layerNames[i]);
Log.report(logvisor::Fatal, fmt("Cannot find layer: {}"), layerNames[i]);
}
}
}
@@ -314,7 +314,7 @@ bool VulkanContext::initVulkan(std::string_view appName, PFN_vkGetInstanceProcAd
vk::init_dispatch_table_top(getVkProc);
if (!glslang::InitializeProcess()) {
Log.report(logvisor::Error, "unable to initialize glslang");
Log.report(logvisor::Error, fmt("unable to initialize glslang"));
return false;
}
@@ -418,8 +418,8 @@ bool VulkanContext::initVulkan(std::string_view appName, PFN_vkGetInstanceProcAd
VkResult instRes = vk::CreateInstance(&instInfo, nullptr, &m_instance);
if (instRes != VK_SUCCESS) {
Log.report(logvisor::Error,
"The Vulkan runtime is installed, but there are no supported "
"hardware vendor interfaces present");
fmt("The Vulkan runtime is installed, but there are no supported "
"hardware vendor interfaces present"));
return false;
}
@@ -427,12 +427,12 @@ bool VulkanContext::initVulkan(std::string_view appName, PFN_vkGetInstanceProcAd
PFN_vkCreateDebugReportCallbackEXT createDebugReportCallback =
(PFN_vkCreateDebugReportCallbackEXT)vk::GetInstanceProcAddr(m_instance, "vkCreateDebugReportCallbackEXT");
if (!createDebugReportCallback)
Log.report(logvisor::Fatal, "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function.");
Log.report(logvisor::Fatal, fmt("GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function."));
m_destroyDebugReportCallback =
(PFN_vkDestroyDebugReportCallbackEXT)vk::GetInstanceProcAddr(m_instance, "vkDestroyDebugReportCallbackEXT");
if (!m_destroyDebugReportCallback)
Log.report(logvisor::Fatal, "GetInstanceProcAddr: Unable to find vkDestroyDebugReportCallbackEXT function.");
Log.report(logvisor::Fatal, fmt("GetInstanceProcAddr: Unable to find vkDestroyDebugReportCallbackEXT function."));
VkDebugReportCallbackCreateInfoEXT debugCreateInfo = {};
debugCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
@@ -477,7 +477,7 @@ bool VulkanContext::enumerateDevices() {
void VulkanContext::initDevice() {
if (m_graphicsQueueFamilyIndex == UINT32_MAX)
Log.report(logvisor::Fatal, "VulkanContext::m_graphicsQueueFamilyIndex hasn't been initialized");
Log.report(logvisor::Fatal, fmt("VulkanContext::m_graphicsQueueFamilyIndex hasn't been initialized"));
/* create the device and queues */
VkDeviceQueueCreateInfo queueInfo = {};
@@ -493,7 +493,7 @@ void VulkanContext::initDevice() {
if (m_features.samplerAnisotropy)
features.samplerAnisotropy = VK_TRUE;
if (!m_features.textureCompressionBC)
Log.report(logvisor::Fatal, "Vulkan device does not support DXT-format textures");
Log.report(logvisor::Fatal, fmt("Vulkan device does not support DXT-format textures"));
features.textureCompressionBC = VK_TRUE;
VkShaderStageFlagBits tessellationDescriptorBit = VkShaderStageFlagBits(0);
if (m_features.tessellationShader) {
@@ -501,7 +501,7 @@ void VulkanContext::initDevice() {
features.tessellationShader = VK_TRUE;
}
if (!m_features.dualSrcBlend)
Log.report(logvisor::Fatal, "Vulkan device does not support dual-source blending");
Log.report(logvisor::Fatal, fmt("Vulkan device does not support dual-source blending"));
features.dualSrcBlend = VK_TRUE;
uint32_t extCount = 0;
@@ -635,10 +635,10 @@ void VulkanContext::initDevice() {
ThrowIfFailed(vk::CreatePipelineLayout(m_dev, &pipelineLayout, nullptr, &m_pipelinelayout));
std::string gpuName = m_gpuProps.deviceName;
Log.report(logvisor::Info, "Initialized %s", gpuName.c_str());
Log.report(logvisor::Info, "Vulkan version %d.%d.%d", m_gpuProps.apiVersion >> 22,
Log.report(logvisor::Info, fmt("Initialized {}"), gpuName);
Log.report(logvisor::Info, fmt("Vulkan version {}.{}.{}"), m_gpuProps.apiVersion >> 22,
(m_gpuProps.apiVersion >> 12) & 0b1111111111, m_gpuProps.apiVersion & 0b111111111111);
Log.report(logvisor::Info, "Driver version %d.%d.%d", m_gpuProps.driverVersion >> 22,
Log.report(logvisor::Info, fmt("Driver version {}.{}.{}"), m_gpuProps.driverVersion >> 22,
(m_gpuProps.driverVersion >> 12) & 0b1111111111, m_gpuProps.driverVersion & 0b111111111111);
}
@@ -1368,7 +1368,7 @@ class VulkanTextureS : public GraphicsDataNode<ITextureS> {
m_pixelPitchDenom = 1;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_vkFmt = pfmt;
@@ -1527,7 +1527,7 @@ class VulkanTextureSA : public GraphicsDataNode<ITextureSA> {
m_pixelPitchNum = 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_vkFmt = pfmt;
@@ -1681,7 +1681,7 @@ class VulkanTextureD : public GraphicsDataNode<ITextureD> {
m_cpuSz = width * height * 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_vkFmt = pfmt;
m_stagingBuf.reset(new uint8_t[m_cpuSz]);
@@ -2660,7 +2660,7 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (ubufOffs[i] % 256)
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset {} provided to newShaderDataBinding"),
int(i));
#endif
std::array<VkDescriptorBufferInfo, 2> fillArr;
@@ -2672,7 +2672,7 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (!ubufs[i])
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
Log.report(logvisor::Fatal, fmt("null uniform-buffer {} provided to newShaderDataBinding"), int(i));
#endif
m_ubufs.push_back(ubufs[i]);
}
@@ -2773,7 +2773,7 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
void bind(VkCommandBuffer cmdBuf, int b, VkRenderPass rPass = 0) {
#ifndef NDEBUG
if (!m_committed)
Log.report(logvisor::Fatal, "attempted to use uncommitted VulkanShaderDataBinding");
Log.report(logvisor::Fatal, fmt("attempted to use uncommitted VulkanShaderDataBinding"));
#endif
/* Ensure resized texture bindings are re-bound */
@@ -3183,7 +3183,7 @@ struct VulkanCommandQueue : IGraphicsCommandQueue {
VulkanTextureR* csource = m_resolveDispSource.cast<VulkanTextureR>();
#ifndef NDEBUG
if (!csource->m_colorBindCount)
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
#endif
ThrowIfFailed(
@@ -3478,9 +3478,9 @@ VulkanTextureR::VulkanTextureR(const boo::ObjToken<BaseGraphicsData>& parent, Vu
, m_colorBindCount(colorBindCount)
, m_depthBindCount(depthBindCount) {
if (colorBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many color bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
if (depthBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
if (m_samplesColor == 0)
m_samplesColor = 1;
@@ -3711,7 +3711,7 @@ ObjToken<IShaderStage> VulkanDataFactory::Context::newShaderStage(const uint8_t*
if (stage == PipelineStage::Control || stage == PipelineStage::Evaluation) {
if (!factory.m_ctx->m_features.tessellationShader)
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
}
return {new VulkanShaderStage(m_data, factory.m_ctx, data, size, stage)};
@@ -3725,9 +3725,9 @@ ObjToken<IShaderPipeline> VulkanDataFactory::Context::newShaderPipeline(
if (control || evaluation) {
if (!factory.m_ctx->m_features.tessellationShader)
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
if (additionalInfo.patchSize > factory.m_ctx->m_gpuProps.limits.maxTessellationPatchSize)
Log.report(logvisor::Fatal, "Device supports %d patch vertices, %d requested",
Log.report(logvisor::Fatal, fmt("Device supports {} patch vertices, {} requested"),
int(factory.m_ctx->m_gpuProps.limits.maxTessellationPatchSize), int(additionalInfo.patchSize));
}
@@ -4089,14 +4089,14 @@ std::vector<uint8_t> VulkanDataFactory::CompileGLSL(const char* source, Pipeline
glslang::TShader shader(lang);
shader.setStrings(&source, 1);
if (!shader.parse(&glslang::DefaultTBuiltInResource, 110, false, messages)) {
printf("%s\n", source);
Log.report(logvisor::Fatal, "unable to compile shader\n%s", shader.getInfoLog());
fmt::print(fmt("{}\n"), source);
Log.report(logvisor::Fatal, fmt("unable to compile shader\n{}"), shader.getInfoLog());
}
glslang::TProgram prog;
prog.addShader(&shader);
if (!prog.link(messages)) {
Log.report(logvisor::Fatal, "unable to link shader program\n%s", prog.getInfoLog());
Log.report(logvisor::Fatal, fmt("unable to link shader program\n{}"), prog.getInfoLog());
}
std::vector<unsigned int> out;

View File

@@ -312,7 +312,7 @@ class NXTextureS : public GraphicsDataNode<ITextureS> {
m_pixelPitchDenom = 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_nxFmt = pfmt;
@@ -327,7 +327,7 @@ class NXTextureS : public GraphicsDataNode<ITextureS> {
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
m_gpuTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
if (!m_gpuTex) {
Log.report(logvisor::Fatal, "Failed to create texture");
Log.report(logvisor::Fatal, fmt("Failed to create texture"));
return;
}
@@ -414,7 +414,7 @@ class NXTextureSA : public GraphicsDataNode<ITextureSA> {
m_pixelPitchNum = 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_nxFmt = pfmt;
@@ -429,7 +429,7 @@ class NXTextureSA : public GraphicsDataNode<ITextureSA> {
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
m_gpuTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
if (!m_gpuTex) {
Log.report(logvisor::Fatal, "Failed to create texture");
Log.report(logvisor::Fatal, fmt("Failed to create texture"));
return;
}
@@ -552,7 +552,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
texTempl.bind = PIPE_BIND_RENDER_TARGET;
m_colorTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
if (!m_colorTex) {
Log.report(logvisor::Fatal, "Failed to create color target texture");
Log.report(logvisor::Fatal, fmt("Failed to create color target texture"));
return;
}
@@ -562,7 +562,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
texTempl.bind = PIPE_BIND_DEPTH_STENCIL;
m_depthTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
if (!m_depthTex) {
Log.report(logvisor::Fatal, "Failed to create depth target texture");
Log.report(logvisor::Fatal, fmt("Failed to create depth target texture"));
return;
}
@@ -573,7 +573,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
m_colorBindTex[i] = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
if (!m_colorBindTex[i]) {
Log.report(logvisor::Fatal, "Failed to create color bind texture");
Log.report(logvisor::Fatal, fmt("Failed to create color bind texture"));
return;
}
}
@@ -583,7 +583,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
m_depthBindTex[i] = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
if (!m_depthBindTex[i]) {
Log.report(logvisor::Fatal, "Failed to create depth bind texture");
Log.report(logvisor::Fatal, fmt("Failed to create depth bind texture"));
return;
}
}
@@ -598,7 +598,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
svTempl.texture = m_colorTex;
m_colorView = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_colorTex, &svTempl);
if (!m_colorView) {
Log.report(logvisor::Fatal, "Failed to create color sampler view");
Log.report(logvisor::Fatal, fmt("Failed to create color sampler view"));
return;
}
@@ -606,7 +606,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
svTempl.texture = m_depthTex;
m_depthView = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_depthTex, &svTempl);
if (!m_depthView) {
Log.report(logvisor::Fatal, "Failed to create depth sampler view");
Log.report(logvisor::Fatal, fmt("Failed to create depth sampler view"));
return;
}
@@ -615,7 +615,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
svTempl.texture = m_colorBindTex[i];
m_colorBindView[i] = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_colorBindTex[i], &svTempl);
if (!m_colorBindView[i]) {
Log.report(logvisor::Fatal, "Failed to create color bind sampler view");
Log.report(logvisor::Fatal, fmt("Failed to create color bind sampler view"));
return;
}
}
@@ -625,7 +625,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
svTempl.texture = m_depthBindTex[i];
m_depthBindView[i] = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_depthBindTex[i], &svTempl);
if (!m_depthBindView[i]) {
Log.report(logvisor::Fatal, "Failed to create depth bind sampler view");
Log.report(logvisor::Fatal, fmt("Failed to create depth bind sampler view"));
return;
}
}
@@ -635,14 +635,14 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
surfTempl.format = ColorFormat;
m_colorSurface = ctx->m_pctx->create_surface(ctx->m_pctx, m_colorTex, &surfTempl);
if (!m_colorSurface) {
Log.report(logvisor::Fatal, "Failed to create color surface");
Log.report(logvisor::Fatal, fmt("Failed to create color surface"));
return;
}
surfTempl.format = DepthFormat;
m_depthSurface = ctx->m_pctx->create_surface(ctx->m_pctx, m_depthTex, &surfTempl);
if (!m_depthSurface) {
Log.report(logvisor::Fatal, "Failed to create depth surface");
Log.report(logvisor::Fatal, fmt("Failed to create depth surface"));
return;
}
@@ -658,9 +658,9 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
TextureClampMode clampMode, size_t colorBindCount, size_t depthBindCount)
: GraphicsDataNode<ITextureR>(parent), m_ctx(ctx) {
if (colorBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many color bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
if (depthBindCount > MAX_BIND_TEXS)
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
if (m_samplesColor == 0)
m_samplesColor = 1;
@@ -788,7 +788,7 @@ class NXShaderStage : public GraphicsDataNode<IShaderStage> {
PipelineStage stage)
: GraphicsDataNode<IShaderStage>(parent), m_obj(ctx->m_compiler.compile(SHADER_TYPE_TABLE[int(stage)], (char*)data)) {
if (!m_obj)
Log.report(logvisor::Fatal, "Shader compile fail:\n%s\n", m_obj.info_log());
Log.report(logvisor::Fatal, fmt("Shader compile fail:\n%s\n"), m_obj.info_log());
}
public:
@@ -953,7 +953,7 @@ protected:
std::string infoLog;
m_shader = ctx->m_compiler.link(numStages, stages, &infoLog);
if (!m_shader)
Log.report(logvisor::Fatal, "Unable to link shader:\n%s\n", infoLog.c_str());
Log.report(logvisor::Fatal, fmt("Unable to link shader:\n%s\n"), infoLog.c_str());
}
public:
@@ -1076,7 +1076,7 @@ struct NXShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (!ubufs[i])
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
Log.report(logvisor::Fatal, fmt("null uniform-buffer %d provided to newShaderDataBinding"), int(i));
#endif
m_ubufs.push_back(ubufs[i]);
if (ubufOffs && ubufSizes)
@@ -1134,7 +1134,7 @@ struct NXShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
void bind(int b) {
#ifndef NDEBUG
if (!m_committed)
Log.report(logvisor::Fatal, "attempted to use uncommitted NXShaderDataBinding");
Log.report(logvisor::Fatal, fmt("attempted to use uncommitted NXShaderDataBinding"));
#endif
struct pipe_context* pctx = m_ctx->m_pctx;
@@ -1355,7 +1355,7 @@ struct NXCommandQueue : IGraphicsCommandQueue {
NXTextureR* csource = m_resolveDispSource.cast<NXTextureR>();
#ifndef NDEBUG
if (!csource->m_colorBindCount)
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
#endif
struct pipe_surface* backBuf = m_ctx->m_windowSurfaces[ST_ATTACHMENT_BACK_LEFT];
@@ -1531,7 +1531,7 @@ NXTextureD::NXTextureD(const boo::ObjToken<BaseGraphicsData>& parent, NXCommandQ
m_cpuSz = width * height * 2;
break;
default:
Log.report(logvisor::Fatal, "unsupported tex format");
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
}
m_nxFmt = pfmt;
m_stagingBuf.reset(new uint8_t[m_cpuSz]);
@@ -1547,7 +1547,7 @@ NXTextureD::NXTextureD(const boo::ObjToken<BaseGraphicsData>& parent, NXCommandQ
for (int i = 0; i < 2; ++i) {
m_gpuTex[i] = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
if (!m_gpuTex[i]) {
Log.report(logvisor::Fatal, "Failed to create texture");
Log.report(logvisor::Fatal, fmt("Failed to create texture"));
return;
}
}
@@ -1805,7 +1805,7 @@ bool NXContext::initialize() {
printf("Activated console\n\n");
m_screen = nouveau_switch_screen_create();
if (!m_screen) {
Log.report(logvisor::Fatal, "Failed to create nouveau screen");
Log.report(logvisor::Fatal, fmt("Failed to create nouveau screen"));
return false;
}
printf("nouveau_switch_screen_create done\n");
@@ -1813,7 +1813,7 @@ bool NXContext::initialize() {
m_pctx = m_screen->context_create(m_screen, nullptr, 0);
if (!m_pctx) {
Log.report(logvisor::Fatal, "Failed to create pipe context");
Log.report(logvisor::Fatal, fmt("Failed to create pipe context"));
m_screen->destroy(m_screen);
return false;
}
@@ -1822,7 +1822,7 @@ bool NXContext::initialize() {
st_config_options opts = {};
m_st = st_create_context(API_OPENGL_CORE, m_pctx, nullptr, nullptr, &opts, false);
if (!m_st) {
Log.report(logvisor::Fatal, "Failed to create st context");
Log.report(logvisor::Fatal, fmt("Failed to create st context"));
m_screen->destroy(m_screen);
return false;
}
@@ -1849,7 +1849,7 @@ bool NXContext::initialize() {
whandle.stride = gfxGetFramebufferPitch();
struct pipe_resource* tex = m_screen->resource_from_handle(m_screen, &texTempl, &whandle, 0);
if (!tex) {
Log.report(logvisor::Fatal, "Failed to create color target texture");
Log.report(logvisor::Fatal, fmt("Failed to create color target texture"));
return false;
}
@@ -1858,7 +1858,7 @@ bool NXContext::initialize() {
surfTempl.format = ColorFormat;
m_windowSurfaces[i] = m_pctx->create_surface(m_pctx, tex, &surfTempl);
if (!m_windowSurfaces[i]) {
Log.report(logvisor::Fatal, "Failed to create color surface");
Log.report(logvisor::Fatal, fmt("Failed to create color surface"));
return false;
}