Skip to content
Snippets Groups Projects
Verified Commit 11c4ea48 authored by Tobias Frisch's avatar Tobias Frisch
Browse files

[#56] Removed batch and SPIRV files, replaced basic shader loading with runtime compilation

parent daf55add
No related branches found
No related tags found
No related merge requests found
Showing
with 32 additions and 52 deletions
......@@ -22,7 +22,7 @@ if(MSVC)
endif()
# including headers of dependencies and the VkCV framework
target_include_directories(first_mesh SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include})
target_include_directories(first_mesh SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_shader_compiler_include})
# linking with libraries from all dependencies and the VkCV framework
target_link_libraries(first_mesh vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_camera)
target_link_libraries(first_mesh vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_camera vkcv_shader_compiler)
%VULKAN_SDK%\Bin32\glslc.exe shader.vert -o vert.spv
%VULKAN_SDK%\Bin32\glslc.exe shader.frag -o frag.spv
pause
\ No newline at end of file
File deleted
File deleted
......@@ -4,6 +4,7 @@
#include <vkcv/camera/CameraManager.hpp>
#include <chrono>
#include <vkcv/asset/asset_loader.hpp>
#include <vkcv/shader/GLSLCompiler.hpp>
int main(int argc, const char** argv) {
const char* applicationName = "First Mesh";
......@@ -77,10 +78,19 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE;
}
vkcv::ShaderProgram firstMeshProgram{};
firstMeshProgram.addShader(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/vert.spv"));
firstMeshProgram.addShader(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/frag.spv"));
vkcv::ShaderProgram firstMeshProgram;
vkcv::shader::GLSLCompiler compiler;
compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/shader.vert"),
[&firstMeshProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
firstMeshProgram.addShader(shaderStage, path);
});
compiler.compile(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/shader.frag"),
[&firstMeshProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
firstMeshProgram.addShader(shaderStage, path);
});
auto& attributes = mesh.vertexGroups[0].vertexBuffer.attributes;
......
......@@ -22,7 +22,7 @@ if(MSVC)
endif()
# including headers of dependencies and the VkCV framework
target_include_directories(first_scene SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_scene_include})
target_include_directories(first_scene SYSTEM BEFORE PRIVATE ${vkcv_include} ${vkcv_includes} ${vkcv_asset_loader_include} ${vkcv_camera_include} ${vkcv_scene_include} ${vkcv_shader_compiler_include})
# linking with libraries from all dependencies and the VkCV framework
target_link_libraries(first_scene vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_camera vkcv_scene)
target_link_libraries(first_scene vkcv ${vkcv_libraries} vkcv_asset_loader ${vkcv_asset_loader_libraries} vkcv_camera vkcv_scene vkcv_shader_compiler)
%VULKAN_SDK%\Bin32\glslc.exe shader.vert -o vert.spv
%VULKAN_SDK%\Bin32\glslc.exe shader.frag -o frag.spv
pause
\ No newline at end of file
File deleted
File deleted
......@@ -4,11 +4,9 @@
#include <vkcv/camera/CameraManager.hpp>
#include <chrono>
#include <vkcv/asset/asset_loader.hpp>
#include <vkcv/Logger.hpp>
#include <vkcv/shader/GLSLCompiler.hpp>
#include <vkcv/scene/Scene.hpp>
int main(int argc, const char** argv) {
const char* applicationName = "First Scene";
......@@ -64,9 +62,18 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE;
}
vkcv::ShaderProgram sceneShaderProgram{};
sceneShaderProgram.addShader(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/vert.spv"));
sceneShaderProgram.addShader(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/frag.spv"));
vkcv::ShaderProgram sceneShaderProgram;
vkcv::shader::GLSLCompiler compiler;
compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("resources/shaders/shader.vert"),
[&sceneShaderProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
sceneShaderProgram.addShader(shaderStage, path);
});
compiler.compile(vkcv::ShaderStage::FRAGMENT, std::filesystem::path("resources/shaders/shader.frag"),
[&sceneShaderProgram](vkcv::ShaderStage shaderStage, const std::filesystem::path& path) {
sceneShaderProgram.addShader(shaderStage, path);
});
const std::vector<vkcv::VertexAttachment> vertexAttachments = sceneShaderProgram.getVertexAttachments();
std::vector<vkcv::VertexBinding> bindings;
......
File deleted
%VULKAN_SDK%\Bin32\glslc.exe shader.vert -o vert.spv
%VULKAN_SDK%\Bin32\glslc.exe shader.frag -o frag.spv
%VULKAN_SDK%\Bin32\glslc.exe shader.comp -o comp.spv
pause
\ No newline at end of file
File deleted
#version 440
layout(std430, binding = 0) buffer testBuffer
{
float test1[10];
float test2[10];
float test3[10];
};
layout( push_constant ) uniform constants{
float pushConstant;
};
layout(local_size_x = 5) in;
void main(){
if(gl_GlobalInvocationID.x >= 10){
return;
}
test1[gl_GlobalInvocationID.x] = gl_GlobalInvocationID.x;
test2[gl_GlobalInvocationID.x] = 69; // nice!
test3[gl_GlobalInvocationID.x] = pushConstant;
}
\ No newline at end of file
File deleted
......@@ -2,10 +2,8 @@
#include <vkcv/Core.hpp>
#include <GLFW/glfw3.h>
#include <vkcv/camera/CameraManager.hpp>
#include <chrono>
#include <vkcv/shader/GLSLCompiler.hpp>
#include <vkcv/gui/GUI.hpp>
#include <chrono>
int main(int argc, const char** argv) {
const char* applicationName = "First Triangle";
......@@ -49,7 +47,7 @@ int main(int argc, const char** argv) {
return EXIT_FAILURE;
}
vkcv::ShaderProgram triangleShaderProgram{};
vkcv::ShaderProgram triangleShaderProgram;
vkcv::shader::GLSLCompiler compiler;
compiler.compile(vkcv::ShaderStage::VERTEX, std::filesystem::path("shaders/shader.vert"),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment