Merge branch 'master' of ssh://git.axiodl.com:6431/AxioDL/boo

This commit is contained in:
Jack Andersen
2019-08-31 10:34:11 -10:00
101 changed files with 2799 additions and 2369 deletions

View File

@@ -3,17 +3,18 @@
/* Private header for managing shader data
* binding lifetimes through rendering cycle */
#include <array>
#include <atomic>
#include <vector>
#include <mutex>
#include <cassert>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <mutex>
#include <queue>
#include <thread>
#include <vector>
#include "boo/graphicsdev/IGraphicsDataFactory.hpp"
#include "boo/graphicsdev/IGraphicsCommandQueue.hpp"
#include "../Common.hpp"
#include "lib/Common.hpp"
namespace boo {
@@ -63,9 +64,6 @@ struct BaseGraphicsData : ListNode<BaseGraphicsData, GraphicsDataFactoryHead*> {
auto* head = getHead<T>();
return head ? head->countForward() : 0;
}
std::unique_lock<std::recursive_mutex> destructorLock() override {
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
}
explicit BaseGraphicsData(GraphicsDataFactoryHead& head __BooTraceArgs)
: ListNode<BaseGraphicsData, GraphicsDataFactoryHead*>(&head) __BooTraceInitializer {}
@@ -131,9 +129,6 @@ struct BaseGraphicsPool : ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*> {
auto* head = getHead<T>();
return head ? head->countForward() : 0;
}
std::unique_lock<std::recursive_mutex> destructorLock() override {
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
}
explicit BaseGraphicsPool(GraphicsDataFactoryHead& head __BooTraceArgs)
: ListNode<BaseGraphicsPool, GraphicsDataFactoryHead*>(&head) __BooTraceInitializer {}
@@ -158,10 +153,6 @@ struct GraphicsDataNode : ListNode<GraphicsDataNode<NodeCls, DataCls>, ObjToken<
return std::unique_lock<std::recursive_mutex>{head->m_head->m_dataMutex};
}
std::unique_lock<std::recursive_mutex> destructorLock() override {
return std::unique_lock<std::recursive_mutex>{base::m_head->m_head->m_dataMutex};
}
explicit GraphicsDataNode(const ObjToken<DataCls>& data)
: ListNode<GraphicsDataNode<NodeCls, DataCls>, ObjToken<DataCls>, NodeCls>(data) {}
@@ -249,7 +240,7 @@ public:
m_backcv.wait(lk, [this]() { return m_outstandingTasks == 0 || !m_running; });
}
bool isReady() {
bool isReady() const {
return m_outstandingTasks == 0 || !m_running;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
#include "boo/graphicsdev/glxew.h"
#include "logvisor/logvisor.hpp"
#include <logvisor/logvisor.hpp>
namespace boo {
static logvisor::Module Log("boo::GLX");

View File

@@ -1,16 +1,17 @@
#include "../mac/CocoaCommon.hpp"
#include "lib/mac/CocoaCommon.hpp"
#if BOO_HAS_METAL
#include "logvisor/logvisor.hpp"
#include "boo/IApplication.hpp"
#include "boo/graphicsdev/Metal.hpp"
#include "boo/IGraphicsContext.hpp"
#include "Common.hpp"
#include <vector>
#include "boo/graphicsdev/Metal.hpp"
#include "lib/graphicsdev/Common.hpp"
#include <unordered_map>
#include <unordered_set>
#include "xxhash/xxhash.h"
#include <vector>
#include <logvisor/logvisor.hpp>
#if !__has_feature(objc_arc)
#error ARC Required
@@ -848,11 +849,13 @@ class MetalShaderStage : public GraphicsDataNode<IShaderStage> {
shaderLib = [ctx->m_dev newLibraryWithSource:@((const char*) (data + 1))
options:compOpts
error:&err];
if (!shaderLib)
if (!shaderLib) {
fmt::print(fmt("{}\n"), data + 1);
}
}
if (!shaderLib) {
Log.report(logvisor::Fatal, fmt("error creating library: {}"), [[err localizedDescription] UTF8String]);
}
if (!shaderLib)
Log.report(logvisor::Fatal, fmt("error creating library: %s"), [[err localizedDescription] UTF8String]);
NSString* funcName;
switch (stage) {
@@ -969,9 +972,10 @@ protected:
desc.inputPrimitiveTopology = MTLPrimitiveTopologyClassTriangle;
NSError* err = nullptr;
m_state = [ctx->m_dev newRenderPipelineStateWithDescriptor:desc error:&err];
if (err)
Log.report(logvisor::Fatal, fmt("error making shader pipeline: %s"),
if (err) {
Log.report(logvisor::Fatal, fmt("error making shader pipeline: {}"),
[[err localizedDescription] UTF8String]);
}
MTLDepthStencilDescriptor* dsDesc = [MTLDepthStencilDescriptor new];
switch (info.depthTest) {
@@ -1043,9 +1047,10 @@ class MetalTessellationShaderPipeline : public MetalShaderPipeline {
NSError* err = nullptr;
m_computeState = [ctx->m_dev newComputePipelineStateWithDescriptor:compDesc options:MTLPipelineOptionNone
reflection:nil error:&err];
if (err)
Log.report(logvisor::Fatal, fmt("error making compute pipeline: %s"),
if (err) {
Log.report(logvisor::Fatal, fmt("error making compute pipeline: {}"),
[[err localizedDescription] UTF8String]);
}
}
void draw(MetalCommandQueue& q, size_t start, size_t count);
@@ -1147,9 +1152,10 @@ struct MetalShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
m_ubufOffs.reserve(ubufCount);
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (ubufOffs[i] % 256)
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding"),
int(i));
if (ubufOffs[i] % 256) {
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset {} provided to newShaderDataBinding"),
i);
}
#endif
m_ubufOffs.push_back(ubufOffs[i]);
}
@@ -1157,8 +1163,9 @@ struct MetalShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
m_ubufs.reserve(ubufCount);
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (!ubufs[i])
Log.report(logvisor::Fatal, fmt("null uniform-buffer %d provided to newShaderDataBinding"), int(i));
if (!ubufs[i]) {
Log.report(logvisor::Fatal, fmt("null uniform-buffer {} provided to newShaderDataBinding"), i);
}
#endif
m_ubufs.push_back(ubufs[i]);
}
@@ -2005,7 +2012,6 @@ void MetalDataFactoryImpl::SetupGammaResources() {
ObjToken<ITexture> texs[] = {{}, m_gammaLUT.get()};
m_gammaBinding = ctx.newShaderDataBinding(m_gammaShader, m_gammaVBO.get(), {}, {},
0, nullptr, nullptr, 2, texs, nullptr, nullptr);
return true;
} BooTrace);
}

View File

@@ -1,15 +1,18 @@
#include "boo/graphicsdev/Vulkan.hpp"
#include "boo/IGraphicsContext.hpp"
#include <vector>
#include <array>
#include <cmath>
#include <vector>
#include <glslang/Public/ShaderLang.h>
#include <StandAlone/ResourceLimits.h>
#include <SPIRV/GlslangToSpv.h>
#include <SPIRV/disassemble.h>
#include "boo/IGraphicsContext.hpp"
#include "boo/graphicsdev/GLSLMacros.hpp"
#include "Common.hpp"
#include "xxhash/xxhash.h"
#include "boo/graphicsdev/IGraphicsCommandQueue.hpp"
#include "lib/graphicsdev/Common.hpp"
#define AMD_PAL_HACK 1
@@ -17,7 +20,7 @@
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#include "vk_mem_alloc.h"
#include "logvisor/logvisor.hpp"
#include <logvisor/logvisor.hpp>
#define BOO_VK_MAX_DESCRIPTOR_SETS 65536
@@ -188,7 +191,7 @@ static void SetImageLayout(VkCommandBuffer cmd, VkImage image, VkImageAspectFlag
uint32_t layerCount, uint32_t baseMipLevel = 0) {
VkImageMemoryBarrier imageMemoryBarrier = {};
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
imageMemoryBarrier.pNext = NULL;
imageMemoryBarrier.pNext = nullptr;
imageMemoryBarrier.srcAccessMask = 0;
imageMemoryBarrier.dstAccessMask = 0;
imageMemoryBarrier.oldLayout = old_image_layout;
@@ -261,7 +264,7 @@ static void SetImageLayout(VkCommandBuffer cmd, VkImage image, VkImageAspectFlag
break;
}
vk::CmdPipelineBarrier(cmd, src_stages, dest_stages, 0, 0, NULL, 0, NULL, 1, &imageMemoryBarrier);
vk::CmdPipelineBarrier(cmd, src_stages, dest_stages, 0, 0, nullptr, 0, nullptr, 1, &imageMemoryBarrier);
}
static VkResult InitGlobalExtensionProperties(VulkanContext::LayerProperties& layerProps) {
@@ -1060,9 +1063,6 @@ struct VulkanDescriptorPool : ListNode<VulkanDescriptorPool, VulkanDataFactoryIm
~VulkanDescriptorPool() { vk::DestroyDescriptorPool(m_head->m_ctx->m_dev, m_descPool, nullptr); }
std::unique_lock<std::recursive_mutex> destructorLock() override {
return std::unique_lock<std::recursive_mutex>{m_head->m_dataMutex};
}
static std::unique_lock<std::recursive_mutex> _getHeadLock(VulkanDataFactoryImpl* factory) {
return std::unique_lock<std::recursive_mutex>{factory->m_dataMutex};
}
@@ -2668,9 +2668,10 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
m_ubufOffs.reserve(ubufCount);
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (ubufOffs[i] % 256)
if (ubufOffs[i] % 256) {
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset {} provided to newShaderDataBinding"),
int(i));
i);
}
#endif
std::array<VkDescriptorBufferInfo, 2> fillArr;
fillArr.fill({VK_NULL_HANDLE, ubufOffs[i], (ubufSizes[i] + 255) & ~255});
@@ -2680,8 +2681,9 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
m_ubufs.reserve(ubufCount);
for (size_t i = 0; i < ubufCount; ++i) {
#ifndef NDEBUG
if (!ubufs[i])
Log.report(logvisor::Fatal, fmt("null uniform-buffer {} provided to newShaderDataBinding"), int(i));
if (!ubufs[i]) {
Log.report(logvisor::Fatal, fmt("null uniform-buffer {} provided to newShaderDataBinding"), i);
}
#endif
m_ubufs.push_back(ubufs[i]);
}

View File

@@ -1,9 +1,13 @@
#include "logvisor/logvisor.hpp"
#include "boo/graphicsdev/NX.hpp"
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
#include "boo/IGraphicsContext.hpp"
#include "boo/graphicsdev/GLSLMacros.hpp"
#include "../Common.hpp"
#include "xxhash/xxhash.h"
#include "lib/graphicsdev/Common.hpp"
#include "main/shaderobj.h"
#include "st_program.h"
@@ -19,6 +23,9 @@ extern "C" {
#include "gallium/winsys/nouveau/switch/nouveau_switch_public.h"
}
#include <logvisor/logvisor.hpp>
#include <xxhash/xxhash.h>
#include <switch.h>
namespace boo {
@@ -1801,7 +1808,7 @@ bool NXContext::initialize() {
gfxInitDefault();
gfxSetMode(GfxMode_TiledDouble);
consoleInit(NULL);
consoleInit(nullptr);
printf("Activated console\n\n");
m_screen = nouveau_switch_screen_create();
if (!m_screen) {