Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • vulkan2021/vkcv-framework
1 result
Show changes
Showing
with 164 additions and 78 deletions
......@@ -50,11 +50,11 @@ namespace vkcv::camera {
}
// handle yaw rotation
float yaw = camera.getYaw() + static_cast<float>(xOffset) * m_cameraSpeed;
float yaw = camera.getYaw() + static_cast<float>(xOffset) * 90.0f * m_cameraSpeed;
camera.setYaw(yaw);
// handle pitch rotation
float pitch = camera.getPitch() - static_cast<float>(yOffset) * m_cameraSpeed;
float pitch = camera.getPitch() - static_cast<float>(yOffset) * 90.0f * m_cameraSpeed;
pitch = glm::clamp(pitch, -89.0f, 89.0f);
camera.setPitch(pitch);
}
......@@ -82,22 +82,22 @@ namespace vkcv::camera {
void PilotCameraController::keyCallback(int key, int scancode, int action, int mods, Camera &camera) {
switch (key) {
case GLFW_KEY_W:
moveForward(action);
m_forward = static_cast<bool>(action);
break;
case GLFW_KEY_S:
moveBackward(action);
m_backward = static_cast<bool>(action);
break;
case GLFW_KEY_A:
moveLeft(action);
m_left = static_cast<bool>(action);
break;
case GLFW_KEY_D:
moveRight(action);
m_right = static_cast<bool>(action);
break;
case GLFW_KEY_E:
moveUpward(action);
m_upward = static_cast<bool>(action);
break;
case GLFW_KEY_Q:
moveDownward(action);
m_downward = static_cast<bool>(action);
break;
default:
break;
......@@ -109,31 +109,25 @@ namespace vkcv::camera {
}
void PilotCameraController::mouseMoveCallback(double xoffset, double yoffset, Camera &camera) {
if(!m_rotationActive){
return;
}
float sensitivity = 0.05f;
xoffset *= sensitivity;
yoffset *= sensitivity;
xoffset *= static_cast<float>(m_rotationActive);
yoffset *= static_cast<float>(m_rotationActive);
panView(xoffset , yoffset, camera);
}
void PilotCameraController::mouseButtonCallback(int button, int action, int mods, Camera &camera) {
if(button == GLFW_MOUSE_BUTTON_2 && m_rotationActive == false && action == GLFW_PRESS){
m_rotationActive = true;
}
else if(button == GLFW_MOUSE_BUTTON_2 && m_rotationActive == true && action == GLFW_RELEASE){
m_rotationActive = false;
}
if (button == GLFW_MOUSE_BUTTON_2) {
if (m_rotationActive != (action == GLFW_PRESS)) {
m_rotationActive = (action == GLFW_PRESS);
}
}
}
void PilotCameraController::gamepadCallback(int gamepadIndex, Camera &camera, double frametime) {
GLFWgamepadstate gamepadState;
glfwGetGamepadState(gamepadIndex, &gamepadState);
float sensitivity = 100.0f;
float sensitivity = 1.0f;
double threshold = 0.1;
// handle rotations
......@@ -162,29 +156,4 @@ namespace vkcv::camera {
* -copysign(1.0, stickLeftX);
}
void PilotCameraController::moveForward(int action){
m_forward = static_cast<bool>(action);
}
void PilotCameraController::moveBackward(int action){
m_backward = static_cast<bool>(action);
}
void PilotCameraController::moveLeft(int action){
m_left = static_cast<bool>(action);
}
void PilotCameraController::moveRight(int action){
m_right = static_cast<bool>(action);
}
void PilotCameraController::moveUpward(int action){
m_upward = static_cast<bool>(action);
}
void PilotCameraController::moveDownward(int action){
m_downward = static_cast<bool>(action);
}
}
\ No newline at end of file
......@@ -23,10 +23,10 @@ namespace vkcv::camera {
}
// handle yaw rotation
m_yaw = m_yaw + static_cast<float>(xOffset) * m_cameraSpeed;
m_yaw = m_yaw + static_cast<float>(xOffset) * 90.0f * m_cameraSpeed;
// handle pitch rotation
m_pitch = m_pitch + static_cast<float>(yOffset) * m_cameraSpeed;
m_pitch = m_pitch + static_cast<float>(yOffset) * 90.0f * m_cameraSpeed;
}
void TrackballCameraController::updateRadius(double offset, Camera &camera) {
......@@ -67,15 +67,10 @@ namespace vkcv::camera {
}
void TrackballCameraController::mouseMoveCallback(double xoffset, double yoffset, Camera &camera) {
if(!m_rotationActive){
return;
}
float sensitivity = 0.025f;
xoffset *= sensitivity;
yoffset *= sensitivity;
xoffset *= static_cast<float>(m_rotationActive);
yoffset *= static_cast<float>(m_rotationActive);
panView(xoffset , yoffset, camera);
panView(xoffset, yoffset, camera);
}
void TrackballCameraController::mouseButtonCallback(int button, int action, int mods, Camera &camera) {
......@@ -91,7 +86,7 @@ namespace vkcv::camera {
GLFWgamepadstate gamepadState;
glfwGetGamepadState(gamepadIndex, &gamepadState);
float sensitivity = 100.0f;
float sensitivity = 1.0f;
double threshold = 0.1;
// handle rotations
......
......@@ -116,6 +116,10 @@ namespace vkcv::scene {
size_t pushConstantsSizePerDrawcall,
const RecordMeshDrawcallFunction &record,
const std::vector<ImageHandle> &renderTargets) {
m_core->recordBeginDebugLabel(cmdStream, "vkcv::scene::Scene", {
0.0f, 1.0f, 0.0f, 1.0f
});
PushConstants pushConstants (pushConstantsSizePerDrawcall);
std::vector<DrawcallInfo> drawcalls;
size_t count = 0;
......@@ -137,6 +141,8 @@ namespace vkcv::scene {
drawcalls,
renderTargets
);
m_core->recordEndDebugLabel(cmdStream);
}
Scene Scene::create(Core& core) {
......
......@@ -31,7 +31,7 @@ include(config/GLSLANG.cmake)
target_link_libraries(vkcv_shader_compiler ${vkcv_shader_compiler_libraries} vkcv)
# including headers of dependencies and the VkCV framework
target_include_directories(vkcv_shader_compiler SYSTEM BEFORE PRIVATE ${vkcv_shader_compiler_includes} ${vkcv_include})
target_include_directories(vkcv_shader_compiler SYSTEM BEFORE PRIVATE ${vkcv_shader_compiler_includes} ${vkcv_include} ${vkcv_includes})
# add the own include directory for public headers
target_include_directories(vkcv_shader_compiler BEFORE PUBLIC ${vkcv_shader_compiler_include})
......@@ -2,7 +2,7 @@
#include "vkcv/shader/GLSLCompiler.hpp"
#include <fstream>
#include <strstream>
#include <sstream>
#include <glslang/SPIRV/GlslangToSpv.h>
#include <glslang/StandAlone/DirStackFileIncluder.h>
......@@ -219,12 +219,10 @@ namespace vkcv::shader {
std::string source (shaderSource);
if (!m_defines.empty()) {
std::strstream defines;
std::ostringstream defines;
for (const auto& define : m_defines) {
defines << "#define " << define.first << " " << define.second << std::endl;
}
defines << '\0';
size_t pos = source.find("#version") + 8;
if (pos >= source.length()) {
......@@ -236,8 +234,10 @@ namespace vkcv::shader {
pos = epos;
}
const auto defines_str = defines.str();
pos = source.find('\n', pos) + 1;
source = source.insert(pos, defines.str());
source = source.insert(pos, defines_str);
}
const char *shaderStrings [1];
......
......@@ -7,7 +7,13 @@ namespace vkcv::upscaling {
void BilinearUpscaling::recordUpscaling(const CommandStreamHandle &cmdStream, const ImageHandle &input,
const ImageHandle &output) {
m_core.recordBeginDebugLabel(cmdStream, "vkcv::upscaling::BilinearUpscaling", {
0.0f, 0.0f, 1.0f, 1.0f
});
m_core.recordBlitImage(cmdStream, input, output, SamplerFilterType::LINEAR);
m_core.recordEndDebugLabel(cmdStream);
}
}
......@@ -177,7 +177,7 @@ namespace vkcv::upscaling {
vkcv::shader::GLSLCompiler easuCompiler;
vkcv::shader::GLSLCompiler rcasCompiler;
const auto& features = m_core.getContext().getPhysicalDevice().getFeatures2();
const auto& features = m_core.getContext().getFeatureManager().getFeatures();
const bool float16Support = (
checkFeatures<vk::PhysicalDeviceFloat16Int8FeaturesKHR>(
reinterpret_cast<const vk::BaseInStructure*>(&features),
......@@ -189,7 +189,7 @@ namespace vkcv::upscaling {
vk::StructureType::ePhysicalDevice16BitStorageFeaturesKHR,
check16Storage
)
) || (true); // check doesn't work because chain is empty
);
if (!float16Support) {
easuCompiler.setDefine("SAMPLE_SLOW_FALLBACK", "1");
......@@ -245,6 +245,10 @@ namespace vkcv::upscaling {
void FSRUpscaling::recordUpscaling(const CommandStreamHandle& cmdStream,
const ImageHandle& input,
const ImageHandle& output) {
m_core.recordBeginDebugLabel(cmdStream, "vkcv::upscaling::FSRUpscaling", {
1.0f, 0.0f, 0.0f, 1.0f
});
const uint32_t inputWidth = m_core.getImageWidth(input);
const uint32_t inputHeight = m_core.getImageHeight(input);
......@@ -361,6 +365,8 @@ namespace vkcv::upscaling {
PushConstants(0)
);
}
m_core.recordEndDebugLabel(cmdStream);
}
bool FSRUpscaling::isHdrEnabled() const {
......
......@@ -6,3 +6,4 @@ add_subdirectory(first_scene)
add_subdirectory(particle_simulation)
add_subdirectory(voxelization)
add_subdirectory(mesh_shader)
add_subdirectory(indirect_dispatch)
......@@ -18,14 +18,13 @@ int main(int argc, const char** argv) {
windowHeight,
true
);
vkcv::Core core = vkcv::Core::create(
window,
applicationName,
VK_MAKE_VERSION(0, 0, 1),
{ vk::QueueFlagBits::eGraphics ,vk::QueueFlagBits::eCompute , vk::QueueFlagBits::eTransfer },
{},
{ "VK_KHR_swapchain" }
{ VK_KHR_SWAPCHAIN_EXTENSION_NAME }
);
vkcv::asset::Scene mesh;
......@@ -166,7 +165,6 @@ int main(int argc, const char** argv) {
vkcv::camera::CameraManager cameraManager(window);
uint32_t camIndex0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT);
uint32_t camIndex1 = cameraManager.addCamera(vkcv::camera::ControllerType::TRACKBALL);
cameraManager.getCamera(camIndex0).setPosition(glm::vec3(0, 0, -3));
......
......@@ -28,14 +28,13 @@ int main(int argc, const char** argv) {
cameraManager.getCamera(camIndex0).setNearFar(0.1f, 30.0f);
cameraManager.getCamera(camIndex1).setNearFar(0.1f, 30.0f);
vkcv::Core core = vkcv::Core::create(
window,
applicationName,
VK_MAKE_VERSION(0, 0, 1),
{ vk::QueueFlagBits::eGraphics ,vk::QueueFlagBits::eCompute , vk::QueueFlagBits::eTransfer },
{},
{ "VK_KHR_swapchain" }
{ VK_KHR_SWAPCHAIN_EXTENSION_NAME }
);
vkcv::scene::Scene scene = vkcv::scene::Scene::load(core, std::filesystem::path(
......
......@@ -16,22 +16,21 @@ int main(int argc, const char** argv) {
windowHeight,
false
);
vkcv::Core core = vkcv::Core::create(
window,
applicationName,
VK_MAKE_VERSION(0, 0, 1),
{ vk::QueueFlagBits::eTransfer,vk::QueueFlagBits::eGraphics, vk::QueueFlagBits::eCompute },
{},
{ "VK_KHR_swapchain" }
{ VK_KHR_SWAPCHAIN_EXTENSION_NAME }
);
const auto& context = core.getContext();
auto triangleIndexBuffer = core.createBuffer<uint16_t>(vkcv::BufferType::INDEX, 3, vkcv::BufferMemoryType::DEVICE_LOCAL);
uint16_t indices[3] = { 0, 1, 2 };
triangleIndexBuffer.fill(&indices[0], sizeof(indices));
core.setDebugLabel(triangleIndexBuffer.getHandle(), "Triangle Index Buffer");
// an example attachment for passes that output to the window
const vkcv::AttachmentDescription present_color_attachment(
vkcv::AttachmentOperation::STORE,
......@@ -46,6 +45,8 @@ int main(int argc, const char** argv) {
std::cout << "Error. Could not create renderpass. Exiting." << std::endl;
return EXIT_FAILURE;
}
core.setDebugLabel(trianglePass, "Triangle Pass");
vkcv::ShaderProgram triangleShaderProgram;
vkcv::shader::GLSLCompiler compiler;
......@@ -78,12 +79,15 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE;
}
core.setDebugLabel(trianglePipeline, "Triangle Pipeline");
auto start = std::chrono::system_clock::now();
const vkcv::Mesh renderMesh({}, triangleIndexBuffer.getVulkanHandle(), 3);
vkcv::DrawcallInfo drawcall(renderMesh, {},1);
const vkcv::ImageHandle swapchainInput = vkcv::ImageHandle::createSwapchainImageHandle();
core.setDebugLabel(swapchainInput, "Swapchain Image");
vkcv::camera::CameraManager cameraManager(window);
uint32_t camIndex0 = cameraManager.addCamera(vkcv::camera::ControllerType::PILOT);
......@@ -113,6 +117,7 @@ int main(int argc, const char** argv) {
pushConstants.appendDrawcall(mvp);
auto cmdStream = core.createCommandStream(vkcv::QueueType::Graphics);
core.setDebugLabel(cmdStream, "Render Commands");
core.recordDrawcallsToCmdStream(
cmdStream,
......
indirect_dispatch
cmake_minimum_required(VERSION 3.16)
project(indirect_dispatch)
# setting c++ standard for the project
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# this should fix the execution path to load local files from the project
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
# adding source files to the project
add_executable(indirect_dispatch src/main.cpp)
target_sources(indirect_dispatch PRIVATE
src/App.hpp
src/App.cpp
src/AppConfig.hpp
src/MotionBlurConfig.hpp
src/AppSetup.hpp
src/AppSetup.cpp
src/MotionBlur.hpp
src/MotionBlur.cpp
src/MotionBlurSetup.hpp
src/MotionBlurSetup.cpp)
# this should fix the execution path to load local files from the project (for MSVC)
if(MSVC)
set_target_properties(indirect_dispatch PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set_target_properties(indirect_dispatch PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# in addition to setting the output directory, the working directory has to be set
# by default visual studio sets the working directory to the build directory, when using the debugger
set_target_properties(indirect_dispatch PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
# including headers of dependencies and the VkCV framework
target_include_directories(indirect_dispatch SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_testing_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include} ${vkcv_gui_include})
# linking with libraries from all dependencies and the VkCV framework
target_link_libraries(indirect_dispatch vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_testing vkcv_camera vkcv_shader_compiler vkcv_gui)
\ No newline at end of file
File added
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
projects/indirect_dispatch/resources/models/grid.png

130 B

File added
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
#version 440
#extension GL_GOOGLE_include_directive : enable
layout(set=0, binding=0) uniform texture2D inTexture;
layout(set=0, binding=1) uniform sampler textureSampler;
layout(set=0, binding=2, rgba8) uniform image2D outImage;
layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;
void main(){
ivec2 outImageRes = imageSize(outImage);
ivec2 coord = ivec2(gl_GlobalInvocationID.xy);
if(any(greaterThanEqual(coord, outImageRes)))
return;
vec2 uv = vec2(coord) / outImageRes;
vec3 linearColor = texture(sampler2D(inTexture, textureSampler), uv).rgb;
vec3 gammaCorrected = pow(linearColor, vec3(1 / 2.2));
imageStore(outImage, coord, vec4(gammaCorrected, 0.f));
}
\ No newline at end of file
#version 450
#extension GL_ARB_separate_shader_objects : enable
layout(location = 0) in vec3 passNormal;
layout(location = 1) in vec2 passUV;
layout(location = 0) out vec3 outColor;
layout(set=0, binding=0) uniform texture2D albedoTexture;
layout(set=0, binding=1) uniform sampler textureSampler;
void main() {
vec3 albedo = texture(sampler2D(albedoTexture, textureSampler), passUV).rgb;
vec3 N = normalize(passNormal);
float light = max(N.y * 0.5 + 0.5, 0);
outColor = light * albedo;
}
\ No newline at end of file