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 for RmlUi #236

Closed
wants to merge 95 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
5391e22
ADD: Started Vulkan implementation
wh1t3lord Sep 10, 2021
072a9d3
ADD: instance creation
wh1t3lord Sep 10, 2021
5570461
ADD: physical device and device properties
wh1t3lord Sep 10, 2021
03e9a1f
ADD: The commentaries about ShellRenderInterfaceVulkan and trying to …
wh1t3lord Sep 10, 2021
b1499b5
ADD: Destroying functions but get HWND from RMLUI
wh1t3lord Sep 10, 2021
c4ee145
ADD: obtaining HWND
wh1t3lord Sep 10, 2021
117840a
FIX: compilation
wh1t3lord Sep 10, 2021
ad11d79
ADD: standard way to initialize and shutdown
wh1t3lord Sep 10, 2021
4b84c7c
ADD: Queues and Queues Indecies
wh1t3lord Sep 10, 2021
635e6cb
ADD: device creation
wh1t3lord Sep 10, 2021
1c4b128
ADD: swapchain
wh1t3lord Sep 11, 2021
3614889
ADD: OnResize method
wh1t3lord Sep 11, 2021
926490f
ADD: correct swapchain creation
wh1t3lord Sep 11, 2021
715370d
ADD: sync primitives
wh1t3lord Sep 11, 2021
c92411e
ADD: presenting, but without resources
wh1t3lord Sep 11, 2021
97926e9
ADD: start implementing resource management, creating descriptor set …
wh1t3lord Sep 19, 2021
2e80604
ADD: creating shaders, but I need to implement that
wh1t3lord Sep 19, 2021
695aa27
ADD: creating VkShaderModule
wh1t3lord Sep 19, 2021
3a8aa4d
ADD: remove not capable method in that arch
wh1t3lord Sep 19, 2021
e4fac8c
ADD: Physical device wrapper, pipeline layout creation
wh1t3lord Oct 3, 2021
5e1163b
ADD: continue creating VkFramebuffer for swapchain
wh1t3lord Oct 3, 2021
f39a70a
FIX: compilation thing and waiting before destroying everything
wh1t3lord Dec 9, 2021
5729c10
ADD: continue work
wh1t3lord Dec 9, 2021
ec5e863
FIX: swapchain creation
wh1t3lord Dec 9, 2021
9ce2310
FIX: formatting for commentary
wh1t3lord Dec 9, 2021
81082b2
ADD: something new
wh1t3lord Dec 9, 2021
da53bd1
ADD: command list ring
wh1t3lord Dec 11, 2021
ffd3dfa
ADD: implemented command list ring
wh1t3lord Dec 11, 2021
5d92ec4
ADD: added explanation commentary about using multiple logical frames…
wh1t3lord Dec 11, 2021
65b78e0
ADD: added allocator for another allocator, but I need to implement i…
wh1t3lord Dec 11, 2021
3222d58
ADD: added final allocator for dynamic buffer
wh1t3lord Dec 11, 2021
5f4e620
ADD: ring buffer pool implementation
wh1t3lord Dec 11, 2021
23c1722
FIX: compilation fixes
wh1t3lord Dec 11, 2021
a7c1b85
FIX: vma uses implementation in cpp
wh1t3lord Dec 11, 2021
38b7056
ADD: successful creation and deletion
wh1t3lord Dec 11, 2021
9e441d4
ADD: started rendering begin and end scopes
wh1t3lord Dec 18, 2021
1872753
ADD: stable rendering
wh1t3lord Dec 18, 2021
68ff9d3
ADD: correct rendering body
wh1t3lord Dec 18, 2021
51ae5f8
ADD: clearing back buffer is working well
wh1t3lord Dec 18, 2021
da3d62c
ADD: something new
wh1t3lord May 10, 2022
97c05cf
ADD: texture data wrapper
wh1t3lord May 11, 2022
15cf288
ADD: writing thing for uploading
wh1t3lord May 12, 2022
682eba1
ADD: need to create separate queue for uploading resources
wh1t3lord May 12, 2022
7f3c4f4
ADD: continue work, added upload manager
wh1t3lord May 13, 2022
24cea43
ADD: many stuff
wh1t3lord May 13, 2022
1ac3140
ADD: uploading textures is fine, but think about better memory handli…
wh1t3lord May 13, 2022
4ae51da
ADD: successful init/destroy state for app
wh1t3lord May 13, 2022
9c0d4c9
ADD: shaders for Vulkan, they are compiled with SPIR-V otherwise you …
wh1t3lord May 13, 2022
3c5bf75
ADD: successful init/destroy
wh1t3lord May 13, 2022
d1f15e5
FIX: inserting data into descriptor set layout bindings
wh1t3lord May 13, 2022
363e558
FIX: shaders, binding must unique!
wh1t3lord May 13, 2022
6df9f7f
ADD: continue at home
wh1t3lord May 13, 2022
a31095a
ADD: Descriptors
wh1t3lord May 16, 2022
b8140ad
ADD: continue
wh1t3lord May 16, 2022
f4490aa
ADD: continue
wh1t3lord May 16, 2022
401f643
FIX: obtaining texture from handle
wh1t3lord May 16, 2022
0fb4f54
ADD: continue work about pipeline creation, use VkDescriptorSetLayout…
wh1t3lord May 16, 2022
d4fb9db
ADD: creating pipelines, continue testing later
wh1t3lord May 17, 2022
0375ba8
ADD: successful creation pipelines
wh1t3lord May 17, 2022
f0c3845
ADD: continue work, because for every compile geometry you need to ha…
wh1t3lord May 18, 2022
8cb56a3
ADD: allocated more than one descriptor set, but still I need to test…
wh1t3lord May 18, 2022
3df9dda
ADD: well it seems drawing functions are recorded, but nothing to sho…
wh1t3lord May 18, 2022
455643b
ADD: cached compiled geometry_handle_t
wh1t3lord May 18, 2022
2a69673
FIX: data uploading was incorrect
wh1t3lord May 18, 2022
11c9e8f
FIX: commentary
wh1t3lord May 18, 2022
0174d1f
FIX: correct format for color
wh1t3lord May 18, 2022
b6a99fb
ADD: something, but geometry is discarded somehow...
wh1t3lord May 19, 2022
9ceccd4
ADD: Now this renders the scene, but font textures are not valid
wh1t3lord May 19, 2022
8da1e07
ADD: something new
wh1t3lord May 19, 2022
3255f07
ADD: FINAL
wh1t3lord May 19, 2022
35af403
ADD: commentary
wh1t3lord May 19, 2022
13be4f8
ADD: in order to test you have to uncomment those lines
wh1t3lord May 19, 2022
2a6fab4
FIX: removed pointless commentary due to release of backends branch
wh1t3lord May 19, 2022
dd116e9
ADD: all necessary commentaries
wh1t3lord May 19, 2022
15e79a3
ADD: vulkan renderer
wh1t3lord May 19, 2022
5376978
ADD: continue work about releasing stuff
wh1t3lord May 19, 2022
3ba040e
ADD: continue work, use one large Descriptor with offsets
wh1t3lord May 19, 2022
5016113
ADD: updated out-dated VMA allocator version, deleted some todos, nee…
wh1t3lord May 20, 2022
125c42a
ADD: using virtual allocator
wh1t3lord May 20, 2022
ed39f1b
ADD: FINAL, but I didn't test the other scenes. Reusing descriptors, …
wh1t3lord May 20, 2022
4efd205
FIX: message
wh1t3lord May 20, 2022
e1b0736
ADD: stuff, but WE REALLY need to solve the thing with Descriptors
wh1t3lord May 20, 2022
a6e1968
ADD: continue at home
wh1t3lord Jun 3, 2022
72bfedf
ADD: test at home
wh1t3lord Jun 6, 2022
1e13948
FIX: if we have descriptors, but remove that functionality after tests
wh1t3lord Jun 6, 2022
ad23af2
FIX: descriptor set picking
wh1t3lord Jun 6, 2022
722dcc2
FIX: descriptor set creation
wh1t3lord Jun 6, 2022
97d9094
ADD: continue testing
wh1t3lord Jun 6, 2022
ac4af10
ADD: continue at home
wh1t3lord Jun 6, 2022
ae27c3b
ADD: one descriptor set for geometry and descriptors per texture
wh1t3lord Jun 8, 2022
056dd62
ADD: something
wh1t3lord Jun 8, 2022
b0c5881
ADD: resizing works
wh1t3lord Jun 8, 2022
c67507e
ADD: need for tests
wh1t3lord Jun 8, 2022
dcc8ec6
FIX: with allocation
wh1t3lord Jun 8, 2022
69cd5d1
ADD: possibly final things
wh1t3lord Jun 9, 2022
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
6 changes: 6 additions & 0 deletions CMake/SampleFileList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ set(shell_HDR_FILES
${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellOpenGL.h
${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellRenderInterfaceExtensions.h
${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellRenderInterfaceOpenGL.h
${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellRenderInterfaceVulkan.h
${PROJECT_SOURCE_DIR}/Samples/shell/include/ShellSystemInterface.h
${PROJECT_SOURCE_DIR}/Samples/shell/include/spirv.h
${PROJECT_SOURCE_DIR}/Samples/shell/include/spirv_reflect.h
${PROJECT_SOURCE_DIR}/Samples/shell/include/vk_mem_alloc.h
)

set(shell_SRC_FILES
${PROJECT_SOURCE_DIR}/Samples/shell/src/Input.cpp
${PROJECT_SOURCE_DIR}/Samples/shell/src/Shell.cpp
${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellFileInterface.cpp
${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellRenderInterfaceOpenGL.cpp
${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellRenderInterfaceVulkan.cpp
${PROJECT_SOURCE_DIR}/Samples/shell/src/ShellSystemInterface.cpp
${PROJECT_SOURCE_DIR}/Samples/shell/src/spirv_reflect.cpp
)

set(animation_HDR_FILES
Expand Down
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,22 @@ if(BUILD_SAMPLES OR BUILD_TESTING)

# Find OpenGL
find_package(OpenGL REQUIRED)

find_package(Vulkan REQUIRED)

if(OPENGL_FOUND)
message("-- OpenGL is found! ${OPENGL_INCLUDE_DIR}")
message("-- OpenGL is found! ${OPENGL_LIBRARIES}")
include_directories(${OPENGL_INCLUDE_DIR})
list(APPEND sample_LIBRARIES ${OPENGL_LIBRARIES})
endif()

if (Vulkan_FOUND)
message("-- Vulkan is found! ${Vulkan_INCLUDE_DIR}")
message("-- Vulkan is found! ${Vulkan_LIBRARIES}")
include_directories(${Vulkan_INCLUDE_DIR})
list(APPEND sample_LIBRARIES ${Vulkan_LIBRARIES})
endif()

# Set up required system libraries
if(APPLE)
Expand Down
14 changes: 14 additions & 0 deletions Samples/assets/rmlui.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

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

layout (location = 0) out vec4 outColor;

layout(set=0, binding=1) uniform sampler2D Texture;

void main() {
outColor = inColor;
}
16 changes: 16 additions & 0 deletions Samples/assets/rmlui.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

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

layout (location = 0) out vec2 outTexCoord;
layout (location = 1) out vec4 outColor;

void main() {
outColor = inColor;
outTexCoord = inTexCoord;
gl_Position = vec4(pos, 0.0f, 1.0f);
}
Binary file added Samples/assets/rmlui_frag.spv
Binary file not shown.
Binary file added Samples/assets/rmlui_vert.spv
Binary file not shown.
15 changes: 15 additions & 0 deletions Samples/assets/shader_pixel_with_textures.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 330

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout(set=1, binding=2) uniform sampler2D _tex;
layout (location = 0) in vec2 fragTexCoord;
layout (location = 1) in vec4 fragColor;

layout (location = 0) out vec4 finalColor;

void main() {
vec4 texColor = texture(_tex, fragTexCoord);
finalColor = fragColor * texColor;
}
Binary file added Samples/assets/shader_pixel_with_textures.spv
Binary file not shown.
12 changes: 12 additions & 0 deletions Samples/assets/shader_pixel_without_textures.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#version 330

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout (location = 0) in vec2 fragTexCoord;
layout (location = 1) in vec4 fragColor;
layout (location = 0) out vec4 finalColor;

void main() {
finalColor = fragColor;
}
Binary file added Samples/assets/shader_pixel_without_textures.spv
Binary file not shown.
Binary file added Samples/assets/shader_vertex.spv
Binary file not shown.
25 changes: 25 additions & 0 deletions Samples/assets/shader_vertex.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#version 330

#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout(set=0, binding=1) uniform UserData
{
mat4 m_transform;
vec2 m_translate;
} userdata;

layout (location = 0) in vec2 inPosition;
layout (location = 1) in vec4 inColor0;
layout (location = 2) in vec2 inTexCoord0;

layout (location = 0) out vec2 fragTexCoord;
layout (location = 1) out vec4 fragColor;

void main() {
fragTexCoord = inTexCoord0;
fragColor = inColor0;
vec2 translatedPos = inPosition + userdata.m_translate.xy;
vec4 outPos = userdata.m_transform * vec4(translatedPos, 0, 1);
gl_Position = outPos;
}
9 changes: 7 additions & 2 deletions Samples/basic/loaddocument/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <Input.h>
#include <Shell.h>
#include <ShellRenderInterfaceOpenGL.h>
#include <ShellRenderInterfaceVulkan.h>

Rml::Context* context = nullptr;

Expand Down Expand Up @@ -70,7 +71,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
int window_height = 768;

ShellRenderInterfaceOpenGL opengl_renderer;
shell_renderer = &opengl_renderer;
ShellRenderInterfaceVulkan vulkan_renderer;

shell_renderer = &vulkan_renderer;
// shell_renderer = &opengl_renderer;

// Generic OS initialisation, creates a window and attaches OpenGL.
if (!Shell::Initialise() ||
Expand All @@ -81,7 +85,8 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
}

// RmlUi initialisation.
Rml::SetRenderInterface(&opengl_renderer);
Rml::SetRenderInterface(&vulkan_renderer);
// Rml::SetRenderInterface(&opengl_renderer);
shell_renderer->SetViewport(window_width, window_height);

ShellSystemInterface system_interface;
Expand Down
11 changes: 9 additions & 2 deletions Samples/basic/treeview/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <Input.h>
#include <Shell.h>
#include <ShellRenderInterfaceOpenGL.h>
#include <ShellRenderInterfaceVulkan.h>
#include "FileBrowser.h"

Rml::Context* context = nullptr;
Expand Down Expand Up @@ -71,7 +72,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
int window_height = 768;

ShellRenderInterfaceOpenGL opengl_renderer;
shell_renderer = &opengl_renderer;
ShellRenderInterfaceVulkan vulkan_renderer;
Rml::RenderInterface* p_renderer = &vulkan_renderer;
//shell_renderer = &opengl_renderer;
shell_renderer = &vulkan_renderer;

// Generic OS initialisation, creates a window and attaches OpenGL.
if (!Shell::Initialise() ||
Expand All @@ -82,8 +86,11 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
}

// RmlUi initialisation.
Rml::SetRenderInterface(&opengl_renderer);
// Rml::SetRenderInterface(&opengl_renderer);

Rml::SetRenderInterface(p_renderer);
opengl_renderer.SetViewport(window_width, window_height);
vulkan_renderer.SetViewport(window_width, window_height);

ShellSystemInterface system_interface;
Rml::SetSystemInterface(&system_interface);
Expand Down
13 changes: 8 additions & 5 deletions Samples/invaders/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <RmlUi/Debugger.h>
#include <Shell.h>
#include <ShellRenderInterfaceOpenGL.h>
#include <ShellRenderInterfaceVulkan.h>
#include <Input.h>
#include "DecoratorInstancerDefender.h"
#include "DecoratorInstancerStarfield.h"
Expand Down Expand Up @@ -78,9 +79,10 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
int window_width = 1024;
int window_height = 768;

ShellRenderInterfaceOpenGL opengl_renderer;
shell_renderer = &opengl_renderer;

//ShellRenderInterfaceOpenGL opengl_renderer;
ShellRenderInterfaceVulkan vulkan_renderer;
//shell_renderer = &opengl_renderer;
shell_renderer = &vulkan_renderer;
// Generic OS initialisation, creates a window and attaches OpenGL.
if (!Shell::Initialise() ||
!Shell::OpenWindow("RmlUi Invaders from Mars", shell_renderer, window_width, window_height, false))
Expand All @@ -90,8 +92,9 @@ int main(int RMLUI_UNUSED_PARAMETER(argc), char** RMLUI_UNUSED_PARAMETER(argv))
}

// RmlUi initialisation.
Rml::SetRenderInterface(&opengl_renderer);
opengl_renderer.SetViewport(window_width, window_height);
//Rml::SetRenderInterface(&opengl_renderer);
Rml::SetRenderInterface(&vulkan_renderer);
shell_renderer->SetViewport(window_width, window_height);

ShellSystemInterface system_interface;
Rml::SetSystemInterface(&system_interface);
Expand Down
5 changes: 5 additions & 0 deletions Samples/shell/include/ShellOpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@

#if defined RMLUI_PLATFORM_WIN32
#include "win32/IncludeWindows.h"

#define VK_USE_PLATFORM_WIN32_KHR
#include <vulkan/vulkan.h>

#include <gl/Gl.h>
#include <gl/Glu.h>

#elif defined RMLUI_PLATFORM_MACOSX
#include <AGL/agl.h>
#include <OpenGL/gl.h>
Expand Down
Loading