Changes necessary to build Vulkan branch updated to current master branch

This commit is contained in:
ksuprynowicz 2022-01-09 14:51:11 +01:00 committed by Lubosz Sarnecki
parent 89b8fce39d
commit 7e585fc8c3
22 changed files with 68 additions and 45 deletions

View file

@ -6,6 +6,8 @@
#
macro(TARGET_VULKAN)
find_package(Vulkan REQUIRED)
find_package(Qt5 COMPONENTS X11Extras REQUIRED)
target_include_directories(${TARGET_NAME} PRIVATE ${VULKAN_INCLUDE_DIR})
target_link_libraries(${TARGET_NAME} ${VULKAN_LIBRARY})
endmacro()
target_link_libraries(${TARGET_NAME} ${Qt5X11Extras_LIBRARIES})
endmacro()

View file

@ -126,7 +126,7 @@ void HmdDisplayPlugin::customizeContext() {
VisionSqueezeParameters parameters;
_visionSqueezeParametersBuffer =
gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(VisionSqueezeParameters), (const gpu::Byte*) &parameters));
gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(VisionSqueezeParameters), (const gpu::Byte*) &parameters));
Parent::customizeContext();
_hudRenderer.build();

View file

@ -32,12 +32,12 @@ PolyLineEntityRenderer::PolyLineEntityRenderer(const EntityItemPointer& entity)
_texture = DependencyManager::get<TextureCache>()->getTexture(DEFAULT_POLYLINE_TEXTURE);
{ // Initialize our buffers
_polylineDataBuffer = std::make_shared<gpu::Buffer>();
_polylineDataBuffer = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer);
_polylineDataBuffer->resize(sizeof(PolylineData));
PolylineData data { glm::vec2(_faceCamera, _glow), glm::vec2(0.0f) };
_polylineDataBuffer->setSubData(0, data);
_polylineGeometryBuffer = std::make_shared<gpu::Buffer>();
_polylineGeometryBuffer = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer);
}
}

View file

@ -198,7 +198,9 @@ struct Cache {
template <typename T>
static std::string hex(T t) {
return (std::stringstream() << std::setw(sizeof(T)) << std::setfill('0') << std::hex << t).str();
std::stringstream sStream;
sStream << std::setw(sizeof(T)) << std::setfill('0') << std::hex << t;
return sStream.str();
}
void setPipeline(const gpu::PipelinePointer& pipeline) {

View file

@ -319,6 +319,7 @@ public:
Flags flags;
};
std::string getKey() const;
// The unique default values for all the fields
static const Data DEFAULT;

View file

@ -69,8 +69,8 @@ Material::Material() {
_propertyFallthroughs[i] = false;
}
// created from nothing: create the Buffer to store the properties
Schema schema;
_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
//Schema schema;
//_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
}
Material::Material(const Material& material) :
@ -93,9 +93,9 @@ Material::Material(const Material& material) :
_propertyFallthroughs(material._propertyFallthroughs)
{
// copied: create the Buffer to store the properties, avoid holding a ref to the old Buffer
Schema schema;
_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
_schemaBuffer.edit<Schema>() = material._schemaBuffer.get<Schema>();
//Schema schema;
//_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
//_schemaBuffer.edit<Schema>() = material._schemaBuffer.get<Schema>();
}
Material& Material::operator=(const Material& material) {
@ -121,9 +121,9 @@ Material& Material::operator=(const Material& material) {
_propertyFallthroughs = material._propertyFallthroughs;
// copied: create the Buffer to store the properties, avoid holding a ref to the old Buffer
Schema schema;
_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
_schemaBuffer.edit<Schema>() = material._schemaBuffer.get<Schema>();
//Schema schema;
//_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
//_schemaBuffer.edit<Schema>() = material._schemaBuffer.get<Schema>();
return (*this);
}
@ -285,7 +285,7 @@ const glm::vec3 Material::DEFAULT_OUTLINE = glm::vec3(0.0f);
MultiMaterial::MultiMaterial() {
Schema schema;
_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
_schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Schema), (const gpu::Byte*) &schema, sizeof(Schema)));
}
void MultiMaterial::calculateMaterialInfo() const {

View file

@ -107,7 +107,7 @@ void buildGraphicsMesh(const hfm::Mesh& hfmMesh, graphics::MeshPointer& graphics
const int totalVertsSize = clusterWeightsOffset + clusterWeightsSize;
// Copy all vertex data in a single buffer
auto vertBuffer = std::make_shared<gpu::Buffer>();
auto vertBuffer = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer);
vertBuffer->resize(totalVertsSize);
// First positions
@ -300,7 +300,7 @@ void buildGraphicsMesh(const hfm::Mesh& hfmMesh, graphics::MeshPointer& graphics
vDest += vStride;
}
auto attribBuffer = std::make_shared<gpu::Buffer>();
auto attribBuffer = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer);
attribBuffer->setData(totalAttribBufferSize, dest.data());
vertexBufferStream->addBuffer(attribBuffer, 0, vStride);
}
@ -319,7 +319,7 @@ void buildGraphicsMesh(const hfm::Mesh& hfmMesh, graphics::MeshPointer& graphics
return;
}
auto indexBuffer = std::make_shared<gpu::Buffer>();
auto indexBuffer = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer);
indexBuffer->resize(totalIndices * sizeof(int));
int indexNum = 0;
@ -357,7 +357,7 @@ void buildGraphicsMesh(const hfm::Mesh& hfmMesh, graphics::MeshPointer& graphics
graphicsMesh->setIndexBuffer(indexBufferView);
if (parts.size()) {
auto pb = std::make_shared<gpu::Buffer>();
auto pb = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer);
pb->setData(parts.size() * sizeof(graphics::Mesh::Part), (const gpu::Byte*) parts.data());
gpu::BufferView pbv(pb, gpu::Element(gpu::VEC4, gpu::UINT32, gpu::XYZW));
graphicsMesh->setPartBuffer(pbv);

View file

@ -20,7 +20,7 @@ gpu::TexturePointer LightingModel::_ambientFresnelLUT;
LightingModel::LightingModel() {
Parameters parameters;
_parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Parameters), (const gpu::Byte*) &parameters, sizeof(Parameters)));
_parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Parameters), (const gpu::Byte*) &parameters, sizeof(Parameters)));
#if RENDER_UTILS_ENABLE_AMBIENT_FRESNEL_LUT
if (!_ambientFresnelLUT) {
@ -327,4 +327,4 @@ void MakeLightingModel::run(const render::RenderContextPointer& renderContext, L
renderContext->args->_enableTexturing = _lightingModel->isMaterialTexturingEnabled();
renderContext->args->_enableBlendshape = _lightingModel->isBlendshapeEnabled();
renderContext->args->_enableSkinning = _lightingModel->isSkinningEnabled();
}
}

View file

@ -371,7 +371,7 @@ void batchSetter(const ShapePipeline& pipeline, gpu::Batch& batch, RenderArgs* a
schema._key = (uint32_t)schemaKey._flags.to_ulong();
auto schemaSize = sizeof(graphics::MultiMaterial::Schema);
schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(schemaSize, (const gpu::Byte*) &schema, schemaSize));
schemaBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, schemaSize, (const gpu::Byte*) &schema, schemaSize));
});
batch.setUniformBuffer(gr::Buffer::Material, schemaBuffer);
@ -1259,7 +1259,7 @@ bool RenderPipelines::bindMaterials(graphics::MultiMaterial& multiMaterial, gpu:
static std::once_flag once;
std::call_once(once, [textureCache] {
graphics::MultiMaterial::Schema schema;
defaultMaterialSchema = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(schema), (const gpu::Byte*) &schema, sizeof(schema)));
defaultMaterialSchema = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(schema), (const gpu::Byte*) &schema, sizeof(schema)));
defaultMaterialTextures->setTexture(gr::Texture::MaterialAlbedo, textureCache->getWhiteTexture());
defaultMaterialTextures->setTexture(gr::Texture::MaterialMetallic, textureCache->getBlackTexture());

View file

@ -27,7 +27,7 @@ gpu::PipelinePointer ToneMapAndResample::_mirrorPipeline;
ToneMapAndResample::ToneMapAndResample() {
Parameters parameters;
_parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(sizeof(Parameters), (const gpu::Byte*) &parameters));
_parametersBuffer = gpu::BufferView(std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(Parameters), (const gpu::Byte*) &parameters));
}
void ToneMapAndResample::init() {

View file

@ -134,7 +134,6 @@ Font::Pointer Font::load(const QString& family) {
void Font::handleFontNetworkReply() {
auto requestReply = qobject_cast<QNetworkReply*>(sender());
Q_ASSERT(requestReply != nullptr);
if (requestReply->error() == QNetworkReply::NoError) {
setLoaded(true);
@ -479,7 +478,7 @@ void Font::drawString(gpu::Batch& batch, Font::DrawInfo& drawInfo, const QString
gpuDrawParams.effectThickness = drawInfo.params.effectThickness;
gpuDrawParams.effect = drawInfo.params.effect;
if (!drawInfo.paramsBuffer) {
drawInfo.paramsBuffer = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(GpuDrawParams), nullptr);
drawInfo.paramsBuffer = std::make_shared<gpu::Buffer>(gpu::Buffer::UniformBuffer, sizeof(DrawParams), nullptr);
}
drawInfo.paramsBuffer->setSubData(0, sizeof(DrawParams), (const gpu::Byte*)&gpuDrawParams);
}

View file

@ -146,6 +146,9 @@ struct Source {
// The name of the shader file, with extension, i.e. DrawColor.frag
std::string name;
// Generic reflection, copied from the 450 dialect / mono variant
Reflection reflection;
// Map of platforms to their specific shaders
std::unordered_map<Dialect, DialectSource, EnumClassHash> dialectSources;

View file

@ -46,7 +46,7 @@ namespace vks {
vk::DeviceSize allocSize{ 0 };
#if VULKAN_USE_VMA
static VmaAllocator& Allocation::getAllocator();
static VmaAllocator& getAllocator();
VmaAllocation allocation;
/** @brief Memory propertys flags to be filled by external source at buffer creation (to query at some later point) */

View file

@ -26,7 +26,8 @@
#define VK_USE_PLATFORM_ANDROID_KHR
#elif defined(Q_OS_DARWIN)
#else
#define VK_USE_PLATFORM_XLIB_KHR
//#define VK_USE_PLATFORM_XLIB_KHR
#define VK_USE_PLATFORM_XCB_KHR
#endif
#define VKCPP_ENHANCED_MODE

View file

@ -1,5 +1,7 @@
#include "Context.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include "Context.h"
vks::Context& vks::Context::get() {
static Context INSTANCE;

View file

@ -1,7 +1,5 @@
#pragma once
#include <QtCore/qmetatype.h>
#include <QtCore/qtextstream.h>
#include "Config.h"
#include "Debug.h"
@ -10,7 +8,6 @@
#include "Helpers.h"
#include "Device.h"
#include <unordered_set>
#include <QtCore/QDebug>
namespace vks {
using StringList = std::list<std::string>;
@ -45,8 +42,8 @@ struct DeviceCreateInfo : public vk::DeviceCreateInfo {
void update() {
assert(deviceQueuesPriorities.size() == deviceQueues.size());
auto size = deviceQueues.size();
for (auto i = 0; i < size; ++i) {
size_t size = deviceQueues.size();
for (size_t i = 0; i < size; ++i) {
auto& deviceQueue = deviceQueues[i];
auto& deviceQueuePriorities = deviceQueuesPriorities[i];
deviceQueue.queueCount = (uint32_t)deviceQueuePriorities.size();

View file

@ -6,6 +6,8 @@
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include "Debug.h"
#include <functional>
@ -15,7 +17,6 @@
#include <sstream>
#include <mutex>
#include <QtCore/QDebug>
namespace vks { namespace debug {

View file

@ -1,7 +1,5 @@
#pragma once
#include <QtCore/qmetatype.h>
#include <QtCore/qtextstream.h>
#include "Config.h"
namespace vks { namespace debug {

View file

@ -1,10 +1,11 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QString>
#include <QtCore/QFileInfo>
#include "Helpers.h"
#include <mutex>
#include <QtCore/QString>
#include <QtCore/QFileInfo>
#include <gl/Config.h>
#include <shared/FileUtils.h>

View file

@ -1,6 +1,5 @@
#pragma once
#include <QtCore/qmetatype.h>
#include "Config.h"
#include <array>
#include <vector>

View file

@ -6,10 +6,16 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "VKWindow.h"
#include <QtCore/QCoreApplication>
#include <QGuiApplication>
#include <QtGui/QWindow>
#include <QtGui/qevent.h>
#include <QtCore/QTimer>
#include <QtCore/QDebug>
#include <QtPlatformHeaders/QXcbWindowFunctions>
#include <QtX11Extras/QX11Info>
#include "VKWindow.h"
#include "Config.h"
#include "Swapchain.h"
#include "Context.h"
@ -23,7 +29,15 @@ VKWindow::VKWindow(QScreen* screen) : QWindow(screen) {
}
const vk::SurfaceKHR& VKWindow::createSurface() {
#ifdef WIN32
_surface = _context.instance.createWin32SurfaceKHR({ {}, GetModuleHandle(NULL), (HWND)winId() });
#else
vk::XcbSurfaceCreateInfoKHR surfaceCreateInfo;
//dynamic_cast<QGuiApplication*>(QGuiApplication::instance())->platformNativeInterface()->connection();
surfaceCreateInfo.connection = QX11Info::connection();
surfaceCreateInfo.window = QX11Info::appRootWindow();
_surface = _context.instance.createXcbSurfaceKHR(surfaceCreateInfo);
#endif
_swapchain.setSurface(_surface);
return _surface;
}
@ -35,7 +49,7 @@ void VKWindow::createSwapchain() {
{
auto qsize = size();
_extent = { (uint32_t)qsize.width(), (uint32_t)qsize.height() };
_extent = vk::Extent2D((uint32_t)qsize.width(), (uint32_t)qsize.height());
}
_swapchain.create(_extent, true);
@ -168,14 +182,14 @@ void VKWindow::setupRenderPass() {
void VKWindow::resizeEvent(QResizeEvent* event) {
QWindow::resizeEvent(event);
auto qsize = event->size();
if (qsize.width() != _extent.width || qsize.height() != _extent.height) {
if (qsize.width() != (int)(_extent.width) || qsize.height() != (int)(_extent.height)) {
_resizeTimer->start();
}
}
void VKWindow::resizeFramebuffer() {
auto qsize = size();
_extent = { (uint32_t)qsize.width(), (uint32_t)qsize.height() };
_extent = vk::Extent2D((uint32_t)qsize.width(), (uint32_t)qsize.height());
_swapchain.waitIdle();
_swapchain.create(_extent, true);
setupDepthStencil();

View file

@ -8,8 +8,11 @@
#pragma once
#include <QtCore/qtextstream.h>
#include <QtCore/QCoreApplication>
#include <QtGui/QWindow>
#include <QtGui/qevent.h>
#include <QtCore/QTimer>
#include <QtCore/QDebug>
#include "Config.h"
#include "Context.h"