Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan Renderer openFrameworks #7

Open
wants to merge 547 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
547 commits
Select commit Hold shift + click to select a range
0aa54b5
set windowH,windowW when creating window
tgfrerer Oct 5, 2016
6bf0bb2
whitespace cleanup
tgfrerer Oct 5, 2016
a51ed43
add noop deleter logger channel
tgfrerer Oct 5, 2016
ab7b1ff
update shader code
tgfrerer Oct 5, 2016
96e5cbe
remove bound pipeline state from RenderBatch member properties
tgfrerer Oct 5, 2016
98f0eb0
drawcommand: add hint to where to catch uniform not found
tgfrerer Oct 5, 2016
dbbe9d3
overhaul example
tgfrerer Oct 5, 2016
851d5b7
add placeholder comments, cleanup
tgfrerer Oct 5, 2016
0330e7d
add by-index setters for vertex attrib data
tgfrerer Oct 6, 2016
2ef3c32
add methods to transfer data to renderContext
tgfrerer Oct 6, 2016
b811372
demote log level for renderer function not implemented
tgfrerer Oct 6, 2016
c5035d6
wait for device idle before destroying allocator
tgfrerer Oct 6, 2016
aedd91f
update example to use static memory for mesh
tgfrerer Oct 6, 2016
db75840
update example
tgfrerer Oct 6, 2016
6d0a434
cleanup
tgfrerer Oct 6, 2016
bff93e7
add fullscreen quad shader
tgfrerer Oct 7, 2016
b74b2d6
update shader init
tgfrerer Oct 7, 2016
bc5e644
pipeline: set initial blend mode to alpha, deactivated
tgfrerer Oct 7, 2016
40e00ce
renderbatch: check for empty before binding
tgfrerer Oct 7, 2016
1d8506c
update stageData
tgfrerer Oct 7, 2016
8039e70
update example
tgfrerer Oct 7, 2016
5188818
remove bufferobject from project file
tgfrerer Oct 7, 2016
fc91ba7
clean example
tgfrerer Oct 7, 2016
d18b684
clean up staging logic, move into context
tgfrerer Oct 7, 2016
990554a
update example
tgfrerer Oct 7, 2016
1ad021b
add convenience methods for setAttribute
tgfrerer Oct 7, 2016
4efb7d1
update example
tgfrerer Oct 7, 2016
4d5d6c7
cleanup buffer transfer functions, prepare image transfer methods
tgfrerer Oct 10, 2016
37c0d07
first step different allocator classes
tgfrerer Oct 10, 2016
5ed949a
implement image allocator
tgfrerer Oct 10, 2016
a6f3ce9
cleanup
tgfrerer Oct 10, 2016
1b790d0
add credit to fullscreenquad shader
tgfrerer Oct 12, 2016
9fc8e8e
prepare example to draw textured plane
tgfrerer Oct 12, 2016
9dbea9e
cleanup uniform members lookup in drawcommand, shader
tgfrerer Oct 12, 2016
1989adf
cleanup pipeline barrier dependencies in buffer upload
tgfrerer Oct 12, 2016
5275c17
implement image upload
tgfrerer Oct 12, 2016
efa4116
rewrite texture class to be slimmer
tgfrerer Oct 12, 2016
dbf805a
rewrite transient draw state handling
tgfrerer Oct 13, 2016
1805792
implement uniform texture binding
tgfrerer Oct 13, 2016
6e86788
add missing shader files for textured rect test
tgfrerer Oct 13, 2016
7a1a6d9
print message when shader code updates successfully
tgfrerer Oct 14, 2016
3f2d8be
add check for ubo storage size
tgfrerer Oct 14, 2016
1456477
add option to shader compiler to print debug info
tgfrerer Oct 14, 2016
9ca5160
fix ubo member overlap check
tgfrerer Oct 14, 2016
ba05f5b
use color on windows console for warning messages
tgfrerer Oct 14, 2016
5537193
print debugInfo in all example shaders for now
tgfrerer Oct 14, 2016
a680f80
clarify comments, update uniform_id bitfield allocations
tgfrerer Oct 21, 2016
c1db71a
add log if present mode could not be set
tgfrerer Oct 21, 2016
7288277
Merge branch 'vk' of github.com:tgfrerer/openFrameworks into vk
tgfrerer Oct 21, 2016
4f41bad
linux fixes: renderpass
tgfrerer Oct 21, 2016
e7bf8de
linux fixes: fix draw command
tgfrerer Oct 21, 2016
2e635f3
linux fixes: fix allocator
tgfrerer Oct 21, 2016
eedc7eb
linux fixes fix rendercontext #2
tgfrerer Oct 21, 2016
7145178
linux fixes 3
tgfrerer Oct 21, 2016
a71f870
rename static upload method
tgfrerer Oct 24, 2016
d4d583e
update spir-v cross to 206cb9157ccd4a60222bf4ed988d6b56c75643de
tgfrerer Oct 24, 2016
4b842b3
Merge branch 'master' of https://github.com/openframeworks/openFramew…
tgfrerer Oct 28, 2016
2b35fd9
update apothecary shaderc recipe
tgfrerer Oct 28, 2016
3bc444e
fix issue with fullscreen on linux
tgfrerer Oct 28, 2016
215a7c7
remove unneeded files
tgfrerer Oct 31, 2016
a3fc2c5
update vs project files and filters
tgfrerer Oct 31, 2016
b2226e3
update example project file
tgfrerer Oct 31, 2016
70d3096
update readme
tgfrerer Oct 31, 2016
b41cd5a
Merge branch 'vk-linux' into vk
tgfrerer Oct 31, 2016
d7cfeb9
linux: use env VULKAN_SDK
tgfrerer Oct 31, 2016
9dd69ba
prepare compute
tgfrerer Nov 14, 2016
e95716a
doc updates
tgfrerer Nov 14, 2016
10af5b2
make rendercontext independent of draw command
tgfrerer Nov 14, 2016
cadd63c
compute pipeline: add hash calc, comp
tgfrerer Nov 14, 2016
4aec518
implement storageBuffer attachment
tgfrerer Nov 14, 2016
5ed925c
merge shader stageflags on samplers, ssbo
tgfrerer Nov 15, 2016
7dcf802
add log for storage buffer shader input
tgfrerer Nov 15, 2016
a3966e9
fix setStorageBuffer syntax
tgfrerer Nov 16, 2016
8aa4c31
update example to use storageBuffer.
tgfrerer Nov 16, 2016
12ffc33
whitespace cleanup
tgfrerer Nov 16, 2016
f2667bb
Merge branch 'vk' of github.com:tgfrerer/openFrameworks into vk
tgfrerer Nov 16, 2016
2bfd380
update props to use VK_SDK_PATH instead of VULKAN_SDK
tgfrerer Nov 17, 2016
a98c0eb
flesh out compute command
tgfrerer Nov 18, 2016
95065bf
update setTexture to accept a const ref instead of a shared_ptr
tgfrerer Nov 18, 2016
ecd09b5
update shaders to work around some issues with 1.0.30 validation layers
tgfrerer Nov 18, 2016
97d9d02
rename some methods in renderbatch
tgfrerer Nov 18, 2016
c9afe6c
add rough compute command example
tgfrerer Nov 18, 2016
5182b17
remove transferbatch from project
tgfrerer Nov 18, 2016
4836b8e
update rendercontext pipeline barrier
tgfrerer Dec 14, 2016
9598720
update vk template
tgfrerer Jan 20, 2017
6279ab4
small updates to swapchain
tgfrerer Jan 20, 2017
d1da3ca
main.cpp: more explicit setup
tgfrerer Jan 20, 2017
ac66669
add missing compute shader
tgfrerer Jan 20, 2017
850e8df
prepare for swapchain changes
tgfrerer Jan 20, 2017
a2b113d
prepare modular swapchain
tgfrerer Jan 20, 2017
de51007
refactor swapchain
tgfrerer Jan 20, 2017
9eeec4e
cleanup
tgfrerer Jan 23, 2017
2f8a594
refactor swapchain
tgfrerer Jan 23, 2017
94fa3e4
prepare image swapchain
tgfrerer Jan 23, 2017
8a2a459
flag surface properties as dirty
tgfrerer Jan 27, 2017
e997409
reorganise swapchain files
tgfrerer Feb 2, 2017
8c98134
move waitforfence into rendercontext
tgfrerer Feb 3, 2017
e84164b
cleanup queuePresent
tgfrerer Feb 3, 2017
6568e2b
cleanup comments
tgfrerer Feb 3, 2017
97bd6e5
remove unused setupCommandPool
tgfrerer Feb 3, 2017
e395374
clarify comments
tgfrerer Feb 6, 2017
22052a7
cleanup depth stencil
tgfrerer Feb 6, 2017
d30786a
remove unused renderpass.h file
tgfrerer Feb 10, 2017
8ffcbd2
renderpass creation more explicit
tgfrerer Feb 10, 2017
290d71e
remove spurious log
tgfrerer Feb 10, 2017
f6d4368
whitespace cleanup
tgfrerer Feb 10, 2017
f989c62
expose renderer components
tgfrerer Feb 10, 2017
04dccdc
more explicit test app
tgfrerer Feb 10, 2017
5544825
cleanup
tgfrerer Feb 13, 2017
2728a7e
img swapchain updates
tgfrerer Feb 13, 2017
f4fb4a0
remove old example
tgfrerer Feb 14, 2017
503fadd
add minimal example
tgfrerer Feb 14, 2017
f24e5ca
rendercontext: unify command buffer allocators
tgfrerer Feb 14, 2017
f2d43e3
renderbatch: better mapping cmdbuffer-renderbatch
tgfrerer Feb 14, 2017
59d5b10
update to latest api, spirv-cross
tgfrerer Feb 16, 2017
5d12491
testVk: fix wrong shaderc include for release mode
tgfrerer Feb 21, 2017
61cc13d
check for shader
tgfrerer Feb 21, 2017
38c893d
update example
tgfrerer Feb 21, 2017
e3d4972
update vk template
tgfrerer Feb 21, 2017
2651e8c
add getter for num virtual frames
tgfrerer Feb 21, 2017
d5404a0
cleanup
tgfrerer Feb 21, 2017
6fa6fe8
cleanup
tgfrerer Feb 22, 2017
21a0c1f
make context swap() private
tgfrerer Feb 22, 2017
5e84908
add clearvalues to context
tgfrerer Feb 22, 2017
e5b2336
cleanup
tgfrerer Feb 22, 2017
8a22362
implement context dependencies
tgfrerer Feb 22, 2017
7c91529
refactor: rename semaphores
tgfrerer Feb 23, 2017
06d86b6
refactor: RenderContext -> Context
tgfrerer Feb 23, 2017
7f356fb
rename Context submitToQueue
tgfrerer Feb 23, 2017
c47e700
update texture to clamp by default
tgfrerer Feb 23, 2017
a3c811b
renderbatch: check for renderpass
tgfrerer Feb 23, 2017
43929a2
add double buffer test app
tgfrerer Feb 23, 2017
4bb2a5b
drawCommand: fix default name for tex coord
tgfrerer Feb 23, 2017
fcac879
update testVk app
tgfrerer Feb 23, 2017
845cbfa
consolidate rendererSettings
tgfrerer Feb 24, 2017
2dc97bc
queues: implement creation of multiple queues
tgfrerer Feb 24, 2017
60d20ef
update readme
tgfrerer Feb 24, 2017
b7a169e
update examples
tgfrerer Feb 24, 2017
492032a
housekeeping
tgfrerer Feb 27, 2017
e14099c
gcc specific cleanup
tgfrerer Feb 27, 2017
6dd943b
renderer: fix queue generation
tgfrerer Feb 28, 2017
79eea19
Merge branch 'master' of https://github.com/openframeworks/openFramew…
tgfrerer Mar 1, 2017
70f2b06
fix qbs for vk
tgfrerer Mar 3, 2017
0bf66a9
Merge branch 'vk' of github.com:tgfrerer/openFrameworks into vk
tgfrerer Mar 3, 2017
e3acaac
clarify memory dependencies in subpass
tgfrerer Mar 6, 2017
b833265
cleanup header dependencies
tgfrerer Mar 6, 2017
16fed65
housekeeping
tgfrerer Mar 6, 2017
ded8de3
refactor imgSwapchain
tgfrerer Mar 13, 2017
47e22da
allocators: respect queue indices
tgfrerer Mar 13, 2017
1d42c6a
housekeeping
tgfrerer Mar 14, 2017
8d4ef12
implement basic single-threaded image swapchain
tgfrerer Mar 14, 2017
900290e
store queue family indices in rendererSettings
tgfrerer Mar 17, 2017
448bd42
cleanup img swapchain
tgfrerer Mar 17, 2017
4dda7a1
cleanup
tgfrerer Mar 20, 2017
5cd43dd
prepare for linux-imgswapchain tests
tgfrerer Mar 22, 2017
08cdf91
cleanup
tgfrerer Apr 20, 2017
c51e7e4
cleanup
tgfrerer Apr 21, 2017
e1c03fb
Merge branch 'master' into vk-master
tgfrerer Apr 21, 2017
450824b
update setup instructions for vs
tgfrerer Apr 21, 2017
f37549b
update submodule ref to local apothecary
tgfrerer Apr 21, 2017
2fee979
update apothecary submodule commit
tgfrerer Apr 21, 2017
920ed01
remove shaderc from repo, as tracked through apothecary
tgfrerer Apr 21, 2017
af17310
update spirv-cross source files
tgfrerer Apr 21, 2017
7f82604
fixes for linux qbs
tgfrerer Apr 21, 2017
4d088f6
pacify qt creator warning
tgfrerer Apr 21, 2017
bc813b3
update readme formatting
tgfrerer Apr 21, 2017
5c0bcbc
update vulkan lib location as of vk sdk >= 1.0.46.0
tgfrerer May 9, 2017
de69b5c
update shader compiler
tgfrerer May 9, 2017
bd67a0e
update testVk shader
tgfrerer May 10, 2017
7272290
whitespace formatting
tgfrerer May 10, 2017
84e6096
update vk template
tgfrerer May 10, 2017
860ea0e
update readme
tgfrerer May 10, 2017
8e5c1ed
vs: update property pages for projects
tgfrerer May 11, 2017
1d609d9
implement explicit selection of draw method
tgfrerer May 11, 2017
2affcff
add method to get vkCmdBuffer from batch
tgfrerer May 11, 2017
a427e7b
allow DrawCommand.setMesh() to be chained
tgfrerer May 11, 2017
78cb261
update examples
tgfrerer May 11, 2017
c450e6f
shader: bail out by quitting if not compile
tgfrerer May 11, 2017
dbd8cb5
Merge branch 'master' of https://github.com/openframeworks/openFramew…
tgfrerer May 11, 2017
2840f87
shader: print attribute info
tgfrerer May 11, 2017
2aa29b4
disable setVsync for vk renderer
tgfrerer May 11, 2017
a9700c1
whitespace fix in of.qbs
tgfrerer May 12, 2017
b2f3539
add shader error highlighting to linux
tgfrerer May 12, 2017
c8955b3
update shader error console output for win32
tgfrerer May 15, 2017
9b6ed5c
add console colour constants to Shader.cpp
tgfrerer May 16, 2017
e27f2a8
Merge branch 'master' of https://github.com/openframeworks/openFramew…
tgfrerer May 16, 2017
6ae8582
Merge branch 'vk' into vk-master
tgfrerer May 16, 2017
9bfb3e6
refactor: renderpass into renderbatch
tgfrerer May 16, 2017
1cddd1c
cleanup
tgfrerer May 17, 2017
61b3dcb
update examples
tgfrerer May 17, 2017
e9be7b8
fix context semaphore for non-primary context
tgfrerer May 18, 2017
d542b4e
cleanup
tgfrerer May 18, 2017
eeae168
extend DrawCommand
tgfrerer May 18, 2017
bcfe164
extend Shader
tgfrerer May 18, 2017
4d3e4bf
add staging context to vk renderer
tgfrerer May 18, 2017
576ff0a
add getter for context of a batch
tgfrerer May 18, 2017
9a5b90f
texture: add option to pass samplerinfo on creation
tgfrerer May 18, 2017
6fa1cdd
rough draft vk imgui test project. depends on custom version of ofxImGui
tgfrerer May 19, 2017
2b8258b
fix static method name
tgfrerer May 24, 2017
6d6dccf
manual merge
tgfrerer May 24, 2017
159fbe0
cleanup
tgfrerer May 26, 2017
413d497
cleanup
tgfrerer May 30, 2017
16f903e
vkfun example: use staging context
tgfrerer May 30, 2017
a349e7d
performance tuning: optimise DrawCommand
tgfrerer May 30, 2017
c3084f1
update vk project template
tgfrerer May 31, 2017
44f1ec3
testVkFun: add shader #include
tgfrerer Jun 2, 2017
319cd72
cleanup
tgfrerer Jun 2, 2017
379a891
shader.cpp add missing console colour to error messages
tgfrerer Jun 2, 2017
27685a9
texture: refactor
tgfrerer Jun 2, 2017
c2732f1
add flag demo project
tgfrerer Jun 2, 2017
d2336ed
update vk readme
tgfrerer Jun 2, 2017
808c90e
update vkImGui example
tgfrerer Jun 27, 2017
5c3e7ec
update imgui example
tgfrerer Jul 10, 2017
cf34a88
cleanup
tgfrerer Jul 10, 2017
3029c05
Merge branch 'vk' of github.com:tgfrerer/openFrameworks into vk
tgfrerer Jul 10, 2017
ad20ae1
Merge branch 'master' of https://github.com/openframeworks/openFramew…
tgfrerer Jul 10, 2017
79695f3
vk-shader: update syntax for setting sources
tgfrerer Jul 11, 2017
2780b1d
add convenience setters for Settings objects
tgfrerer Jul 11, 2017
9ea8b8d
fix imgui example
tgfrerer Jul 11, 2017
ab481e0
Shader fixes
tgfrerer Jul 11, 2017
e068cfd
Renderbatch: add convenience setters
tgfrerer Jul 11, 2017
6057b0a
update vk template
tgfrerer Jul 14, 2017
e75c567
cleanup
tgfrerer Jul 14, 2017
35aa266
image allocator : fix initialisers
tgfrerer Jul 14, 2017
76a5d69
helpertypes: prepare adapter for ofPixels
tgfrerer Jul 14, 2017
b4d092d
refactor: make allocator standalone objects
tgfrerer Jul 14, 2017
e53c05e
update examples for new Allocator syntax
tgfrerer Jul 14, 2017
634275c
fixes for gcc
tgfrerer Jul 17, 2017
8fc10d6
cleanup DrawCommand
tgfrerer Jul 17, 2017
7f49d97
vk::Texture refactor
tgfrerer Jul 17, 2017
d93127d
add default shaders source and spirv
tgfrerer Jul 17, 2017
f40d617
vk::Texture - update examples
tgfrerer Jul 18, 2017
36021ac
ComputeCommand: return reference to shared_ptr
tgfrerer Jul 18, 2017
8c7ec4f
update project files for vs2017
tgfrerer Jul 18, 2017
62fe915
update computeCommand, cleanup
tgfrerer Jul 26, 2017
568ecea
renderbatch: add templated clearcolorvalue setter
tgfrerer Jul 26, 2017
861a01a
cleanup
tgfrerer Jul 26, 2017
7171c3c
add readme for default shader sources files
tgfrerer Jul 26, 2017
2a78f6b
vk context: fix synchronisation issue
tgfrerer Aug 16, 2017
7d1e06a
vk renderbatch: initialise cmd in constructor
tgfrerer Aug 16, 2017
338d652
vk pipeline: add initialisers for blendmodes
tgfrerer Aug 16, 2017
897df5b
vk: cleanup
tgfrerer Aug 16, 2017
c84c368
feature: add option to set ubo as struct in shader interface
tgfrerer Aug 24, 2017
cdd6747
cleanup swapchain initialisation
tgfrerer Aug 24, 2017
7951da8
context: clean up sync
tgfrerer Aug 24, 2017
688bbfd
cleanup compute pipeline generation
tgfrerer Aug 24, 2017
99c1a29
Merge branch 'master' of https://github.com/openframeworks/openFramew…
tgfrerer Sep 8, 2017
2c148f8
asdf
tgfrerer Sep 8, 2017
c6c7147
Merge branch 'master' of https://github.com/openframeworks/openFramew…
tgfrerer Oct 27, 2017
f78eb54
small fixes
tgfrerer Oct 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,4 @@ Desktop.ini

.mailmap
/apps*/
openframeworksLib.vcxproj.user
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
url = https://github.com/openframeworks/projectGenerator.git
[submodule "scripts/apothecary"]
path = scripts/apothecary
url = https://github.com/openframeworks/apothecary
url = https://github.com/openframeworks-vk/apothecary.git
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
================

# Experimental Vulkan Renderer branch

For mainline openFrameworks goto:
[https://github.com/openframeworks/openFrameworks](https://github.com/openframeworks/openFrameworks)

Also take a look at the Vulkan specific README in [libs/openFrameworks/vk](https://github.com/openframeworks-vk/openFrameworks/tree/vk/libs/openFrameworks/vk)

================

[openFrameworks](http://openframeworks.cc/)
================

Expand All @@ -6,7 +17,6 @@ openFrameworks is a C++ toolkit for creative coding. If you are new to OF, welc
[![Slack Status](https://ofslack.herokuapp.com/badge.svg)](https://ofslack.herokuapp.com)

Build status
--------

Linux, OSX, iOS and Android [![Build Status](https://travis-ci.org/openframeworks/openFrameworks.svg?branch=master)](https://travis-ci.org/openframeworks/openFrameworks)

Expand Down
Empty file added apps/devApps/testVk/addons.make
Empty file.
Empty file.
33 changes: 33 additions & 0 deletions apps/devApps/testVk/bin/data/default.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#version 450 core

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout (location = 0) in vec4 inColor;
layout (location = 1) in vec3 inNormal;
layout (location = 2) in vec2 inTexCoord;

// uniforms (resources)
layout (set = 0, binding = 0) uniform DefaultMatrices
{
mat4 projectionMatrix;
mat4 modelMatrix;
mat4 viewMatrix;
};
// layout (set = 1, binding = 0) uniform StyleSet
// {
// vec4 globalColor;
// } style;


layout (location = 0) out vec4 outFragColor;

void main()
{

vec4 normalColor = vec4((inNormal + vec3(1.0)) * vec3(0.5) , 1.0);
vec4 vertexColor = inColor;

// set the actual fragment color here
outFragColor = vertexColor;
}
43 changes: 43 additions & 0 deletions apps/devApps/testVk/bin/data/default.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#version 450 core

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

// uniforms (resources)
layout (set = 0, binding = 0) uniform DefaultMatrices
{
mat4 projectionMatrix;
mat4 modelMatrix;
mat4 viewMatrix;
}; // note: if you don't specify a variable name for the block its elements will live in the global namespace.

layout (set = 0, binding = 1) uniform Style
{
vec4 globalColor;
} style;

// inputs (vertex attributes)
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec4 inColor;
layout (location = 2) in vec3 inNormal;
layout (location = 3) in vec2 inTexCoord;

// outputs
layout (location = 0) out vec4 outColor;
layout (location = 1) out vec3 outNormal;
layout (location = 2) out vec2 outTexCoord;

// we override the built-in fixed function outputs
// to have more control over the SPIR-V code created.
out gl_PerVertex
{
vec4 gl_Position;
};

void main()
{
outNormal = (inverse(transpose( viewMatrix * modelMatrix)) * vec4(inNormal, 0.0)).xyz;
outColor = style.globalColor;
outTexCoord = inTexCoord;
gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(inPos.xyz, 1.0);
}
14 changes: 14 additions & 0 deletions apps/devApps/testVk/bin/data/fullScreenQuad.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 450 core

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

// inputs
layout (location = 0) in vec2 inTexCoord;

// outputs
layout (location = 0) out vec4 outFragColor;

void main(){
outFragColor = vec4(inTexCoord, 1, 1.0);
}
24 changes: 24 additions & 0 deletions apps/devApps/testVk/bin/data/fullScreenQuad.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#version 450 core

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

// outputs
layout (location = 0) out vec2 outTexCoord;

// we override the built-in fixed function outputs
// to have more control over the SPIR-V code created.
out gl_PerVertex
{
vec4 gl_Position;
};

// This shader built after a technique introduced in:
// http://www.saschawillems.de/?page_id=2122

void main()
{
outTexCoord = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2);
gl_Position = vec4(outTexCoord * 2.0f + -1.0f, 0.0f, 1.0f);

}
8 changes: 8 additions & 0 deletions apps/devApps/testVk/icon.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Icon Resource Definition
#define MAIN_ICON 102

#if defined(_DEBUG)
MAIN_ICON ICON "icon_debug.ico"
#else
MAIN_ICON ICON "icon.ico"
#endif
38 changes: 38 additions & 0 deletions apps/devApps/testVk/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "ofMain.h"
#include "ofApp.h"

int main(){
// Do basic initialisation (mostly setup timers, and randseed)
ofInit();

auto consoleLogger = new ofConsoleLoggerChannel();
ofSetLoggerChannel( std::shared_ptr<ofBaseLoggerChannel>( consoleLogger, []( ofBaseLoggerChannel * lhs){} ) );

// Create a new window
auto mainWindow = std::make_shared<ofAppGLFWWindow>();
//auto mainWindow = std::make_shared<ofAppVkNoWindow>();

// Store main window in mainloop
ofGetMainLoop()->addWindow( mainWindow );

{
ofVkWindowSettings settings;
settings.rendererSettings.setVkVersion( 1, 0, 46 );
settings.rendererSettings.numSwapchainImages = 3;
settings.rendererSettings.numVirtualFrames = 3;
settings.rendererSettings.presentMode = ::vk::PresentModeKHR::eMailbox;

#ifdef NDEBUG
settings.rendererSettings.useDebugLayers = false;
#else
settings.rendererSettings.useDebugLayers = true;
#endif

// Initialise main window, and associated renderer.
mainWindow->setup( settings );
}

// Initialise and start application
ofRunApp( new ofApp() );

}
159 changes: 159 additions & 0 deletions apps/devApps/testVk/src/ofApp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
#include "ofApp.h"
#include "ofVkRenderer.h"

// We keep a shared pointer to the renderer so we don't have to
// fetch it anew every time we need it.
shared_ptr<ofVkRenderer> renderer;

//--------------------------------------------------------------
void ofApp::setup(){
ofDisableSetupScreen();

renderer = dynamic_pointer_cast<ofVkRenderer>( ofGetCurrentRenderer() );

{
// Set up a Draw Command which draws a full screen quad.
//
// This command uses the vertex shader to emit vertices, so
// doesn't need any geometry to render.

of::vk::Shader::Settings shaderSettings;

shaderSettings.device = renderer->getVkDevice();
shaderSettings.printDebugInfo = true;
shaderSettings.setSource(::vk::ShaderStageFlagBits::eVertex ,"fullScreenQuad.vert");
shaderSettings.setSource(::vk::ShaderStageFlagBits::eFragment,"fullScreenQuad.frag");

mShaderFullscreen = std::make_shared<of::vk::Shader>( shaderSettings );

of::vk::GraphicsPipelineState pipeline;

pipeline.setShader( mShaderFullscreen );

// Our full screen quad needs to draw just the back face. This is due to
// how we emit the vertices on the vertex shader. Since this differs from
// the default (back culling) behaviour, we have to set this explicitly.
pipeline.rasterizationState
.setCullMode( ::vk::CullModeFlagBits::eFront )
.setFrontFace( ::vk::FrontFace::eCounterClockwise );

// We don't care about depth testing when drawing the full screen quad.
// It shall always cover the full screen.
pipeline.depthStencilState
.setDepthTestEnable( VK_FALSE )
.setDepthWriteEnable( VK_FALSE )
;
pipeline.blendAttachmentStates[0].blendEnable = VK_TRUE;

fullscreenQuad.setup( pipeline );

// As this draw command issues vertices on the vertex shader
// we must tell it how many vertices to render.
fullscreenQuad.setNumVertices( 3 );
}

}

//--------------------------------------------------------------
void ofApp::update(){
ofSetWindowTitle( ofToString( ofGetFrameRate(), 10, ' ' ) );
}

//--------------------------------------------------------------
void ofApp::draw(){

// Fetch the default context. This context is automatically
// set up upon app initialisation to draw to the swapchain.
auto & context = renderer->getDefaultContext();

// Batch is a light-weight helper object which encapsulates
// a Vulkan Command Buffer. The command buffer is associated
// with the context it has been created from. As long as the
// command buffer lives on the same thread as the context, and
// only uses resources which are either global readonly static,
// or resources which are temporarily allocated though the
// context inside the context's thread, this is thread-safe.

// setup the main pass renderbatch
//
of::vk::RenderBatch::Settings settings;

settings
.setContext(context.get())
.setFramebufferAttachmentsExtent(renderer->getSwapchain()->getWidth(), renderer->getSwapchain()->getHeight())
.setRenderAreaExtent(renderer->getViewportWidth(), renderer->getViewportHeight())
.setRenderPass(*renderer->getDefaultRenderpass())
.addFramebufferAttachment(context->getSwapchainImageView())
.addClearColorValue(ofFloatColor::blueSteel)
.addFramebufferAttachment(renderer->getDepthStencilImageView())
.addClearDepthStencilValue({ 1.f,0 })
;

of::vk::RenderBatch batch{ settings };

batch.begin();
batch.draw( fullscreenQuad );
batch.end();


}

//--------------------------------------------------------------
void ofApp::keyPressed(int key){

}

//--------------------------------------------------------------
void ofApp::keyReleased(int key){
if ( key == ' ' ){
// Recompile the full screen shader and
// touch (force implicit re-creation of) any
// associated pipelines.
mShaderFullscreen->compile();
}
}

//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){

}

//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){

}

//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){

}

//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){

}

//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){

}

//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){

}

//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){

}
29 changes: 29 additions & 0 deletions apps/devApps/testVk/src/ofApp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#pragma once

#include "ofMain.h"
#include "vk/DrawCommand.h"

class ofApp : public ofBaseApp{

of::vk::DrawCommand fullscreenQuad;

std::shared_ptr<of::vk::Shader> mShaderFullscreen;

public:
void setup();
void update();
void draw();

void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void mouseEntered(int x, int y);
void mouseExited(int x, int y);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);

};
Loading