new compute dispatch
This commit is contained in:
Vendored
+1
-1
Submodule external/vcpkg updated: 365f6444ab...cb2981c4e0
@@ -3,6 +3,7 @@
|
||||
#include "Graphics/Texture.h"
|
||||
#include "Window/WindowManager.h"
|
||||
#include "ktx.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace Seele;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ class ComputeCommand {
|
||||
virtual void bindDescriptor(const Array<Gfx::PDescriptorSet>& sets) = 0;
|
||||
virtual void pushConstants(Gfx::SeShaderStageFlags stage, uint32 offset, uint32 size, const void* data) = 0;
|
||||
virtual void dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) = 0;
|
||||
virtual void dispatch(UVector threadGroupSize) = 0;
|
||||
virtual void dispatchIndirect(Gfx::PShaderBuffer buffer, uint32 offset) = 0;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
@@ -491,10 +491,16 @@ void ComputeCommand::pushConstants(Gfx::SeShaderStageFlags stage, uint32 offset,
|
||||
vkCmdPushConstants(handle, pipeline->getLayout(), stage, offset, size, data);
|
||||
}
|
||||
|
||||
void ComputeCommand::dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) {
|
||||
void ComputeCommand::dispatch(uint32 threadGroupCountX, uint32 threadGroupCountY, uint32 threadGroupCountZ) {
|
||||
assert(threadId == std::this_thread::get_id());
|
||||
vkCmdDispatch(handle, threadX, threadY, threadZ);
|
||||
vkCmdDispatch(handle, threadGroupCountX, threadGroupCountY, threadGroupCountZ);
|
||||
}
|
||||
|
||||
void ComputeCommand::dispatch(UVector threadGroupSize) {
|
||||
assert(threadId == std::this_thread::get_id());
|
||||
vkCmdDispatch(handle, threadGroupSize.x, threadGroupSize.y, threadGroupSize.z);
|
||||
}
|
||||
|
||||
void ComputeCommand::dispatchIndirect(Gfx::PShaderBuffer buffer, uint32 offset) {
|
||||
assert(threadId == std::this_thread::get_id());
|
||||
vkCmdDispatchIndirect(handle, buffer.cast<ShaderBuffer>()->getHandle(), offset);
|
||||
|
||||
@@ -116,6 +116,7 @@ class ComputeCommand : public Gfx::ComputeCommand {
|
||||
virtual void bindDescriptor(const Array<Gfx::PDescriptorSet>& sets) override;
|
||||
virtual void pushConstants(Gfx::SeShaderStageFlags stage, uint32 offset, uint32 size, const void* data) override;
|
||||
virtual void dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) override;
|
||||
virtual void dispatch(UVector threadGroupSize) override;
|
||||
virtual void dispatchIndirect(Gfx::PShaderBuffer buffer, uint32 offset) override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -1,11 +1,26 @@
|
||||
#include "Debug.h"
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
const char* severityToString(VkDebugUtilsMessageSeverityFlagBitsEXT severity) {
|
||||
if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
|
||||
return "ERROR";
|
||||
}
|
||||
if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) {
|
||||
return "WARNING";
|
||||
}
|
||||
if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT) {
|
||||
return "INFO";
|
||||
}
|
||||
return "VERBOSE";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
using namespace Seele::Vulkan;
|
||||
|
||||
VkBool32 Seele::Vulkan::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT, VkDebugUtilsMessageTypeFlagsEXT,
|
||||
VkBool32 Seele::Vulkan::debugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT,
|
||||
const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, void*) {
|
||||
std::cerr << pCallbackData->pMessage << std::endl;
|
||||
std::cerr << "[Vulkan " << severityToString(messageSeverity) << "] " << pCallbackData->pMessage << std::endl;
|
||||
return VK_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
if (res == VK_ERROR_DEVICE_LOST) { \
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3)); \
|
||||
} \
|
||||
std::cout << "Fatal : VkResult is " << res << " in " << __FILE__ << " at line " << __LINE__ << std::endl; \
|
||||
std::cerr << "Fatal: VkResult is " << res << " in " << __FILE__ << " at line " << __LINE__ << std::endl; \
|
||||
std::cerr.flush(); \
|
||||
abort(); \
|
||||
} \
|
||||
}
|
||||
|
||||
@@ -697,7 +697,25 @@ void Graphics::initInstance(GraphicsInitializer initInfo) {
|
||||
extensions.add("VK_KHR_portability_enumeration");
|
||||
#endif
|
||||
Array<const char*> layers = initInfo.layers;
|
||||
// layers.add("VK_LAYER_KHRONOS_validation");
|
||||
#ifdef ENABLE_VALIDATION
|
||||
bool hasValidationLayer = false;
|
||||
uint32 layerCount = 0;
|
||||
vkEnumerateInstanceLayerProperties(&layerCount, nullptr);
|
||||
Array<VkLayerProperties> availableLayers(layerCount);
|
||||
vkEnumerateInstanceLayerProperties(&layerCount, availableLayers.data());
|
||||
for (const auto& layer : availableLayers) {
|
||||
if (std::strcmp(layer.layerName, "VK_LAYER_KHRONOS_validation") == 0) {
|
||||
hasValidationLayer = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasValidationLayer) {
|
||||
layers.add("VK_LAYER_KHRONOS_validation");
|
||||
std::cerr << "Enabled Vulkan validation layer: VK_LAYER_KHRONOS_validation" << std::endl;
|
||||
} else {
|
||||
std::cerr << "ENABLE_VALIDATION is set, but VK_LAYER_KHRONOS_validation is unavailable on this system." << std::endl;
|
||||
}
|
||||
#endif
|
||||
VkInstanceCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
@@ -718,7 +736,8 @@ void Graphics::setupDebugCallback() {
|
||||
.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT,
|
||||
.pNext = nullptr,
|
||||
.flags = 0,
|
||||
.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT,
|
||||
.messageSeverity = VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT,
|
||||
.messageType = VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT | VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT |
|
||||
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT,
|
||||
.pfnUserCallback = &debugCallback,
|
||||
@@ -766,6 +785,7 @@ void Graphics::pickPhysicalDevice() {
|
||||
};
|
||||
features.get<VkPhysicalDeviceVulkan11Features>().multiview = true;
|
||||
features.get<VkPhysicalDeviceVulkan11Features>().storageBuffer16BitAccess = true;
|
||||
features.get<VkPhysicalDeviceVulkan11Features>().shaderDrawParameters = true;
|
||||
|
||||
features.get<VkPhysicalDeviceVulkan12Features>().descriptorIndexing = true;
|
||||
features.get<VkPhysicalDeviceVulkan12Features>().descriptorBindingPartiallyBound = true;
|
||||
|
||||
@@ -144,7 +144,6 @@ void Window::endFrame() {
|
||||
}
|
||||
|
||||
bool Window::shouldClose() const {
|
||||
std::cout << "Checking if window should close: " << glfwWindowShouldClose((GLFWwindow*)windowHandle) << std::endl;
|
||||
return glfwWindowShouldClose((GLFWwindow*)windowHandle);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,30 +34,6 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
||||
slang::SessionDesc sessionDesc;
|
||||
sessionDesc.flags = 0;
|
||||
Array<slang::CompilerOptionEntry> option = {
|
||||
{
|
||||
.name = slang::CompilerOptionName::LineDirectiveMode,
|
||||
.value =
|
||||
{
|
||||
.kind = slang::CompilerOptionValueKind::Int,
|
||||
.intValue0 = SLANG_LINE_DIRECTIVE_MODE_NONE,
|
||||
},
|
||||
},
|
||||
{
|
||||
.name = slang::CompilerOptionName::DebugInformation,
|
||||
.value =
|
||||
{
|
||||
.kind = slang::CompilerOptionValueKind::Int,
|
||||
.intValue0 = SLANG_DEBUG_INFO_LEVEL_STANDARD,
|
||||
},
|
||||
},
|
||||
{
|
||||
.name = slang::CompilerOptionName::DebugInformationFormat,
|
||||
.value =
|
||||
{
|
||||
.kind = slang::CompilerOptionValueKind::Int,
|
||||
.intValue0 = SLANG_DEBUG_INFO_FORMAT_PDB,
|
||||
},
|
||||
},
|
||||
{
|
||||
.name = slang::CompilerOptionName::DumpIntermediates,
|
||||
.value =
|
||||
@@ -68,8 +44,8 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
|
||||
},
|
||||
};
|
||||
|
||||
sessionDesc.compilerOptionEntries = 0;//option.data();
|
||||
sessionDesc.compilerOptionEntryCount = 0;//(uint32)option.size();
|
||||
sessionDesc.compilerOptionEntries = option.data();
|
||||
sessionDesc.compilerOptionEntryCount = (uint32)option.size();
|
||||
sessionDesc.defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR;
|
||||
Array<slang::PreprocessorMacroDesc> macros;
|
||||
for (const auto& [key, val] : info.defines) {
|
||||
|
||||
Reference in New Issue
Block a user