new structure complete
This commit is contained in:
commit
e7d0bc8f8e
69 changed files with 141 additions and 2733 deletions
|
|
@ -24,9 +24,5 @@ for(uint32_t x = 0; x < 1280; x++) {
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[WindowWaylandWayland](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandWayland.html)
|
|
||||||
|
|
|
||||||
|
|
@ -1,41 +1,18 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
import Crafter.Graphics;
|
import Crafter.Graphics;
|
||||||
|
import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
WindowWaylandWayland window("HelloWindow", 1280, 720);
|
WindowWaylandWayland window("HelloWindow", 1280, 720);
|
||||||
|
|
||||||
// for(uint32_t x = 0; x < 1280; x++) {
|
for(uint32_t x = 0; x < 1280; x++) {
|
||||||
// for(uint32_t y = 0; y < 720; y++) {
|
for(uint32_t y = 0; y < 720; y++) {
|
||||||
// window.framebuffer[x*720+y].r = 255;
|
window.framebuffer[x*720+y].r = 255;
|
||||||
// window.framebuffer[x*720+y].g = 0;
|
window.framebuffer[x*720+y].g = 0;
|
||||||
// window.framebuffer[x*720+y].b = 0;
|
window.framebuffer[x*720+y].b = 0;
|
||||||
// window.framebuffer[x*720+y].a = 255;
|
window.framebuffer[x*720+y].a = 255;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
|
||||||
|
|
||||||
//Semi transparant version:
|
//Semi transparant version:
|
||||||
// for(uint32_t x = 0; x < 1280; x++) {
|
// for(uint32_t x = 0; x < 1280; x++) {
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,12 @@
|
||||||
"name": "crafter-graphics",
|
"name": "crafter-graphics",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "example",
|
"name": "executable",
|
||||||
"standard": "c++26",
|
"implementations": ["main"],
|
||||||
"source_files": ["main"],
|
|
||||||
"module_files": [],
|
|
||||||
"build_dir": "build",
|
|
||||||
"output_dir": "bin",
|
|
||||||
"type":"executable",
|
|
||||||
"libs": [],
|
|
||||||
"flags": ["-Wno-uninitialized"],
|
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"path":"../../project.json",
|
"path":"../../project.json",
|
||||||
"configuration":"lib-debug"
|
"configuration":"lib-wayland"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,5 @@ EventListener<char> anyKeyListener(&window.onAnyKeyDown, [](char key){
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[Window](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1Window.html)
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,6 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <format>
|
|
||||||
|
|
||||||
import Crafter.Graphics;
|
import Crafter.Graphics;
|
||||||
//Needed for events
|
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
|
import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,12 @@
|
||||||
"name": "crafter-graphics",
|
"name": "crafter-graphics",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "example",
|
"name": "executable",
|
||||||
"standard": "c++26",
|
"implementations": ["main"],
|
||||||
"source_files": ["main"],
|
|
||||||
"module_files": [],
|
|
||||||
"build_dir": "build",
|
|
||||||
"output_dir": "bin",
|
|
||||||
"type":"executable",
|
|
||||||
"libs": [],
|
|
||||||
"flags": ["-Wno-uninitialized"],
|
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"path":"../../project.json",
|
"path":"../../project.json",
|
||||||
"configuration":"lib-debug"
|
"configuration":"lib-wayland"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,9 +28,5 @@ UiElement& element = window.elements.emplace_back(
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[UiElement](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1UiElement.html)
|
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,6 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import Crafter.Graphics;
|
import Crafter.Graphics;
|
||||||
|
import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,12 @@
|
||||||
"name": "crafter-graphics",
|
"name": "crafter-graphics",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "example",
|
"name": "executable",
|
||||||
"standard": "c++26",
|
"implementations": ["main"],
|
||||||
"source_files": ["main"],
|
|
||||||
"module_files": [],
|
|
||||||
"build_dir": "build",
|
|
||||||
"output_dir": "bin",
|
|
||||||
"type":"executable",
|
|
||||||
"libs": [],
|
|
||||||
"flags": ["-Wno-uninitialized"],
|
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"path":"../../project.json",
|
"path":"../../project.json",
|
||||||
"configuration":"lib-debug"
|
"configuration":"lib-wayland"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,5 @@ window.StartSync();
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[WindowWaylandWayland](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandWayland.html)
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,5 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Crafter.Graphics;
|
import Crafter.Graphics;
|
||||||
|
import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
|
||||||
|
|
@ -2,19 +2,12 @@
|
||||||
"name": "crafter-graphics",
|
"name": "crafter-graphics",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "example",
|
"name": "executable",
|
||||||
"standard": "c++26",
|
"implementations": ["main"],
|
||||||
"source_files": ["main"],
|
|
||||||
"module_files": [],
|
|
||||||
"build_dir": "build",
|
|
||||||
"output_dir": "bin",
|
|
||||||
"type":"executable",
|
|
||||||
"libs": [],
|
|
||||||
"flags": ["-Wno-uninitialized"],
|
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"path":"../../project.json",
|
"path":"../../project.json",
|
||||||
"configuration":"lib-debug"
|
"configuration":"lib-wayland"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ Here you'll find a variety of demos to help you learn and experiment with the fe
|
||||||
## Getting Started
|
## Getting Started
|
||||||
To run any example, navigate into its folder and use the following command:
|
To run any example, navigate into its folder and use the following command:
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Hello Series
|
## Hello Series
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,5 @@ camera.Update();
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[Camera](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1Mesh.html)
|
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,5 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
//required for the camera matrix.
|
|
||||||
import Crafter.Math;
|
import Crafter.Math;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import Crafter.Graphics;
|
import Crafter.Graphics;
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,5 @@ class CustomShader {
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[DescriptorSet](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1DescriptorSet.html)
|
|
||||||
[VulkanShader](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanShader.html)
|
|
||||||
|
|
|
||||||
|
|
@ -1,31 +1,11 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
#include "../../lib/VulkanInitializers.hpp"
|
||||||
#include <cstring>
|
|
||||||
#include <vector>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
//required for the camera matrix.
|
//required for the camera matrix.
|
||||||
import Crafter.Math;
|
import Crafter.Math;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
|
import std;
|
||||||
import Crafter.Graphics;
|
import Crafter.Graphics;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
|
|
@ -44,7 +24,7 @@ class CustomShader {
|
||||||
Initialze our buffer as shader visible storage buffer with the size of the colors vector.
|
Initialze our buffer as shader visible storage buffer with the size of the colors vector.
|
||||||
*/
|
*/
|
||||||
CustomShader(const std::vector<Vector<float, 4>>& colors) : colors(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, colors.size()) {
|
CustomShader(const std::vector<Vector<float, 4>>& colors) : colors(VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, colors.size()) {
|
||||||
memcpy(this->colors.value, colors.data(), colors.size()*sizeof(Vector<float, 4>));
|
std::memcpy(this->colors.value, colors.data(), colors.size()*sizeof(Vector<float, 4>));
|
||||||
}
|
}
|
||||||
void WriteDescriptors(VkDescriptorSet set) {
|
void WriteDescriptors(VkDescriptorSet set) {
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,5 @@ EventListener<VkCommandBuffer> listener(&window.onDraw, [&descriptors, &meshShad
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[DescriptorSet](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1DescriptorSet.html)
|
|
||||||
[Mesh](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1Mesh.html)
|
|
||||||
[MeshShader](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1MeshShader.html)
|
|
||||||
[VulkanShader](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanShader.html)
|
|
||||||
[VulkanPipeline](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanPipeline.html)
|
|
||||||
[WindowWaylandVulkan](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandVulkan.html)
|
|
||||||
|
|
@ -1,23 +1,3 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,5 @@ window.StartSync();
|
||||||
## How to Run
|
## How to Run
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
crafter-build -c example -r
|
crafter-build build executable -r
|
||||||
```
|
```
|
||||||
|
|
||||||
## Relevant documentation
|
|
||||||
|
|
||||||
[VulkanDevice](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1VulkanDevice.html)
|
|
||||||
[WindowWaylandVulkan](https://crafter-graphics.docs.catcrafts.net/classCrafter_1_1WindowWaylandVulkan.html)
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,3 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
import Crafter.Graphics;
|
import Crafter.Graphics;
|
||||||
|
|
|
||||||
|
|
@ -20,12 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <iostream>
|
|
||||||
#include <format>
|
|
||||||
|
|
||||||
module Crafter.Graphics;
|
module Crafter.Graphics:Camera_impl;
|
||||||
|
import :Camera;
|
||||||
import Crafter.Math;
|
import Crafter.Math;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
@ -18,11 +18,10 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
module Crafter.Graphics:UiElement_impl;
|
||||||
|
import :UiElement;
|
||||||
|
import std;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
module Crafter.Graphics;
|
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), absoluteWidth(absoluteWidth), absoluteHeight(absoluteHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), useRelativeSize(false), ignoreScaling(ignoreScaling) {
|
UiElement::UiElement(float anchorX, float anchorY, std::uint32_t bufferWidth, std::uint32_t bufferHeight, std::uint32_t absoluteWidth, std::uint32_t absoluteHeight, float anchorOffsetX, float anchorOffsetY, float z, bool ignoreScaling) : anchorX(anchorX), anchorY(anchorY), bufferWidth(bufferWidth), bufferHeight(bufferHeight), absoluteWidth(absoluteWidth), absoluteHeight(absoluteHeight), anchorOffsetX(anchorOffsetX), anchorOffsetY(anchorOffsetY), z(z), buffer(bufferWidth*bufferHeight), useRelativeSize(false), ignoreScaling(ignoreScaling) {
|
||||||
|
|
@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_wayland.h>
|
#include <vulkan/vulkan_wayland.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -33,7 +32,9 @@ module;
|
||||||
|
|
||||||
#define GET_EXTENSION_FUNCTION(_id) ((PFN_##_id)(vkGetInstanceProcAddr(instance, #_id)))
|
#define GET_EXTENSION_FUNCTION(_id) ((PFN_##_id)(vkGetInstanceProcAddr(instance, #_id)))
|
||||||
|
|
||||||
module Crafter.Graphics;
|
module Crafter.Graphics:VulkanDevice_impl;
|
||||||
|
import :VulkanDevice;
|
||||||
|
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
const char* const instanceExtensionNames[] = {
|
const char* const instanceExtensionNames[] = {
|
||||||
"VK_EXT_debug_utils",
|
"VK_EXT_debug_utils",
|
||||||
|
|
@ -23,7 +23,8 @@ module;
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
module Crafter.Graphics;
|
module Crafter.Graphics:Window_impl;
|
||||||
|
import :Window;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
|
|
@ -23,41 +23,27 @@ module;
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <string>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wayland-cursor.h>
|
#include <wayland-cursor.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_wayland.h>
|
#include <vulkan/vulkan_wayland.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <cstring>
|
|
||||||
#include "../../lib/xdg-shell-client-protocol.h"
|
|
||||||
#include "../../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <print>
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-client-protocol.h>
|
#include <wayland-client-protocol.h>
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#include <cmath>
|
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include <cstdio>
|
#include "../lib/xdg-shell-client-protocol.h"
|
||||||
|
#include "../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
module Crafter.Graphics;
|
module Crafter.Graphics:WindowWayland_impl;
|
||||||
|
import :WindowWayland;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
|
|
@ -20,20 +20,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_wayland.h>
|
#include <vulkan/vulkan_wayland.h>
|
||||||
#include <vector>
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <thread>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cassert>
|
|
||||||
#include <exception>
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
#include "../../lib/VulkanTransition.hpp"
|
|
||||||
|
|
||||||
module Crafter.Graphics;
|
module Crafter.Graphics;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
|
|
@ -23,39 +23,32 @@ module;
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <string>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wayland-cursor.h>
|
#include <wayland-cursor.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include <iostream>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_wayland.h>
|
#include <vulkan/vulkan_wayland.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <cstring>
|
|
||||||
#include "../../lib/xdg-shell-client-protocol.h"
|
|
||||||
#include "../../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
#include <print>
|
#include <print>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include <wayland-client-protocol.h>
|
#include <wayland-client-protocol.h>
|
||||||
#include <linux/input-event-codes.h>
|
#include <linux/input-event-codes.h>
|
||||||
#include <cmath>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
module Crafter.Graphics;
|
export module Crafter.Graphics:WindowWaylandWayland_impl;
|
||||||
|
import :WindowWaylandWayland;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
|
|
@ -18,12 +18,8 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Camera;
|
export module Crafter.Graphics:Camera;
|
||||||
import :VulkanBuffer;
|
import std;
|
||||||
import Crafter.Math;
|
import Crafter.Math;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
|
|
||||||
|
|
@ -58,6 +54,6 @@ namespace Crafter {
|
||||||
* @param y The y-coordinate on the screen (in pixels).
|
* @param y The y-coordinate on the screen (in pixels).
|
||||||
* @return A normalized 3D direction vector representing the ray from the camera.
|
* @return A normalized 3D direction vector representing the ray from the camera.
|
||||||
*/
|
*/
|
||||||
Vector<float, 3> ToRay(uint32_t x, uint32_t y);
|
Vector<float, 3> ToRay(std::uint32_t x, std::uint32_t y);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -20,14 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
|
|
||||||
export module Crafter.Graphics:DescriptorSet;
|
export module Crafter.Graphics:DescriptorSet;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import :VulkanDevice;
|
import :VulkanDevice;
|
||||||
import :VulkanShader;
|
import :VulkanShader;
|
||||||
|
|
@ -20,14 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
|
|
||||||
export module Crafter.Graphics:HeightmapShader;
|
export module Crafter.Graphics:HeightmapShader;
|
||||||
|
import std;
|
||||||
import :Camera;
|
import :Camera;
|
||||||
import :VulkanPipeline;
|
import :VulkanPipeline;
|
||||||
import :DescriptorSet;
|
import :DescriptorSet;
|
||||||
|
|
@ -20,12 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Mesh;
|
export module Crafter.Graphics:Mesh;
|
||||||
|
import std;
|
||||||
import Crafter.Math;
|
import Crafter.Math;
|
||||||
import :VulkanBuffer;
|
import :VulkanBuffer;
|
||||||
import :Types;
|
import :Types;
|
||||||
|
|
@ -20,14 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
|
|
||||||
export module Crafter.Graphics:MeshShader;
|
export module Crafter.Graphics:MeshShader;
|
||||||
|
import std;
|
||||||
import :Mesh;
|
import :Mesh;
|
||||||
import :Camera;
|
import :Camera;
|
||||||
import :VulkanPipeline;
|
import :VulkanPipeline;
|
||||||
|
|
@ -20,13 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
|
|
||||||
export module Crafter.Graphics:TextureShader;
|
export module Crafter.Graphics:TextureShader;
|
||||||
|
import std;
|
||||||
import :VulkanTexture;
|
import :VulkanTexture;
|
||||||
import :VulkanPipeline;
|
import :VulkanPipeline;
|
||||||
import :DescriptorSet;
|
import :DescriptorSet;
|
||||||
|
|
@ -18,11 +18,8 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Types;
|
export module Crafter.Graphics:Types;
|
||||||
|
import std;
|
||||||
|
|
||||||
namespace Crafter {
|
namespace Crafter {
|
||||||
export struct MousePoint {
|
export struct MousePoint {
|
||||||
|
|
@ -18,12 +18,8 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:UiElement;
|
export module Crafter.Graphics:UiElement;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import :Types;
|
import :Types;
|
||||||
|
|
||||||
|
|
@ -18,16 +18,10 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
#include <cmath>
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
|
|
||||||
export module Crafter.Graphics:VoxelShader;
|
export module Crafter.Graphics:VoxelShader;
|
||||||
|
import std;
|
||||||
import :Mesh;
|
import :Mesh;
|
||||||
import :Camera;
|
import :Camera;
|
||||||
import :VulkanPipeline;
|
import :VulkanPipeline;
|
||||||
|
|
@ -18,13 +18,10 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
|
|
||||||
export module Crafter.Graphics:VulkanBuffer;
|
export module Crafter.Graphics:VulkanBuffer;
|
||||||
|
import std;
|
||||||
import :VulkanDevice;
|
import :VulkanDevice;
|
||||||
|
|
||||||
namespace Crafter {
|
namespace Crafter {
|
||||||
|
|
@ -18,13 +18,11 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_wayland.h>
|
#include <vulkan/vulkan_wayland.h>
|
||||||
|
|
||||||
export module Crafter.Graphics:VulkanDevice;
|
export module Crafter.Graphics:VulkanDevice;
|
||||||
|
import std;
|
||||||
|
|
||||||
export namespace Crafter {
|
export namespace Crafter {
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,13 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <array>
|
|
||||||
#include "../../lib/VulkanInitializers.hpp"
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:VulkanPipeline;
|
export module Crafter.Graphics:VulkanPipeline;
|
||||||
|
import std;
|
||||||
import :VulkanDevice;
|
import :VulkanDevice;
|
||||||
import :VulkanShader;
|
import :VulkanShader;
|
||||||
import :WindowWaylandVulkan;
|
import :WindowWaylandVulkan;
|
||||||
|
|
@ -20,15 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <fstream>
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vector>
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:VulkanShader;
|
export module Crafter.Graphics:VulkanShader;
|
||||||
|
import std;
|
||||||
import :VulkanDevice;
|
import :VulkanDevice;
|
||||||
|
|
||||||
namespace Crafter {
|
namespace Crafter {
|
||||||
|
|
@ -20,12 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <cstring>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:VulkanTexture;
|
export module Crafter.Graphics:VulkanTexture;
|
||||||
|
import std;
|
||||||
import :VulkanDevice;
|
import :VulkanDevice;
|
||||||
import :VulkanBuffer;
|
import :VulkanBuffer;
|
||||||
|
|
||||||
|
|
@ -18,23 +18,18 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Window;
|
export module Crafter.Graphics:Window;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import :UiElement;
|
import :UiElement;
|
||||||
import :Types;
|
import :Types;
|
||||||
|
|
||||||
export namespace Crafter {
|
export namespace Crafter {
|
||||||
struct ScaleData {
|
struct ScaleData {
|
||||||
int32_t x;
|
std::int32_t x;
|
||||||
int32_t y;
|
std::int32_t y;
|
||||||
int32_t width;
|
std::int32_t width;
|
||||||
int32_t height;
|
std::int32_t height;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -20,13 +20,13 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
#include "../../lib/xdg-shell-client-protocol.h"
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include "../../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
#include "../lib/xdg-shell-client-protocol.h"
|
||||||
|
#include "../lib/wayland-xdg-decoration-unstable-v1-client-protocol.h"
|
||||||
|
|
||||||
export module Crafter.Graphics:WindowWayland;
|
export module Crafter.Graphics:WindowWayland;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import :UiElement;
|
import :UiElement;
|
||||||
import :Types;
|
import :Types;
|
||||||
|
|
@ -20,14 +20,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
module;
|
module;
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_wayland.h>
|
#include <vulkan/vulkan_wayland.h>
|
||||||
#include <vector>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:WindowWaylandVulkan;
|
export module Crafter.Graphics:WindowWaylandVulkan;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import :WindowWayland;
|
import :WindowWayland;
|
||||||
|
|
||||||
|
|
@ -18,13 +18,8 @@ License along with this library; if not, write to the Free Software
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:WindowWaylandWayland;
|
export module Crafter.Graphics:WindowWaylandWayland;
|
||||||
|
import std;
|
||||||
import Crafter.Event;
|
import Crafter.Event;
|
||||||
import :WindowWayland;
|
import :WindowWayland;
|
||||||
|
|
||||||
|
|
@ -39,7 +34,7 @@ export namespace Crafter {
|
||||||
/**
|
/**
|
||||||
* @brief Framebuffer for the window using the BGRA 8-bit unsigned pixel format, use this for direct drawing to the window.
|
* @brief Framebuffer for the window using the BGRA 8-bit unsigned pixel format, use this for direct drawing to the window.
|
||||||
*/
|
*/
|
||||||
Pixel_BU8_GU8_RU8_AU8* framebuffer = NULL;
|
Pixel_BU8_GU8_RU8_AU8* framebuffer = nullptr;
|
||||||
/**
|
/**
|
||||||
* @brief Constructs a new WindowWaylandWayland object.
|
* @brief Constructs a new WindowWaylandWayland object.
|
||||||
*
|
*
|
||||||
|
|
@ -23,18 +23,19 @@ export module Crafter.Graphics;
|
||||||
export import :Window;
|
export import :Window;
|
||||||
export import :WindowWayland;
|
export import :WindowWayland;
|
||||||
export import :WindowWaylandWayland;
|
export import :WindowWaylandWayland;
|
||||||
export import :WindowWaylandVulkan;
|
|
||||||
export import :UiElement;
|
export import :UiElement;
|
||||||
export import :Types;
|
export import :Types;
|
||||||
export import :VulkanDevice;
|
|
||||||
export import :VulkanPipeline;
|
|
||||||
export import :VulkanShader;
|
|
||||||
export import :Camera;
|
export import :Camera;
|
||||||
export import :VulkanBuffer;
|
|
||||||
export import :VoxelShader;
|
// export import :WindowWaylandVulkan;
|
||||||
export import :Mesh;
|
// export import :VulkanBuffer;
|
||||||
export import :MeshShader;
|
// export import :VoxelShader;
|
||||||
export import :VulkanTexture;
|
// export import :Mesh;
|
||||||
export import :TextureShader;
|
// export import :MeshShader;
|
||||||
export import :DescriptorSet;
|
// export import :VulkanTexture;
|
||||||
export import :HeightmapShader;
|
// export import :TextureShader;
|
||||||
|
// export import :DescriptorSet;
|
||||||
|
// export import :HeightmapShader;
|
||||||
|
// export import :VulkanDevice;
|
||||||
|
// export import :VulkanPipeline;
|
||||||
|
// export import :VulkanShader;
|
||||||
|
|
@ -1,660 +0,0 @@
|
||||||
/*
|
|
||||||
* Initializers for Vulkan structures and objects used by the examples
|
|
||||||
* Saves lot of VK_STRUCTURE_TYPE assignments
|
|
||||||
* Some initializers are parameterized for convenience
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016 by Sascha Willems - www.saschawillems.de
|
|
||||||
*
|
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include "vulkan/vulkan.h"
|
|
||||||
|
|
||||||
namespace vks
|
|
||||||
{
|
|
||||||
namespace initializers
|
|
||||||
{
|
|
||||||
|
|
||||||
inline VkMemoryAllocateInfo memoryAllocateInfo()
|
|
||||||
{
|
|
||||||
VkMemoryAllocateInfo memAllocInfo {};
|
|
||||||
memAllocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
||||||
return memAllocInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkMappedMemoryRange mappedMemoryRange()
|
|
||||||
{
|
|
||||||
VkMappedMemoryRange mappedMemoryRange {};
|
|
||||||
mappedMemoryRange.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
|
||||||
return mappedMemoryRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkCommandBufferAllocateInfo commandBufferAllocateInfo(
|
|
||||||
VkCommandPool commandPool,
|
|
||||||
VkCommandBufferLevel level,
|
|
||||||
uint32_t bufferCount)
|
|
||||||
{
|
|
||||||
VkCommandBufferAllocateInfo commandBufferAllocateInfo {};
|
|
||||||
commandBufferAllocateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
|
||||||
commandBufferAllocateInfo.commandPool = commandPool;
|
|
||||||
commandBufferAllocateInfo.level = level;
|
|
||||||
commandBufferAllocateInfo.commandBufferCount = bufferCount;
|
|
||||||
return commandBufferAllocateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkCommandPoolCreateInfo commandPoolCreateInfo()
|
|
||||||
{
|
|
||||||
VkCommandPoolCreateInfo cmdPoolCreateInfo {};
|
|
||||||
cmdPoolCreateInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
|
|
||||||
return cmdPoolCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkCommandBufferBeginInfo commandBufferBeginInfo()
|
|
||||||
{
|
|
||||||
VkCommandBufferBeginInfo cmdBufferBeginInfo {};
|
|
||||||
cmdBufferBeginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
|
|
||||||
return cmdBufferBeginInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkCommandBufferInheritanceInfo commandBufferInheritanceInfo()
|
|
||||||
{
|
|
||||||
VkCommandBufferInheritanceInfo cmdBufferInheritanceInfo {};
|
|
||||||
cmdBufferInheritanceInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO;
|
|
||||||
return cmdBufferInheritanceInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkRenderPassBeginInfo renderPassBeginInfo()
|
|
||||||
{
|
|
||||||
VkRenderPassBeginInfo renderPassBeginInfo {};
|
|
||||||
renderPassBeginInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
|
|
||||||
return renderPassBeginInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkRenderPassCreateInfo renderPassCreateInfo()
|
|
||||||
{
|
|
||||||
VkRenderPassCreateInfo renderPassCreateInfo {};
|
|
||||||
renderPassCreateInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
|
||||||
return renderPassCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Initialize an image memory barrier with no image transfer ownership */
|
|
||||||
inline VkImageMemoryBarrier imageMemoryBarrier()
|
|
||||||
{
|
|
||||||
VkImageMemoryBarrier imageMemoryBarrier {};
|
|
||||||
imageMemoryBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
|
||||||
imageMemoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
imageMemoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
return imageMemoryBarrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Initialize a buffer memory barrier with no image transfer ownership */
|
|
||||||
inline VkBufferMemoryBarrier bufferMemoryBarrier()
|
|
||||||
{
|
|
||||||
VkBufferMemoryBarrier bufferMemoryBarrier {};
|
|
||||||
bufferMemoryBarrier.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER;
|
|
||||||
bufferMemoryBarrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
bufferMemoryBarrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
return bufferMemoryBarrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkMemoryBarrier memoryBarrier()
|
|
||||||
{
|
|
||||||
VkMemoryBarrier memoryBarrier {};
|
|
||||||
memoryBarrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
|
|
||||||
return memoryBarrier;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkImageCreateInfo imageCreateInfo()
|
|
||||||
{
|
|
||||||
VkImageCreateInfo imageCreateInfo {};
|
|
||||||
imageCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
|
||||||
return imageCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkSamplerCreateInfo samplerCreateInfo()
|
|
||||||
{
|
|
||||||
VkSamplerCreateInfo samplerCreateInfo {};
|
|
||||||
samplerCreateInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
|
|
||||||
samplerCreateInfo.maxAnisotropy = 1.0f;
|
|
||||||
return samplerCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkImageViewCreateInfo imageViewCreateInfo()
|
|
||||||
{
|
|
||||||
VkImageViewCreateInfo imageViewCreateInfo {};
|
|
||||||
imageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
|
||||||
return imageViewCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkFramebufferCreateInfo framebufferCreateInfo()
|
|
||||||
{
|
|
||||||
VkFramebufferCreateInfo framebufferCreateInfo {};
|
|
||||||
framebufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
|
||||||
return framebufferCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkSemaphoreCreateInfo semaphoreCreateInfo()
|
|
||||||
{
|
|
||||||
VkSemaphoreCreateInfo semaphoreCreateInfo {};
|
|
||||||
semaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
|
||||||
return semaphoreCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkFenceCreateInfo fenceCreateInfo(VkFenceCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkFenceCreateInfo fenceCreateInfo {};
|
|
||||||
fenceCreateInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
|
|
||||||
fenceCreateInfo.flags = flags;
|
|
||||||
return fenceCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkEventCreateInfo eventCreateInfo()
|
|
||||||
{
|
|
||||||
VkEventCreateInfo eventCreateInfo {};
|
|
||||||
eventCreateInfo.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO;
|
|
||||||
return eventCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkSubmitInfo submitInfo()
|
|
||||||
{
|
|
||||||
VkSubmitInfo submitInfo {};
|
|
||||||
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
|
||||||
return submitInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkViewport viewport(
|
|
||||||
float width,
|
|
||||||
float height,
|
|
||||||
float minDepth,
|
|
||||||
float maxDepth)
|
|
||||||
{
|
|
||||||
VkViewport viewport {};
|
|
||||||
viewport.width = width;
|
|
||||||
viewport.height = height;
|
|
||||||
viewport.minDepth = minDepth;
|
|
||||||
viewport.maxDepth = maxDepth;
|
|
||||||
return viewport;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkRect2D rect2D(
|
|
||||||
int32_t width,
|
|
||||||
int32_t height,
|
|
||||||
int32_t offsetX,
|
|
||||||
int32_t offsetY)
|
|
||||||
{
|
|
||||||
VkRect2D rect2D {};
|
|
||||||
rect2D.extent.width = width;
|
|
||||||
rect2D.extent.height = height;
|
|
||||||
rect2D.offset.x = offsetX;
|
|
||||||
rect2D.offset.y = offsetY;
|
|
||||||
return rect2D;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkBufferCreateInfo bufferCreateInfo()
|
|
||||||
{
|
|
||||||
VkBufferCreateInfo bufCreateInfo {};
|
|
||||||
bufCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
|
||||||
return bufCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkBufferCreateInfo bufferCreateInfo(
|
|
||||||
VkBufferUsageFlags usage,
|
|
||||||
VkDeviceSize size)
|
|
||||||
{
|
|
||||||
VkBufferCreateInfo bufCreateInfo {};
|
|
||||||
bufCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
|
|
||||||
bufCreateInfo.usage = usage;
|
|
||||||
bufCreateInfo.size = size;
|
|
||||||
return bufCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorPoolCreateInfo descriptorPoolCreateInfo(
|
|
||||||
uint32_t poolSizeCount,
|
|
||||||
VkDescriptorPoolSize* pPoolSizes,
|
|
||||||
uint32_t maxSets)
|
|
||||||
{
|
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo {};
|
|
||||||
descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
|
||||||
descriptorPoolInfo.poolSizeCount = poolSizeCount;
|
|
||||||
descriptorPoolInfo.pPoolSizes = pPoolSizes;
|
|
||||||
descriptorPoolInfo.maxSets = maxSets;
|
|
||||||
return descriptorPoolInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorPoolCreateInfo descriptorPoolCreateInfo(
|
|
||||||
const std::vector<VkDescriptorPoolSize>& poolSizes,
|
|
||||||
uint32_t maxSets)
|
|
||||||
{
|
|
||||||
VkDescriptorPoolCreateInfo descriptorPoolInfo{};
|
|
||||||
descriptorPoolInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
|
|
||||||
descriptorPoolInfo.poolSizeCount = static_cast<uint32_t>(poolSizes.size());
|
|
||||||
descriptorPoolInfo.pPoolSizes = poolSizes.data();
|
|
||||||
descriptorPoolInfo.maxSets = maxSets;
|
|
||||||
return descriptorPoolInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorPoolSize descriptorPoolSize(
|
|
||||||
VkDescriptorType type,
|
|
||||||
uint32_t descriptorCount)
|
|
||||||
{
|
|
||||||
VkDescriptorPoolSize descriptorPoolSize {};
|
|
||||||
descriptorPoolSize.type = type;
|
|
||||||
descriptorPoolSize.descriptorCount = descriptorCount;
|
|
||||||
return descriptorPoolSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorSetLayoutBinding descriptorSetLayoutBinding(
|
|
||||||
VkDescriptorType type,
|
|
||||||
VkShaderStageFlags stageFlags,
|
|
||||||
uint32_t binding,
|
|
||||||
uint32_t descriptorCount = 1)
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayoutBinding setLayoutBinding {};
|
|
||||||
setLayoutBinding.descriptorType = type;
|
|
||||||
setLayoutBinding.stageFlags = stageFlags;
|
|
||||||
setLayoutBinding.binding = binding;
|
|
||||||
setLayoutBinding.descriptorCount = descriptorCount;
|
|
||||||
return setLayoutBinding;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo(
|
|
||||||
const VkDescriptorSetLayoutBinding* pBindings,
|
|
||||||
uint32_t bindingCount)
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo {};
|
|
||||||
descriptorSetLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
||||||
descriptorSetLayoutCreateInfo.pBindings = pBindings;
|
|
||||||
descriptorSetLayoutCreateInfo.bindingCount = bindingCount;
|
|
||||||
return descriptorSetLayoutCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo(
|
|
||||||
const std::vector<VkDescriptorSetLayoutBinding>& bindings)
|
|
||||||
{
|
|
||||||
VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo{};
|
|
||||||
descriptorSetLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
|
||||||
descriptorSetLayoutCreateInfo.pBindings = bindings.data();
|
|
||||||
descriptorSetLayoutCreateInfo.bindingCount = static_cast<uint32_t>(bindings.size());
|
|
||||||
return descriptorSetLayoutCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo(
|
|
||||||
const VkDescriptorSetLayout* pSetLayouts,
|
|
||||||
uint32_t setLayoutCount = 1)
|
|
||||||
{
|
|
||||||
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo {};
|
|
||||||
pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
|
||||||
pipelineLayoutCreateInfo.setLayoutCount = setLayoutCount;
|
|
||||||
pipelineLayoutCreateInfo.pSetLayouts = pSetLayouts;
|
|
||||||
return pipelineLayoutCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo(
|
|
||||||
uint32_t setLayoutCount = 1)
|
|
||||||
{
|
|
||||||
VkPipelineLayoutCreateInfo pipelineLayoutCreateInfo{};
|
|
||||||
pipelineLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
|
|
||||||
pipelineLayoutCreateInfo.setLayoutCount = setLayoutCount;
|
|
||||||
return pipelineLayoutCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorSetAllocateInfo descriptorSetAllocateInfo(
|
|
||||||
VkDescriptorPool descriptorPool,
|
|
||||||
const VkDescriptorSetLayout* pSetLayouts,
|
|
||||||
uint32_t descriptorSetCount)
|
|
||||||
{
|
|
||||||
VkDescriptorSetAllocateInfo descriptorSetAllocateInfo {};
|
|
||||||
descriptorSetAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
|
|
||||||
descriptorSetAllocateInfo.descriptorPool = descriptorPool;
|
|
||||||
descriptorSetAllocateInfo.pSetLayouts = pSetLayouts;
|
|
||||||
descriptorSetAllocateInfo.descriptorSetCount = descriptorSetCount;
|
|
||||||
return descriptorSetAllocateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkDescriptorImageInfo descriptorImageInfo(VkSampler sampler, VkImageView imageView, VkImageLayout imageLayout)
|
|
||||||
{
|
|
||||||
VkDescriptorImageInfo descriptorImageInfo {};
|
|
||||||
descriptorImageInfo.sampler = sampler;
|
|
||||||
descriptorImageInfo.imageView = imageView;
|
|
||||||
descriptorImageInfo.imageLayout = imageLayout;
|
|
||||||
return descriptorImageInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkWriteDescriptorSet writeDescriptorSet(
|
|
||||||
VkDescriptorSet dstSet,
|
|
||||||
VkDescriptorType type,
|
|
||||||
uint32_t binding,
|
|
||||||
VkDescriptorBufferInfo* bufferInfo,
|
|
||||||
uint32_t descriptorCount = 1)
|
|
||||||
{
|
|
||||||
VkWriteDescriptorSet writeDescriptorSet {};
|
|
||||||
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
writeDescriptorSet.dstSet = dstSet;
|
|
||||||
writeDescriptorSet.descriptorType = type;
|
|
||||||
writeDescriptorSet.dstBinding = binding;
|
|
||||||
writeDescriptorSet.pBufferInfo = bufferInfo;
|
|
||||||
writeDescriptorSet.descriptorCount = descriptorCount;
|
|
||||||
return writeDescriptorSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkWriteDescriptorSet writeDescriptorSet(
|
|
||||||
VkDescriptorSet dstSet,
|
|
||||||
VkDescriptorType type,
|
|
||||||
uint32_t binding,
|
|
||||||
VkDescriptorImageInfo *imageInfo,
|
|
||||||
uint32_t descriptorCount = 1)
|
|
||||||
{
|
|
||||||
VkWriteDescriptorSet writeDescriptorSet {};
|
|
||||||
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
writeDescriptorSet.dstSet = dstSet;
|
|
||||||
writeDescriptorSet.descriptorType = type;
|
|
||||||
writeDescriptorSet.dstBinding = binding;
|
|
||||||
writeDescriptorSet.pImageInfo = imageInfo;
|
|
||||||
writeDescriptorSet.descriptorCount = descriptorCount;
|
|
||||||
return writeDescriptorSet;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkVertexInputBindingDescription vertexInputBindingDescription(
|
|
||||||
uint32_t binding,
|
|
||||||
uint32_t stride,
|
|
||||||
VkVertexInputRate inputRate)
|
|
||||||
{
|
|
||||||
VkVertexInputBindingDescription vInputBindDescription {};
|
|
||||||
vInputBindDescription.binding = binding;
|
|
||||||
vInputBindDescription.stride = stride;
|
|
||||||
vInputBindDescription.inputRate = inputRate;
|
|
||||||
return vInputBindDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkVertexInputAttributeDescription vertexInputAttributeDescription(
|
|
||||||
uint32_t binding,
|
|
||||||
uint32_t location,
|
|
||||||
VkFormat format,
|
|
||||||
uint32_t offset)
|
|
||||||
{
|
|
||||||
VkVertexInputAttributeDescription vInputAttribDescription {};
|
|
||||||
vInputAttribDescription.location = location;
|
|
||||||
vInputAttribDescription.binding = binding;
|
|
||||||
vInputAttribDescription.format = format;
|
|
||||||
vInputAttribDescription.offset = offset;
|
|
||||||
return vInputAttribDescription;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo()
|
|
||||||
{
|
|
||||||
VkPipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo {};
|
|
||||||
pipelineVertexInputStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
|
||||||
return pipelineVertexInputStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo(
|
|
||||||
const std::vector<VkVertexInputBindingDescription> &vertexBindingDescriptions,
|
|
||||||
const std::vector<VkVertexInputAttributeDescription> &vertexAttributeDescriptions
|
|
||||||
)
|
|
||||||
{
|
|
||||||
VkPipelineVertexInputStateCreateInfo pipelineVertexInputStateCreateInfo{};
|
|
||||||
pipelineVertexInputStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
|
|
||||||
pipelineVertexInputStateCreateInfo.vertexBindingDescriptionCount = static_cast<uint32_t>(vertexBindingDescriptions.size());
|
|
||||||
pipelineVertexInputStateCreateInfo.pVertexBindingDescriptions = vertexBindingDescriptions.data();
|
|
||||||
pipelineVertexInputStateCreateInfo.vertexAttributeDescriptionCount = static_cast<uint32_t>(vertexAttributeDescriptions.size());
|
|
||||||
pipelineVertexInputStateCreateInfo.pVertexAttributeDescriptions = vertexAttributeDescriptions.data();
|
|
||||||
return pipelineVertexInputStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateCreateInfo(
|
|
||||||
VkPrimitiveTopology topology,
|
|
||||||
VkPipelineInputAssemblyStateCreateFlags flags,
|
|
||||||
VkBool32 primitiveRestartEnable)
|
|
||||||
{
|
|
||||||
VkPipelineInputAssemblyStateCreateInfo pipelineInputAssemblyStateCreateInfo {};
|
|
||||||
pipelineInputAssemblyStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
|
|
||||||
pipelineInputAssemblyStateCreateInfo.topology = topology;
|
|
||||||
pipelineInputAssemblyStateCreateInfo.flags = flags;
|
|
||||||
pipelineInputAssemblyStateCreateInfo.primitiveRestartEnable = primitiveRestartEnable;
|
|
||||||
return pipelineInputAssemblyStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineRasterizationStateCreateInfo pipelineRasterizationStateCreateInfo(
|
|
||||||
VkPolygonMode polygonMode,
|
|
||||||
VkCullModeFlags cullMode,
|
|
||||||
VkFrontFace frontFace,
|
|
||||||
VkPipelineRasterizationStateCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkPipelineRasterizationStateCreateInfo pipelineRasterizationStateCreateInfo {};
|
|
||||||
pipelineRasterizationStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
|
|
||||||
pipelineRasterizationStateCreateInfo.polygonMode = polygonMode;
|
|
||||||
pipelineRasterizationStateCreateInfo.cullMode = cullMode;
|
|
||||||
pipelineRasterizationStateCreateInfo.frontFace = frontFace;
|
|
||||||
pipelineRasterizationStateCreateInfo.flags = flags;
|
|
||||||
pipelineRasterizationStateCreateInfo.depthClampEnable = VK_FALSE;
|
|
||||||
pipelineRasterizationStateCreateInfo.lineWidth = 1.0f;
|
|
||||||
return pipelineRasterizationStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineColorBlendAttachmentState pipelineColorBlendAttachmentState(
|
|
||||||
VkColorComponentFlags colorWriteMask,
|
|
||||||
VkBool32 blendEnable)
|
|
||||||
{
|
|
||||||
VkPipelineColorBlendAttachmentState pipelineColorBlendAttachmentState {};
|
|
||||||
pipelineColorBlendAttachmentState.colorWriteMask = colorWriteMask;
|
|
||||||
pipelineColorBlendAttachmentState.blendEnable = blendEnable;
|
|
||||||
return pipelineColorBlendAttachmentState;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo(
|
|
||||||
uint32_t attachmentCount,
|
|
||||||
const VkPipelineColorBlendAttachmentState * pAttachments)
|
|
||||||
{
|
|
||||||
VkPipelineColorBlendStateCreateInfo pipelineColorBlendStateCreateInfo {};
|
|
||||||
pipelineColorBlendStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
|
|
||||||
pipelineColorBlendStateCreateInfo.attachmentCount = attachmentCount;
|
|
||||||
pipelineColorBlendStateCreateInfo.pAttachments = pAttachments;
|
|
||||||
return pipelineColorBlendStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineDepthStencilStateCreateInfo pipelineDepthStencilStateCreateInfo(
|
|
||||||
VkBool32 depthTestEnable,
|
|
||||||
VkBool32 depthWriteEnable,
|
|
||||||
VkCompareOp depthCompareOp)
|
|
||||||
{
|
|
||||||
VkPipelineDepthStencilStateCreateInfo pipelineDepthStencilStateCreateInfo {};
|
|
||||||
pipelineDepthStencilStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
|
|
||||||
pipelineDepthStencilStateCreateInfo.depthTestEnable = depthTestEnable;
|
|
||||||
pipelineDepthStencilStateCreateInfo.depthWriteEnable = depthWriteEnable;
|
|
||||||
pipelineDepthStencilStateCreateInfo.depthCompareOp = depthCompareOp;
|
|
||||||
pipelineDepthStencilStateCreateInfo.back.compareOp = VK_COMPARE_OP_ALWAYS;
|
|
||||||
pipelineDepthStencilStateCreateInfo.stencilTestEnable = VK_FALSE;
|
|
||||||
return pipelineDepthStencilStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineViewportStateCreateInfo pipelineViewportStateCreateInfo(
|
|
||||||
uint32_t viewportCount,
|
|
||||||
uint32_t scissorCount,
|
|
||||||
VkPipelineViewportStateCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkPipelineViewportStateCreateInfo pipelineViewportStateCreateInfo {};
|
|
||||||
pipelineViewportStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
|
|
||||||
pipelineViewportStateCreateInfo.viewportCount = viewportCount;
|
|
||||||
pipelineViewportStateCreateInfo.scissorCount = scissorCount;
|
|
||||||
pipelineViewportStateCreateInfo.flags = flags;
|
|
||||||
return pipelineViewportStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo(
|
|
||||||
VkSampleCountFlagBits rasterizationSamples,
|
|
||||||
VkPipelineMultisampleStateCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkPipelineMultisampleStateCreateInfo pipelineMultisampleStateCreateInfo {};
|
|
||||||
pipelineMultisampleStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
|
|
||||||
pipelineMultisampleStateCreateInfo.rasterizationSamples = rasterizationSamples;
|
|
||||||
pipelineMultisampleStateCreateInfo.flags = flags;
|
|
||||||
return pipelineMultisampleStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo(
|
|
||||||
const VkDynamicState * pDynamicStates,
|
|
||||||
uint32_t dynamicStateCount,
|
|
||||||
VkPipelineDynamicStateCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo {};
|
|
||||||
pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
|
||||||
pipelineDynamicStateCreateInfo.pDynamicStates = pDynamicStates;
|
|
||||||
pipelineDynamicStateCreateInfo.dynamicStateCount = dynamicStateCount;
|
|
||||||
pipelineDynamicStateCreateInfo.flags = flags;
|
|
||||||
return pipelineDynamicStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo(
|
|
||||||
const std::vector<VkDynamicState>& pDynamicStates,
|
|
||||||
VkPipelineDynamicStateCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo{};
|
|
||||||
pipelineDynamicStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
|
|
||||||
pipelineDynamicStateCreateInfo.pDynamicStates = pDynamicStates.data();
|
|
||||||
pipelineDynamicStateCreateInfo.dynamicStateCount = static_cast<uint32_t>(pDynamicStates.size());
|
|
||||||
pipelineDynamicStateCreateInfo.flags = flags;
|
|
||||||
return pipelineDynamicStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPipelineTessellationStateCreateInfo pipelineTessellationStateCreateInfo(uint32_t patchControlPoints)
|
|
||||||
{
|
|
||||||
VkPipelineTessellationStateCreateInfo pipelineTessellationStateCreateInfo {};
|
|
||||||
pipelineTessellationStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO;
|
|
||||||
pipelineTessellationStateCreateInfo.patchControlPoints = patchControlPoints;
|
|
||||||
return pipelineTessellationStateCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkGraphicsPipelineCreateInfo pipelineCreateInfo(
|
|
||||||
VkPipelineLayout layout,
|
|
||||||
VkRenderPass renderPass,
|
|
||||||
VkPipelineCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo {};
|
|
||||||
pipelineCreateInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
|
||||||
pipelineCreateInfo.layout = layout;
|
|
||||||
pipelineCreateInfo.renderPass = renderPass;
|
|
||||||
pipelineCreateInfo.flags = flags;
|
|
||||||
pipelineCreateInfo.basePipelineIndex = -1;
|
|
||||||
pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE;
|
|
||||||
return pipelineCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkGraphicsPipelineCreateInfo pipelineCreateInfo()
|
|
||||||
{
|
|
||||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo{};
|
|
||||||
pipelineCreateInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
|
|
||||||
pipelineCreateInfo.basePipelineIndex = -1;
|
|
||||||
pipelineCreateInfo.basePipelineHandle = VK_NULL_HANDLE;
|
|
||||||
return pipelineCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkComputePipelineCreateInfo computePipelineCreateInfo(
|
|
||||||
VkPipelineLayout layout,
|
|
||||||
VkPipelineCreateFlags flags = 0)
|
|
||||||
{
|
|
||||||
VkComputePipelineCreateInfo computePipelineCreateInfo {};
|
|
||||||
computePipelineCreateInfo.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO;
|
|
||||||
computePipelineCreateInfo.layout = layout;
|
|
||||||
computePipelineCreateInfo.flags = flags;
|
|
||||||
return computePipelineCreateInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkPushConstantRange pushConstantRange(
|
|
||||||
VkShaderStageFlags stageFlags,
|
|
||||||
uint32_t size,
|
|
||||||
uint32_t offset)
|
|
||||||
{
|
|
||||||
VkPushConstantRange pushConstantRange {};
|
|
||||||
pushConstantRange.stageFlags = stageFlags;
|
|
||||||
pushConstantRange.offset = offset;
|
|
||||||
pushConstantRange.size = size;
|
|
||||||
return pushConstantRange;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkBindSparseInfo bindSparseInfo()
|
|
||||||
{
|
|
||||||
VkBindSparseInfo bindSparseInfo{};
|
|
||||||
bindSparseInfo.sType = VK_STRUCTURE_TYPE_BIND_SPARSE_INFO;
|
|
||||||
return bindSparseInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Initialize a map entry for a shader specialization constant */
|
|
||||||
inline VkSpecializationMapEntry specializationMapEntry(uint32_t constantID, uint32_t offset, size_t size)
|
|
||||||
{
|
|
||||||
VkSpecializationMapEntry specializationMapEntry{};
|
|
||||||
specializationMapEntry.constantID = constantID;
|
|
||||||
specializationMapEntry.offset = offset;
|
|
||||||
specializationMapEntry.size = size;
|
|
||||||
return specializationMapEntry;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Initialize a specialization constant info structure to pass to a shader stage */
|
|
||||||
inline VkSpecializationInfo specializationInfo(uint32_t mapEntryCount, const VkSpecializationMapEntry* mapEntries, size_t dataSize, const void* data)
|
|
||||||
{
|
|
||||||
VkSpecializationInfo specializationInfo{};
|
|
||||||
specializationInfo.mapEntryCount = mapEntryCount;
|
|
||||||
specializationInfo.pMapEntries = mapEntries;
|
|
||||||
specializationInfo.dataSize = dataSize;
|
|
||||||
specializationInfo.pData = data;
|
|
||||||
return specializationInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @brief Initialize a specialization constant info structure to pass to a shader stage */
|
|
||||||
inline VkSpecializationInfo specializationInfo(const std::vector<VkSpecializationMapEntry> &mapEntries, size_t dataSize, const void* data)
|
|
||||||
{
|
|
||||||
VkSpecializationInfo specializationInfo{};
|
|
||||||
specializationInfo.mapEntryCount = static_cast<uint32_t>(mapEntries.size());
|
|
||||||
specializationInfo.pMapEntries = mapEntries.data();
|
|
||||||
specializationInfo.dataSize = dataSize;
|
|
||||||
specializationInfo.pData = data;
|
|
||||||
return specializationInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ray tracing related
|
|
||||||
inline VkAccelerationStructureGeometryKHR accelerationStructureGeometryKHR()
|
|
||||||
{
|
|
||||||
VkAccelerationStructureGeometryKHR accelerationStructureGeometryKHR{};
|
|
||||||
accelerationStructureGeometryKHR.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
|
|
||||||
return accelerationStructureGeometryKHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkAccelerationStructureBuildGeometryInfoKHR accelerationStructureBuildGeometryInfoKHR()
|
|
||||||
{
|
|
||||||
VkAccelerationStructureBuildGeometryInfoKHR accelerationStructureBuildGeometryInfoKHR{};
|
|
||||||
accelerationStructureBuildGeometryInfoKHR.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR;
|
|
||||||
return accelerationStructureBuildGeometryInfoKHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkAccelerationStructureBuildSizesInfoKHR accelerationStructureBuildSizesInfoKHR()
|
|
||||||
{
|
|
||||||
VkAccelerationStructureBuildSizesInfoKHR accelerationStructureBuildSizesInfoKHR{};
|
|
||||||
accelerationStructureBuildSizesInfoKHR.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR;
|
|
||||||
return accelerationStructureBuildSizesInfoKHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkRayTracingShaderGroupCreateInfoKHR rayTracingShaderGroupCreateInfoKHR()
|
|
||||||
{
|
|
||||||
VkRayTracingShaderGroupCreateInfoKHR rayTracingShaderGroupCreateInfoKHR{};
|
|
||||||
rayTracingShaderGroupCreateInfoKHR.sType = VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_KHR;
|
|
||||||
return rayTracingShaderGroupCreateInfoKHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkRayTracingPipelineCreateInfoKHR rayTracingPipelineCreateInfoKHR()
|
|
||||||
{
|
|
||||||
VkRayTracingPipelineCreateInfoKHR rayTracingPipelineCreateInfoKHR{};
|
|
||||||
rayTracingPipelineCreateInfoKHR.sType = VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_CREATE_INFO_KHR;
|
|
||||||
return rayTracingPipelineCreateInfoKHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline VkWriteDescriptorSetAccelerationStructureKHR writeDescriptorSetAccelerationStructureKHR()
|
|
||||||
{
|
|
||||||
VkWriteDescriptorSetAccelerationStructureKHR writeDescriptorSetAccelerationStructureKHR{};
|
|
||||||
writeDescriptorSetAccelerationStructureKHR.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR;
|
|
||||||
return writeDescriptorSetAccelerationStructureKHR;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,455 +0,0 @@
|
||||||
/*
|
|
||||||
* Assorted commonly used Vulkan helper functions
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016-2024 by Sascha Willems - www.saschawillems.de
|
|
||||||
*
|
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "VulkanTools.h"
|
|
||||||
|
|
||||||
#if !(defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK) || defined(VK_USE_PLATFORM_METAL_EXT))
|
|
||||||
// iOS & macOS: getAssetPath() and getShaderBasePath() implemented externally for access to Obj-C++ path utilities
|
|
||||||
const std::string getAssetPath()
|
|
||||||
{
|
|
||||||
if (vks::tools::resourcePath != "") {
|
|
||||||
return vks::tools::resourcePath + "/assets/";
|
|
||||||
}
|
|
||||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
|
||||||
return "";
|
|
||||||
#elif defined(VK_EXAMPLE_ASSETS_DIR)
|
|
||||||
return VK_EXAMPLE_ASSETS_DIR;
|
|
||||||
#else
|
|
||||||
return "./../assets/";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string getShaderBasePath()
|
|
||||||
{
|
|
||||||
if (vks::tools::resourcePath != "") {
|
|
||||||
return vks::tools::resourcePath + "/shaders/";
|
|
||||||
}
|
|
||||||
#if defined(VK_USE_PLATFORM_ANDROID_KHR)
|
|
||||||
return "shaders/";
|
|
||||||
#elif defined(VK_EXAMPLE_SHADERS_DIR)
|
|
||||||
return VK_EXAMPLE_SHADERS_DIR;
|
|
||||||
#else
|
|
||||||
return "./../shaders/";
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace vks
|
|
||||||
{
|
|
||||||
namespace tools
|
|
||||||
{
|
|
||||||
bool errorModeSilent = false;
|
|
||||||
std::string resourcePath = "";
|
|
||||||
|
|
||||||
std::string errorString(VkResult errorCode)
|
|
||||||
{
|
|
||||||
switch (errorCode)
|
|
||||||
{
|
|
||||||
#define STR(r) case VK_ ##r: return #r
|
|
||||||
STR(NOT_READY);
|
|
||||||
STR(TIMEOUT);
|
|
||||||
STR(EVENT_SET);
|
|
||||||
STR(EVENT_RESET);
|
|
||||||
STR(INCOMPLETE);
|
|
||||||
STR(ERROR_OUT_OF_HOST_MEMORY);
|
|
||||||
STR(ERROR_OUT_OF_DEVICE_MEMORY);
|
|
||||||
STR(ERROR_INITIALIZATION_FAILED);
|
|
||||||
STR(ERROR_DEVICE_LOST);
|
|
||||||
STR(ERROR_MEMORY_MAP_FAILED);
|
|
||||||
STR(ERROR_LAYER_NOT_PRESENT);
|
|
||||||
STR(ERROR_EXTENSION_NOT_PRESENT);
|
|
||||||
STR(ERROR_FEATURE_NOT_PRESENT);
|
|
||||||
STR(ERROR_INCOMPATIBLE_DRIVER);
|
|
||||||
STR(ERROR_TOO_MANY_OBJECTS);
|
|
||||||
STR(ERROR_FORMAT_NOT_SUPPORTED);
|
|
||||||
STR(ERROR_SURFACE_LOST_KHR);
|
|
||||||
STR(ERROR_NATIVE_WINDOW_IN_USE_KHR);
|
|
||||||
STR(SUBOPTIMAL_KHR);
|
|
||||||
STR(ERROR_OUT_OF_DATE_KHR);
|
|
||||||
STR(ERROR_INCOMPATIBLE_DISPLAY_KHR);
|
|
||||||
STR(ERROR_VALIDATION_FAILED_EXT);
|
|
||||||
STR(ERROR_INVALID_SHADER_NV);
|
|
||||||
STR(ERROR_INCOMPATIBLE_SHADER_BINARY_EXT);
|
|
||||||
#undef STR
|
|
||||||
default:
|
|
||||||
return "UNKNOWN_ERROR";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string physicalDeviceTypeString(VkPhysicalDeviceType type)
|
|
||||||
{
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
#define STR(r) case VK_PHYSICAL_DEVICE_TYPE_ ##r: return #r
|
|
||||||
STR(OTHER);
|
|
||||||
STR(INTEGRATED_GPU);
|
|
||||||
STR(DISCRETE_GPU);
|
|
||||||
STR(VIRTUAL_GPU);
|
|
||||||
STR(CPU);
|
|
||||||
#undef STR
|
|
||||||
default: return "UNKNOWN_DEVICE_TYPE";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat)
|
|
||||||
{
|
|
||||||
// Since all depth formats may be optional, we need to find a suitable depth format to use
|
|
||||||
// Start with the highest precision packed format
|
|
||||||
std::vector<VkFormat> formatList = {
|
|
||||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
|
||||||
VK_FORMAT_D32_SFLOAT,
|
|
||||||
VK_FORMAT_D24_UNORM_S8_UINT,
|
|
||||||
VK_FORMAT_D16_UNORM_S8_UINT,
|
|
||||||
VK_FORMAT_D16_UNORM
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto& format : formatList)
|
|
||||||
{
|
|
||||||
VkFormatProperties formatProps;
|
|
||||||
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProps);
|
|
||||||
if (formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
|
||||||
{
|
|
||||||
*depthFormat = format;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkBool32 getSupportedDepthStencilFormat(VkPhysicalDevice physicalDevice, VkFormat* depthStencilFormat)
|
|
||||||
{
|
|
||||||
std::vector<VkFormat> formatList = {
|
|
||||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
|
||||||
VK_FORMAT_D24_UNORM_S8_UINT,
|
|
||||||
VK_FORMAT_D16_UNORM_S8_UINT,
|
|
||||||
};
|
|
||||||
|
|
||||||
for (auto& format : formatList)
|
|
||||||
{
|
|
||||||
VkFormatProperties formatProps;
|
|
||||||
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProps);
|
|
||||||
if (formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
|
|
||||||
{
|
|
||||||
*depthStencilFormat = format;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkBool32 formatHasStencil(VkFormat format)
|
|
||||||
{
|
|
||||||
std::vector<VkFormat> stencilFormats = {
|
|
||||||
VK_FORMAT_S8_UINT,
|
|
||||||
VK_FORMAT_D16_UNORM_S8_UINT,
|
|
||||||
VK_FORMAT_D24_UNORM_S8_UINT,
|
|
||||||
VK_FORMAT_D32_SFLOAT_S8_UINT,
|
|
||||||
};
|
|
||||||
return std::find(stencilFormats.begin(), stencilFormats.end(), format) != std::end(stencilFormats);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns if a given format support LINEAR filtering
|
|
||||||
VkBool32 formatIsFilterable(VkPhysicalDevice physicalDevice, VkFormat format, VkImageTiling tiling)
|
|
||||||
{
|
|
||||||
VkFormatProperties formatProps;
|
|
||||||
vkGetPhysicalDeviceFormatProperties(physicalDevice, format, &formatProps);
|
|
||||||
|
|
||||||
if (tiling == VK_IMAGE_TILING_OPTIMAL)
|
|
||||||
return formatProps.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
|
||||||
|
|
||||||
if (tiling == VK_IMAGE_TILING_LINEAR)
|
|
||||||
return formatProps.linearTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an image memory barrier for changing the layout of
|
|
||||||
// an image and put it into an active command buffer
|
|
||||||
// See chapter 11.4 "Image Layout" for details
|
|
||||||
|
|
||||||
void setImageLayout(
|
|
||||||
VkCommandBuffer cmdbuffer,
|
|
||||||
VkImage image,
|
|
||||||
VkImageLayout oldImageLayout,
|
|
||||||
VkImageLayout newImageLayout,
|
|
||||||
VkImageSubresourceRange subresourceRange,
|
|
||||||
VkPipelineStageFlags srcStageMask,
|
|
||||||
VkPipelineStageFlags dstStageMask)
|
|
||||||
{
|
|
||||||
// Create an image barrier object
|
|
||||||
VkImageMemoryBarrier imageMemoryBarrier = vks::initializers::imageMemoryBarrier();
|
|
||||||
imageMemoryBarrier.oldLayout = oldImageLayout;
|
|
||||||
imageMemoryBarrier.newLayout = newImageLayout;
|
|
||||||
imageMemoryBarrier.image = image;
|
|
||||||
imageMemoryBarrier.subresourceRange = subresourceRange;
|
|
||||||
|
|
||||||
// Source layouts (old)
|
|
||||||
// Source access mask controls actions that have to be finished on the old layout
|
|
||||||
// before it will be transitioned to the new layout
|
|
||||||
switch (oldImageLayout)
|
|
||||||
{
|
|
||||||
case VK_IMAGE_LAYOUT_UNDEFINED:
|
|
||||||
// Image layout is undefined (or does not matter)
|
|
||||||
// Only valid as initial layout
|
|
||||||
// No flags required, listed only for completeness
|
|
||||||
imageMemoryBarrier.srcAccessMask = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_PREINITIALIZED:
|
|
||||||
// Image is preinitialized
|
|
||||||
// Only valid as initial layout for linear images, preserves memory contents
|
|
||||||
// Make sure host writes have been finished
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
|
||||||
// Image is a color attachment
|
|
||||||
// Make sure any writes to the color buffer have been finished
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
|
|
||||||
// Image is a depth/stencil attachment
|
|
||||||
// Make sure any writes to the depth/stencil buffer have been finished
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
|
|
||||||
// Image is a transfer source
|
|
||||||
// Make sure any reads from the image have been finished
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
|
|
||||||
// Image is a transfer destination
|
|
||||||
// Make sure any writes to the image have been finished
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
|
|
||||||
// Image is read by a shader
|
|
||||||
// Make sure any shader reads from the image have been finished
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Other source layouts aren't handled (yet)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Target layouts (new)
|
|
||||||
// Destination access mask controls the dependency for the new image layout
|
|
||||||
switch (newImageLayout)
|
|
||||||
{
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
|
|
||||||
// Image will be used as a transfer destination
|
|
||||||
// Make sure any writes to the image have been finished
|
|
||||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
|
|
||||||
// Image will be used as a transfer source
|
|
||||||
// Make sure any reads from the image have been finished
|
|
||||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
|
||||||
// Image will be used as a color attachment
|
|
||||||
// Make sure any writes to the color buffer have been finished
|
|
||||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL:
|
|
||||||
// Image layout will be used as a depth/stencil attachment
|
|
||||||
// Make sure any writes to depth/stencil buffer have been finished
|
|
||||||
imageMemoryBarrier.dstAccessMask = imageMemoryBarrier.dstAccessMask | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
|
|
||||||
// Image will be read in a shader (sampler, input attachment)
|
|
||||||
// Make sure any writes to the image have been finished
|
|
||||||
if (imageMemoryBarrier.srcAccessMask == 0)
|
|
||||||
{
|
|
||||||
imageMemoryBarrier.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT | VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
}
|
|
||||||
imageMemoryBarrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Other source layouts aren't handled (yet)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put barrier inside setup command buffer
|
|
||||||
vkCmdPipelineBarrier(
|
|
||||||
cmdbuffer,
|
|
||||||
srcStageMask,
|
|
||||||
dstStageMask,
|
|
||||||
0,
|
|
||||||
0, nullptr,
|
|
||||||
0, nullptr,
|
|
||||||
1, &imageMemoryBarrier);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixed sub resource on first mip level and layer
|
|
||||||
void setImageLayout(
|
|
||||||
VkCommandBuffer cmdbuffer,
|
|
||||||
VkImage image,
|
|
||||||
VkImageAspectFlags aspectMask,
|
|
||||||
VkImageLayout oldImageLayout,
|
|
||||||
VkImageLayout newImageLayout,
|
|
||||||
VkPipelineStageFlags srcStageMask,
|
|
||||||
VkPipelineStageFlags dstStageMask)
|
|
||||||
{
|
|
||||||
VkImageSubresourceRange subresourceRange = {};
|
|
||||||
subresourceRange.aspectMask = aspectMask;
|
|
||||||
subresourceRange.baseMipLevel = 0;
|
|
||||||
subresourceRange.levelCount = 1;
|
|
||||||
subresourceRange.layerCount = 1;
|
|
||||||
setImageLayout(cmdbuffer, image, oldImageLayout, newImageLayout, subresourceRange, srcStageMask, dstStageMask);
|
|
||||||
}
|
|
||||||
|
|
||||||
void insertImageMemoryBarrier(
|
|
||||||
VkCommandBuffer cmdbuffer,
|
|
||||||
VkImage image,
|
|
||||||
VkAccessFlags srcAccessMask,
|
|
||||||
VkAccessFlags dstAccessMask,
|
|
||||||
VkImageLayout oldImageLayout,
|
|
||||||
VkImageLayout newImageLayout,
|
|
||||||
VkPipelineStageFlags srcStageMask,
|
|
||||||
VkPipelineStageFlags dstStageMask,
|
|
||||||
VkImageSubresourceRange subresourceRange)
|
|
||||||
{
|
|
||||||
VkImageMemoryBarrier imageMemoryBarrier = vks::initializers::imageMemoryBarrier();
|
|
||||||
imageMemoryBarrier.srcAccessMask = srcAccessMask;
|
|
||||||
imageMemoryBarrier.dstAccessMask = dstAccessMask;
|
|
||||||
imageMemoryBarrier.oldLayout = oldImageLayout;
|
|
||||||
imageMemoryBarrier.newLayout = newImageLayout;
|
|
||||||
imageMemoryBarrier.image = image;
|
|
||||||
imageMemoryBarrier.subresourceRange = subresourceRange;
|
|
||||||
|
|
||||||
vkCmdPipelineBarrier(
|
|
||||||
cmdbuffer,
|
|
||||||
srcStageMask,
|
|
||||||
dstStageMask,
|
|
||||||
0,
|
|
||||||
0, nullptr,
|
|
||||||
0, nullptr,
|
|
||||||
1, &imageMemoryBarrier);
|
|
||||||
}
|
|
||||||
|
|
||||||
void exitFatal(const std::string& message, int32_t exitCode)
|
|
||||||
{
|
|
||||||
#if defined(_WIN32)
|
|
||||||
if (!errorModeSilent) {
|
|
||||||
MessageBox(NULL, message.c_str(), NULL, MB_OK | MB_ICONERROR);
|
|
||||||
}
|
|
||||||
#elif defined(__ANDROID__)
|
|
||||||
LOGE("Fatal error: %s", message.c_str());
|
|
||||||
vks::android::showAlert(message.c_str());
|
|
||||||
#endif
|
|
||||||
std::cerr << message << "\n";
|
|
||||||
#if !defined(__ANDROID__)
|
|
||||||
exit(exitCode);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void exitFatal(const std::string& message, VkResult resultCode)
|
|
||||||
{
|
|
||||||
exitFatal(message, (int32_t)resultCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(__ANDROID__)
|
|
||||||
// Android shaders are stored as assets in the apk
|
|
||||||
// So they need to be loaded via the asset manager
|
|
||||||
VkShaderModule loadShader(AAssetManager* assetManager, const char *fileName, VkDevice device)
|
|
||||||
{
|
|
||||||
// Load shader from compressed asset
|
|
||||||
AAsset* asset = AAssetManager_open(assetManager, fileName, AASSET_MODE_STREAMING);
|
|
||||||
assert(asset);
|
|
||||||
size_t size = AAsset_getLength(asset);
|
|
||||||
assert(size > 0);
|
|
||||||
|
|
||||||
char *shaderCode = new char[size];
|
|
||||||
AAsset_read(asset, shaderCode, size);
|
|
||||||
AAsset_close(asset);
|
|
||||||
|
|
||||||
VkShaderModule shaderModule;
|
|
||||||
VkShaderModuleCreateInfo moduleCreateInfo;
|
|
||||||
moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
|
||||||
moduleCreateInfo.pNext = NULL;
|
|
||||||
moduleCreateInfo.codeSize = size;
|
|
||||||
moduleCreateInfo.pCode = (uint32_t*)shaderCode;
|
|
||||||
moduleCreateInfo.flags = 0;
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateShaderModule(device, &moduleCreateInfo, NULL, &shaderModule));
|
|
||||||
|
|
||||||
delete[] shaderCode;
|
|
||||||
|
|
||||||
return shaderModule;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
VkShaderModule loadShader(const char *fileName, VkDevice device)
|
|
||||||
{
|
|
||||||
std::ifstream is(fileName, std::ios::binary | std::ios::in | std::ios::ate);
|
|
||||||
|
|
||||||
if (is.is_open())
|
|
||||||
{
|
|
||||||
size_t size = is.tellg();
|
|
||||||
is.seekg(0, std::ios::beg);
|
|
||||||
char* shaderCode = new char[size];
|
|
||||||
is.read(shaderCode, size);
|
|
||||||
is.close();
|
|
||||||
|
|
||||||
assert(size > 0);
|
|
||||||
|
|
||||||
VkShaderModule shaderModule;
|
|
||||||
VkShaderModuleCreateInfo moduleCreateInfo{};
|
|
||||||
moduleCreateInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
|
||||||
moduleCreateInfo.codeSize = size;
|
|
||||||
moduleCreateInfo.pCode = (uint32_t*)shaderCode;
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkCreateShaderModule(device, &moduleCreateInfo, NULL, &shaderModule));
|
|
||||||
|
|
||||||
delete[] shaderCode;
|
|
||||||
|
|
||||||
return shaderModule;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cerr << "Error: Could not open shader file \"" << fileName << "\"" << "\n";
|
|
||||||
return VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool fileExists(const std::string &filename)
|
|
||||||
{
|
|
||||||
std::ifstream f(filename.c_str());
|
|
||||||
return !f.fail();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t alignedSize(uint32_t value, uint32_t alignment)
|
|
||||||
{
|
|
||||||
return (value + alignment - 1) & ~(alignment - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t alignedSize(size_t value, size_t alignment)
|
|
||||||
{
|
|
||||||
return (value + alignment - 1) & ~(alignment - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
VkDeviceSize alignedVkSize(VkDeviceSize value, VkDeviceSize alignment)
|
|
||||||
{
|
|
||||||
return (value + alignment - 1) & ~(alignment - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,141 +0,0 @@
|
||||||
/*
|
|
||||||
* Assorted Vulkan helper functions
|
|
||||||
*
|
|
||||||
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
|
||||||
*
|
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "vulkan/vulkan.h"
|
|
||||||
#include "VulkanInitializers.hpp"
|
|
||||||
|
|
||||||
#include <math.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string>
|
|
||||||
#include <cstring>
|
|
||||||
#include <fstream>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include <fstream>
|
|
||||||
#include <algorithm>
|
|
||||||
#if defined(_WIN32)
|
|
||||||
#include <windows.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <io.h>
|
|
||||||
#elif defined(__ANDROID__)
|
|
||||||
#include "VulkanAndroid.h"
|
|
||||||
#include <android/asset_manager.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Custom define for better code readability
|
|
||||||
#define VK_FLAGS_NONE 0
|
|
||||||
// Default fence timeout in nanoseconds
|
|
||||||
#define DEFAULT_FENCE_TIMEOUT 100000000000
|
|
||||||
|
|
||||||
// Macro to check and display Vulkan return results
|
|
||||||
#if defined(__ANDROID__)
|
|
||||||
#define VK_CHECK_RESULT(f) \
|
|
||||||
{ \
|
|
||||||
VkResult res = (f); \
|
|
||||||
if (res != VK_SUCCESS) \
|
|
||||||
{ \
|
|
||||||
LOGE("Fatal : VkResult is \" %s \" in %s at line %d", vks::tools::errorString(res).c_str(), __FILE__, __LINE__); \
|
|
||||||
assert(res == VK_SUCCESS); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define VK_CHECK_RESULT(f) \
|
|
||||||
{ \
|
|
||||||
VkResult res = (f); \
|
|
||||||
if (res != VK_SUCCESS) \
|
|
||||||
{ \
|
|
||||||
std::cout << "Fatal : VkResult is \"" << vks::tools::errorString(res) << "\" in " << __FILE__ << " at line " << __LINE__ << "\n"; \
|
|
||||||
assert(res == VK_SUCCESS); \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const std::string getAssetPath();
|
|
||||||
const std::string getShaderBasePath();
|
|
||||||
|
|
||||||
namespace vks
|
|
||||||
{
|
|
||||||
namespace tools
|
|
||||||
{
|
|
||||||
/** @brief Setting this path chnanges the place where the samples looks for assets and shaders */
|
|
||||||
extern std::string resourcePath;
|
|
||||||
|
|
||||||
/** @brief Disable message boxes on fatal errors */
|
|
||||||
extern bool errorModeSilent;
|
|
||||||
|
|
||||||
/** @brief Returns an error code as a string */
|
|
||||||
std::string errorString(VkResult errorCode);
|
|
||||||
|
|
||||||
/** @brief Returns the device type as a string */
|
|
||||||
std::string physicalDeviceTypeString(VkPhysicalDeviceType type);
|
|
||||||
|
|
||||||
// Selected a suitable supported depth format starting with 32 bit down to 16 bit
|
|
||||||
// Returns false if none of the depth formats in the list is supported by the device
|
|
||||||
VkBool32 getSupportedDepthFormat(VkPhysicalDevice physicalDevice, VkFormat *depthFormat);
|
|
||||||
// Same as getSupportedDepthFormat but will only select formats that also have stencil
|
|
||||||
VkBool32 getSupportedDepthStencilFormat(VkPhysicalDevice physicalDevice, VkFormat* depthStencilFormat);
|
|
||||||
|
|
||||||
// Returns true a given format support LINEAR filtering
|
|
||||||
VkBool32 formatIsFilterable(VkPhysicalDevice physicalDevice, VkFormat format, VkImageTiling tiling);
|
|
||||||
// Returns true if a given format has a stencil part
|
|
||||||
VkBool32 formatHasStencil(VkFormat format);
|
|
||||||
|
|
||||||
// Put an image memory barrier for setting an image layout on the sub resource into the given command buffer
|
|
||||||
void setImageLayout(
|
|
||||||
VkCommandBuffer cmdbuffer,
|
|
||||||
VkImage image,
|
|
||||||
VkImageLayout oldImageLayout,
|
|
||||||
VkImageLayout newImageLayout,
|
|
||||||
VkImageSubresourceRange subresourceRange,
|
|
||||||
VkPipelineStageFlags srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
|
||||||
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
|
||||||
// Uses a fixed sub resource layout with first mip level and layer
|
|
||||||
void setImageLayout(
|
|
||||||
VkCommandBuffer cmdbuffer,
|
|
||||||
VkImage image,
|
|
||||||
VkImageAspectFlags aspectMask,
|
|
||||||
VkImageLayout oldImageLayout,
|
|
||||||
VkImageLayout newImageLayout,
|
|
||||||
VkPipelineStageFlags srcStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
|
||||||
VkPipelineStageFlags dstStageMask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
|
||||||
|
|
||||||
/** @brief Insert an image memory barrier into the command buffer */
|
|
||||||
void insertImageMemoryBarrier(
|
|
||||||
VkCommandBuffer cmdbuffer,
|
|
||||||
VkImage image,
|
|
||||||
VkAccessFlags srcAccessMask,
|
|
||||||
VkAccessFlags dstAccessMask,
|
|
||||||
VkImageLayout oldImageLayout,
|
|
||||||
VkImageLayout newImageLayout,
|
|
||||||
VkPipelineStageFlags srcStageMask,
|
|
||||||
VkPipelineStageFlags dstStageMask,
|
|
||||||
VkImageSubresourceRange subresourceRange);
|
|
||||||
|
|
||||||
// Display error message and exit on fatal error
|
|
||||||
void exitFatal(const std::string& message, int32_t exitCode);
|
|
||||||
void exitFatal(const std::string& message, VkResult resultCode);
|
|
||||||
|
|
||||||
// Load a SPIR-V shader (binary)
|
|
||||||
#if defined(__ANDROID__)
|
|
||||||
VkShaderModule loadShader(AAssetManager* assetManager, const char *fileName, VkDevice device);
|
|
||||||
#else
|
|
||||||
VkShaderModule loadShader(const char *fileName, VkDevice device);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/** @brief Checks if a file exists */
|
|
||||||
bool fileExists(const std::string &filename);
|
|
||||||
|
|
||||||
uint32_t alignedSize(uint32_t value, uint32_t alignment);
|
|
||||||
VkDeviceSize alignedVkSize(VkDeviceSize value, VkDeviceSize alignment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,163 +0,0 @@
|
||||||
#include <vulkan/vulkan.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
VkAccessFlags getAccessFlags(VkImageLayout layout)
|
|
||||||
{
|
|
||||||
switch (layout)
|
|
||||||
{
|
|
||||||
case VK_IMAGE_LAYOUT_UNDEFINED:
|
|
||||||
case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
|
|
||||||
return 0;
|
|
||||||
case VK_IMAGE_LAYOUT_PREINITIALIZED:
|
|
||||||
return VK_ACCESS_HOST_WRITE_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
|
||||||
return VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL:
|
|
||||||
return VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT | VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR:
|
|
||||||
return VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR;
|
|
||||||
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
|
|
||||||
return VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
|
|
||||||
return VK_ACCESS_TRANSFER_READ_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
|
|
||||||
return VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_GENERAL:
|
|
||||||
assert(false && "Don't know how to get a meaningful VkAccessFlags for VK_IMAGE_LAYOUT_GENERAL! Don't use it!");
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VkPipelineStageFlags getPipelineStageFlags(VkImageLayout layout)
|
|
||||||
{
|
|
||||||
switch (layout)
|
|
||||||
{
|
|
||||||
case VK_IMAGE_LAYOUT_UNDEFINED:
|
|
||||||
return VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_PREINITIALIZED:
|
|
||||||
return VK_PIPELINE_STAGE_HOST_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
|
|
||||||
case VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL:
|
|
||||||
return VK_PIPELINE_STAGE_TRANSFER_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
|
|
||||||
return VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL:
|
|
||||||
return VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT | VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR:
|
|
||||||
return VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR;
|
|
||||||
case VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL:
|
|
||||||
return VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
|
|
||||||
return VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
|
||||||
case VK_IMAGE_LAYOUT_GENERAL:
|
|
||||||
assert(false && "Don't know how to get a meaningful VkPipelineStageFlags for VK_IMAGE_LAYOUT_GENERAL! Don't use it!");
|
|
||||||
return 0;
|
|
||||||
default:
|
|
||||||
assert(false);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an image memory barrier for changing the layout of
|
|
||||||
// an image and put it into an active command buffer
|
|
||||||
// See chapter 12.4 "Image Layout" for details
|
|
||||||
|
|
||||||
void image_layout_transition(VkCommandBuffer command_buffer,
|
|
||||||
VkImage image,
|
|
||||||
VkPipelineStageFlags src_stage_mask,
|
|
||||||
VkPipelineStageFlags dst_stage_mask,
|
|
||||||
VkAccessFlags src_access_mask,
|
|
||||||
VkAccessFlags dst_access_mask,
|
|
||||||
VkImageLayout old_layout,
|
|
||||||
VkImageLayout new_layout,
|
|
||||||
VkImageSubresourceRange const &subresource_range)
|
|
||||||
{
|
|
||||||
// Create an image barrier object
|
|
||||||
VkImageMemoryBarrier image_memory_barrier{};
|
|
||||||
image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
|
||||||
image_memory_barrier.srcAccessMask = src_access_mask;
|
|
||||||
image_memory_barrier.dstAccessMask = dst_access_mask;
|
|
||||||
image_memory_barrier.oldLayout = old_layout;
|
|
||||||
image_memory_barrier.newLayout = new_layout;
|
|
||||||
image_memory_barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
image_memory_barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
image_memory_barrier.image = image;
|
|
||||||
image_memory_barrier.subresourceRange = subresource_range;
|
|
||||||
|
|
||||||
// Put barrier inside setup command buffer
|
|
||||||
vkCmdPipelineBarrier(command_buffer, src_stage_mask, dst_stage_mask, 0, 0, nullptr, 0, nullptr, 1, &image_memory_barrier);
|
|
||||||
}
|
|
||||||
|
|
||||||
void image_layout_transition(VkCommandBuffer command_buffer,
|
|
||||||
VkImage image,
|
|
||||||
VkImageLayout old_layout,
|
|
||||||
VkImageLayout new_layout,
|
|
||||||
VkImageSubresourceRange const &subresource_range)
|
|
||||||
{
|
|
||||||
VkPipelineStageFlags src_stage_mask = getPipelineStageFlags(old_layout);
|
|
||||||
VkPipelineStageFlags dst_stage_mask = getPipelineStageFlags(new_layout);
|
|
||||||
VkAccessFlags src_access_mask = getAccessFlags(old_layout);
|
|
||||||
VkAccessFlags dst_access_mask = getAccessFlags(new_layout);
|
|
||||||
|
|
||||||
image_layout_transition(command_buffer, image, src_stage_mask, dst_stage_mask, src_access_mask, dst_access_mask, old_layout, new_layout, subresource_range);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fixed sub resource on first mip level and layer
|
|
||||||
void image_layout_transition(VkCommandBuffer command_buffer,
|
|
||||||
VkImage image,
|
|
||||||
VkImageLayout old_layout,
|
|
||||||
VkImageLayout new_layout)
|
|
||||||
{
|
|
||||||
VkImageSubresourceRange subresource_range = {};
|
|
||||||
subresource_range.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
||||||
subresource_range.baseMipLevel = 0;
|
|
||||||
subresource_range.levelCount = 1;
|
|
||||||
subresource_range.baseArrayLayer = 0;
|
|
||||||
subresource_range.layerCount = 1;
|
|
||||||
image_layout_transition(command_buffer, image, old_layout, new_layout, subresource_range);
|
|
||||||
}
|
|
||||||
|
|
||||||
void image_layout_transition(VkCommandBuffer command_buffer,
|
|
||||||
std::vector<std::pair<VkImage, VkImageSubresourceRange>> const &imagesAndRanges,
|
|
||||||
VkImageLayout old_layout,
|
|
||||||
VkImageLayout new_layout)
|
|
||||||
{
|
|
||||||
VkPipelineStageFlags src_stage_mask = getPipelineStageFlags(old_layout);
|
|
||||||
VkPipelineStageFlags dst_stage_mask = getPipelineStageFlags(new_layout);
|
|
||||||
VkAccessFlags src_access_mask = getAccessFlags(old_layout);
|
|
||||||
VkAccessFlags dst_access_mask = getAccessFlags(new_layout);
|
|
||||||
|
|
||||||
// Create image barrier objects
|
|
||||||
std::vector<VkImageMemoryBarrier> image_memory_barriers;
|
|
||||||
image_memory_barriers.reserve(imagesAndRanges.size());
|
|
||||||
for (size_t i = 0; i < imagesAndRanges.size(); i++)
|
|
||||||
{
|
|
||||||
image_memory_barriers.emplace_back(VkImageMemoryBarrier{VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
|
||||||
nullptr,
|
|
||||||
src_access_mask,
|
|
||||||
dst_access_mask,
|
|
||||||
old_layout,
|
|
||||||
new_layout,
|
|
||||||
VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
VK_QUEUE_FAMILY_IGNORED,
|
|
||||||
imagesAndRanges[i].first,
|
|
||||||
imagesAndRanges[i].second});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Put barriers inside setup command buffer
|
|
||||||
vkCmdPipelineBarrier(command_buffer,
|
|
||||||
src_stage_mask,
|
|
||||||
dst_stage_mask,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
nullptr,
|
|
||||||
0,
|
|
||||||
nullptr,
|
|
||||||
static_cast<uint32_t>(image_memory_barriers.size()),
|
|
||||||
image_memory_barriers.data());
|
|
||||||
}
|
|
||||||
|
|
||||||
56
lib/shm.c
56
lib/shm.c
|
|
@ -1,56 +0,0 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Boilerplate to create an in-memory shared file.
|
|
||||||
*
|
|
||||||
* Link with `-lrt`.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static void randname(char *buf) {
|
|
||||||
struct timespec ts;
|
|
||||||
clock_gettime(CLOCK_REALTIME, &ts);
|
|
||||||
long r = ts.tv_nsec;
|
|
||||||
for (int i = 0; i < 6; ++i) {
|
|
||||||
buf[i] = 'A'+(r&15)+(r&16)*2;
|
|
||||||
r >>= 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int anonymous_shm_open(void) {
|
|
||||||
char name[] = "/hello-wayland-XXXXXX";
|
|
||||||
int retries = 100;
|
|
||||||
|
|
||||||
do {
|
|
||||||
randname(name + strlen(name) - 6);
|
|
||||||
|
|
||||||
--retries;
|
|
||||||
// shm_open guarantees that O_CLOEXEC is set
|
|
||||||
int fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL, 0600);
|
|
||||||
if (fd >= 0) {
|
|
||||||
shm_unlink(name);
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
} while (retries > 0 && errno == EEXIST);
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int create_shm_file(off_t size) {
|
|
||||||
int fd = anonymous_shm_open();
|
|
||||||
if (fd < 0) {
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ftruncate(fd, size) < 0) {
|
|
||||||
close(fd);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return fd;
|
|
||||||
}
|
|
||||||
10
lib/shm.h
10
lib/shm.h
|
|
@ -1,10 +0,0 @@
|
||||||
#ifndef SHM_H
|
|
||||||
#define SHM_H
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
int create_shm_file(off_t size);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
75
project.json
75
project.json
|
|
@ -3,15 +3,23 @@
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "base",
|
"name": "base",
|
||||||
"standard": "c++26",
|
"implementations": ["implementations/Crafter.Graphics-Window", "implementations/Crafter.Graphics-UiElement", "implementations/Crafter.Graphics-Camera"],
|
||||||
"source_files": ["src/source/Crafter.Graphics-Window","src/source/Crafter.Graphics-WindowWayland","src/source/Crafter.Graphics-WindowWaylandWayland", "src/source/Crafter.Graphics-UiElement", "src/source/Crafter.Graphics-VulkanDevice", "src/source/Crafter.Graphics-WindowWaylandVulkan", "lib/VulkanTools", "src/source/Crafter.Graphics-Camera"],
|
"interfaces": ["interfaces/Crafter.Graphics-Window", "interfaces/Crafter.Graphics", "interfaces/Crafter.Graphics-UiElement", "interfaces/Crafter.Graphics-Types", "interfaces/Crafter.Graphics-Camera"],
|
||||||
"c_files": ["lib/wayland-xdg-decoration-unstable-v1-client-protocol", "lib/xdg-shell-protocol", "lib/shm"],
|
"type": "library"
|
||||||
"module_files": ["src/module/Crafter.Graphics-Window","src/module/Crafter.Graphics-WindowWayland","src/module/Crafter.Graphics-WindowWaylandWayland", "src/module/Crafter.Graphics", "src/module/Crafter.Graphics-UiElement", "src/module/Crafter.Graphics-Types", "src/module/Crafter.Graphics-VulkanDevice", "src/module/Crafter.Graphics-VulkanPipeline", "src/module/Crafter.Graphics-VulkanShader", "src/module/Crafter.Graphics-WindowWaylandVulkan", "src/module/Crafter.Graphics-Camera", "src/module/Crafter.Graphics-VulkanBuffer", "src/module/Crafter.Graphics-Mesh", "src/module/Crafter.Graphics-MeshShader", "src/module/Crafter.Graphics-HeightmapShader","src/module/Crafter.Graphics-VoxelShader", "src/module/Crafter.Graphics-VulkanTexture", "src/module/Crafter.Graphics-TextureShader", "src/module/Crafter.Graphics-DescriptorSet"],
|
},
|
||||||
"build_dir": "build",
|
{
|
||||||
"output_dir": "bin",
|
"name": "wayland",
|
||||||
"type":"library",
|
"implementations": ["implementations/Crafter.Graphics-WindowWayland", "implementations/Crafter.Graphics-WindowWaylandWayland"],
|
||||||
"libs": ["wayland-client", "vulkan", "xkbcommon"],
|
"interfaces": ["interfaces/Crafter.Graphics-WindowWayland", "interfaces/Crafter.Graphics-WindowWaylandWayland"],
|
||||||
"flags": ["-Wno-uninitialized"],
|
"libs": ["wayland-client", "xkbcommon"],
|
||||||
|
"c_files": ["lib/xdg-shell-protocol", "lib/wayland-xdg-decoration-unstable-v1-client-protocol"],
|
||||||
|
"extends": ["base"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "vulkan",
|
||||||
|
"implementations": ["implementations/Crafter.Graphics-VulkanDevice", "implementations/Crafter.Graphics-WindowWaylandVulkan"],
|
||||||
|
"interfaces": ["interfaces/Crafter.Graphics-WindowWayland", "interfaces/Crafter.Graphics-WindowWaylandWayland", "interfaces/Crafter.Graphics-VulkanDevice", "interfaces/Crafter.Graphics-VulkanPipeline", "interfaces/Crafter.Graphics-VulkanShader", "interfaces/Crafter.Graphics-WindowWaylandVulkan", "interfaces/Crafter.Graphics-VulkanBuffer", "interfaces/Crafter.Graphics-Mesh", "interfaces/Crafter.Graphics-MeshShader", "interfaces/Crafter.Graphics-HeightmapShader","interfaces/Crafter.Graphics-VoxelShader", "interfaces/Crafter.Graphics-VulkanTexture", "interfaces/Crafter.Graphics-TextureShader", "interfaces/Crafter.Graphics-DescriptorSet"],
|
||||||
|
"libs": ["vulkan"],
|
||||||
"shaders": [
|
"shaders": [
|
||||||
{
|
{
|
||||||
"path":"src/shader/MeshShaderXYZ.glsl",
|
"path":"src/shader/MeshShaderXYZ.glsl",
|
||||||
|
|
@ -53,22 +61,30 @@
|
||||||
"type":4,
|
"type":4,
|
||||||
"entrypoint":"main"
|
"entrypoint":"main"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"extends": ["wayland"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "deps",
|
||||||
|
"dependencies": [
|
||||||
|
{
|
||||||
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
|
||||||
|
"configuration":"lib"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
|
||||||
|
"configuration":"lib"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lib-debug",
|
"name": "deps-debug",
|
||||||
"extends": ["base"],
|
|
||||||
"optimization_level": "0",
|
|
||||||
"debug": true,
|
"debug": true,
|
||||||
"dependencies": [
|
"dependencies": [
|
||||||
{
|
{
|
||||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
|
||||||
"configuration":"lib-debug"
|
"configuration":"lib-debug"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
|
|
||||||
"configuration":"lib-debug"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
|
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
|
||||||
"configuration":"lib-debug"
|
"configuration":"lib-debug"
|
||||||
|
|
@ -76,29 +92,14 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "lib-release",
|
"name": "lib-wayland",
|
||||||
"extends": ["base"],
|
"extends": ["wayland", "deps"],
|
||||||
"optimization_level": "3",
|
"type": "library"
|
||||||
"dependencies": [
|
|
||||||
{
|
|
||||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Event.git",
|
|
||||||
"configuration":"lib-release"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Asset.git",
|
"name": "lib-wayland-debug",
|
||||||
"configuration":"lib-release"
|
"type": "library",
|
||||||
},
|
"extends": ["wayland", "deps-debug"]
|
||||||
{
|
|
||||||
"path":"https://forgejo.catcrafts.net/Catcrafts/Crafter.Math.git",
|
|
||||||
"configuration":"lib-release"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "develop",
|
|
||||||
"extends": ["lib-debug"],
|
|
||||||
"source_files": ["src/source/main"],
|
|
||||||
"type":"executable"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Window;
|
|
||||||
import :UiElement;
|
|
||||||
|
|
||||||
export namespace Crafter::Graphics::Base {
|
|
||||||
class Window {
|
|
||||||
public:
|
|
||||||
std::vector<UiElement> elements;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Window;
|
|
||||||
import Crafter.Event;
|
|
||||||
import :UiElement;
|
|
||||||
|
|
||||||
export namespace Crafter::Graphics::Base {
|
|
||||||
struct ScaleData {
|
|
||||||
int32_t x;
|
|
||||||
int32_t y;
|
|
||||||
int32_t width;
|
|
||||||
int32_t height;
|
|
||||||
};
|
|
||||||
|
|
||||||
class WindowBuffer {
|
|
||||||
public:
|
|
||||||
std::uint32_t width;
|
|
||||||
std::uint32_t height;
|
|
||||||
float scale = 1;
|
|
||||||
Window(std::uint32_t width, std::uint32_t height, float scale = 1);
|
|
||||||
ScaleData ScaleElement(const UiElement& element);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Window;
|
|
||||||
import Crafter.Event;
|
|
||||||
|
|
||||||
export namespace Crafter::Graphics::Base {
|
|
||||||
class WindowClose {
|
|
||||||
public:
|
|
||||||
Event<void> onClose;
|
|
||||||
bool open = true;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Window;
|
|
||||||
import Crafter.Event;
|
|
||||||
|
|
||||||
export namespace Crafter::Graphics::Base {
|
|
||||||
class WindowKeyboard {
|
|
||||||
public:
|
|
||||||
bool heldkeys[255] = {};
|
|
||||||
Event<void> onKeyDown[255];
|
|
||||||
Event<void> onKeyHold[255];
|
|
||||||
Event<void> onKeyUp[255];
|
|
||||||
Event<char> onAnyKeyDown;
|
|
||||||
Event<char> onAnyKeyHold;
|
|
||||||
Event<char> onAnyKeyUp;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
module;
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
export module Crafter.Graphics:Window;
|
|
||||||
import Crafter.Event;
|
|
||||||
import :UiElement;
|
|
||||||
import :Types;
|
|
||||||
|
|
||||||
export namespace Crafter::Graphics::Base {
|
|
||||||
class WindowMouse {
|
|
||||||
public:
|
|
||||||
Event<MousePoint> onMouseRightClick;
|
|
||||||
Event<MousePoint> onMouseLeftClick;
|
|
||||||
Event<MousePoint> onMouseRightHold;
|
|
||||||
Event<MousePoint> onMouseLeftHold;
|
|
||||||
Event<MousePoint> onMouseRightRelease;
|
|
||||||
Event<MousePoint> onMouseLeftRelease;
|
|
||||||
Event<MouseMoveEvent> onMouseMove;
|
|
||||||
Event<MouseMoveEvent> onMouseEnter;
|
|
||||||
Event<MouseMoveEvent> onMouseLeave;
|
|
||||||
Event<double> onMouseScroll;
|
|
||||||
MousePoint currentMousePos;
|
|
||||||
MousePoint lastMousePos;
|
|
||||||
MousePoint mouseDelta;
|
|
||||||
bool mouseLeftHeld = false;
|
|
||||||
bool mouseRightHeld = false;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
export module Crafter.Graphics;
|
|
||||||
export import :Window;
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
|
|
||||||
layout(location = 0) out vec4 outFragColor;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
outFragColor = vec4(1, 1, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
@ -1,78 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
|
|
||||||
layout(location = 0) in vec2 fragUV;
|
|
||||||
layout(location = 0) out vec4 outColor;
|
|
||||||
layout(set = 1, binding = 0) uniform sampler2D texSampler;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
outColor = texture(texSampler, fragUV);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
float getFilledAlpha(vec2 uv, vec2 center, float radius, float fillAmount) {
|
|
||||||
vec2 dir = uv - center;
|
|
||||||
float dist = length(dir);
|
|
||||||
|
|
||||||
// If outside the circle, return 0
|
|
||||||
if (dist > radius)
|
|
||||||
return 0.0;
|
|
||||||
|
|
||||||
// Normalize direction vector and compute angle
|
|
||||||
float angle = atan(dir.y, dir.x); // atan returns from -PI to PI
|
|
||||||
if (angle < 0.0) angle += 2.0 * 3.14159265359; // Convert to 0 to 2PI
|
|
||||||
|
|
||||||
float filledAngle = fillAmount * 2.0 * 3.14159265359;
|
|
||||||
|
|
||||||
// If the point is within the filled angle, return 1
|
|
||||||
if (angle <= filledAngle)
|
|
||||||
return 1.0;
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
float getFilledAlphaAA(vec2 uv, vec2 center, float radius, float fillAmount, float edgeSoftness) {
|
|
||||||
vec2 dir = uv - center;
|
|
||||||
float dist = length(dir);
|
|
||||||
|
|
||||||
// If completely outside the circle, return 0
|
|
||||||
if (dist > radius + edgeSoftness)
|
|
||||||
return 0.0;
|
|
||||||
|
|
||||||
// Normalize direction vector and compute angle
|
|
||||||
float angle = atan(dir.y, dir.x); // -PI to PI
|
|
||||||
if (angle < 0.0) angle += 2.0 * 3.14159265359; // Convert to 0 to 2PI
|
|
||||||
|
|
||||||
float filledAngle = fillAmount * 2.0 * 3.14159265359;
|
|
||||||
|
|
||||||
// Calculate smooth edge for radius
|
|
||||||
float radiusAlpha = 1.0 - smoothstep(radius, radius + edgeSoftness, dist);
|
|
||||||
|
|
||||||
// Calculate smooth edge for angle
|
|
||||||
float angleAlpha = smoothstep(filledAngle - 0.02, filledAngle + 0.02, angle); // 0.02 rad ~ edge softness
|
|
||||||
|
|
||||||
return radiusAlpha * angleAlpha;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
|
|
||||||
layout(location = 0) in vec4 inColor;
|
|
||||||
layout(location = 0) out vec4 outColor;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
outColor = inColor;
|
|
||||||
}
|
|
||||||
|
|
@ -1,82 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
#extension GL_EXT_mesh_shader : require
|
|
||||||
|
|
||||||
layout (binding = 0) uniform UBO
|
|
||||||
{
|
|
||||||
mat4 modelProjectionView;
|
|
||||||
uint stride;
|
|
||||||
float spacing;
|
|
||||||
uint padding[14];
|
|
||||||
} ubo;
|
|
||||||
|
|
||||||
struct VertexType
|
|
||||||
{
|
|
||||||
float height;
|
|
||||||
float padding[3];
|
|
||||||
vec4 color;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (binding = 1) buffer VERTEX
|
|
||||||
{
|
|
||||||
VertexType pos[];
|
|
||||||
} vertex;
|
|
||||||
|
|
||||||
|
|
||||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
||||||
layout(triangles, max_vertices = 256, max_primitives = 128) out;
|
|
||||||
|
|
||||||
layout (location = 0) out PerVertexData
|
|
||||||
{
|
|
||||||
vec4 color;
|
|
||||||
} outVert[];
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
SetMeshOutputsEXT(256, 128);
|
|
||||||
|
|
||||||
uint linearID = gl_GlobalInvocationID.x;
|
|
||||||
uint quadX = linearID % ubo.stride;
|
|
||||||
uint quadZ = linearID / ubo.stride;
|
|
||||||
|
|
||||||
VertexType vertex1 = vertex.pos[quadZ * ubo.stride + quadX];
|
|
||||||
VertexType vertex2 = vertex.pos[quadZ * ubo.stride + quadX + 1];
|
|
||||||
VertexType vertex3 = vertex.pos[(quadZ+1) * ubo.stride + quadX];
|
|
||||||
VertexType vertex4 = vertex.pos[(quadZ+1) * ubo.stride + quadX + 1];
|
|
||||||
|
|
||||||
uint vertexID = gl_LocalInvocationID.x*4;
|
|
||||||
|
|
||||||
gl_MeshVerticesEXT[vertexID].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX, vertex1.height, ubo.spacing*quadZ, 1); // Top-left
|
|
||||||
gl_MeshVerticesEXT[vertexID + 1].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX+ubo.spacing, vertex2.height, ubo.spacing*quadZ, 1); // Top-right
|
|
||||||
gl_MeshVerticesEXT[vertexID + 2].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX, vertex3.height, ubo.spacing*quadZ+ubo.spacing, 1); // Bottom-left
|
|
||||||
gl_MeshVerticesEXT[vertexID + 3].gl_Position = ubo.modelProjectionView * vec4(ubo.spacing*quadX+ubo.spacing, vertex4.height, ubo.spacing*quadZ+ubo.spacing, 1); // Bottom-right
|
|
||||||
|
|
||||||
outVert[vertexID].color = vertex1.color;
|
|
||||||
outVert[vertexID + 1].color = vertex2.color;
|
|
||||||
outVert[vertexID+ 2].color = vertex3.color;
|
|
||||||
outVert[vertexID + 3].color = vertex4.color;
|
|
||||||
|
|
||||||
uint triangleID = gl_LocalInvocationID.x*2;
|
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[triangleID] = uvec3(vertexID+2, vertexID+1, vertexID);
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[triangleID + 1] = uvec3(vertexID+3, vertexID+1, vertexID+2);
|
|
||||||
}
|
|
||||||
|
|
@ -1,159 +0,0 @@
|
||||||
/*
|
|
||||||
* Crafter®.Graphics
|
|
||||||
* Copyright (C) 2025 Catcrafts®
|
|
||||||
* Catcrafts.net
|
|
||||||
*
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
#extension GL_EXT_mesh_shader : require
|
|
||||||
|
|
||||||
layout (binding = 0) uniform UBO
|
|
||||||
{
|
|
||||||
mat4 modelProjectionView;
|
|
||||||
uint sizeX;
|
|
||||||
uint sizeY;
|
|
||||||
uint sizeZ;
|
|
||||||
} ubo;
|
|
||||||
|
|
||||||
struct VoxelType
|
|
||||||
{
|
|
||||||
uint type;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (binding = 1) buffer VOXELS
|
|
||||||
{
|
|
||||||
VoxelType voxel[];
|
|
||||||
} voxels;
|
|
||||||
|
|
||||||
|
|
||||||
layout (location = 0) out PerVertexData
|
|
||||||
{
|
|
||||||
vec4 color;
|
|
||||||
} outVert[];
|
|
||||||
|
|
||||||
|
|
||||||
shared uint writeCounter;
|
|
||||||
|
|
||||||
layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in;
|
|
||||||
layout(triangles, max_vertices = 128, max_primitives = 192) out;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
if (gl_LocalInvocationIndex == 0) {
|
|
||||||
writeCounter = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
barrier();
|
|
||||||
|
|
||||||
uint type = voxels.voxel[gl_GlobalInvocationID.x].type;
|
|
||||||
|
|
||||||
if(type != 0) {
|
|
||||||
uint old = atomicAdd(writeCounter, 1);
|
|
||||||
uint z = gl_GlobalInvocationID.x / (ubo.sizeX * ubo.sizeY);
|
|
||||||
uint y = (gl_GlobalInvocationID.x % (ubo.sizeX * ubo.sizeY)) / ubo.sizeX;
|
|
||||||
uint x = gl_GlobalInvocationID.x % ubo.sizeX;
|
|
||||||
|
|
||||||
float zF = float(z);
|
|
||||||
float yF = float(y);
|
|
||||||
float xF = float(x);
|
|
||||||
|
|
||||||
uint oldVertexOffset = old*8;
|
|
||||||
|
|
||||||
float xC = xF / float((ubo.sizeX) - 1);
|
|
||||||
float yC = yF / float((ubo.sizeY) - 1);
|
|
||||||
float zC = zF / float((ubo.sizeZ) - 1);
|
|
||||||
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 0].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF - 0.5, zF - 0.5, 1.0);
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 1].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF - 0.5, zF - 0.5, 1.0);
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 2].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF + 0.5, zF - 0.5, 1.0);
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 3].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF + 0.5, zF - 0.5, 1.0);
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 4].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF - 0.5, zF + 0.5, 1.0);
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 5].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF - 0.5, zF + 0.5, 1.0);
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 6].gl_Position = ubo.modelProjectionView * vec4(xF + 0.5, yF + 0.5, zF + 0.5, 1.0);
|
|
||||||
gl_MeshVerticesEXT[oldVertexOffset + 7].gl_Position = ubo.modelProjectionView * vec4(xF - 0.5, yF + 0.5, zF + 0.5, 1.0);
|
|
||||||
|
|
||||||
outVert[oldVertexOffset + 0].color = vec4(xC, yC, zC, 1);
|
|
||||||
outVert[oldVertexOffset + 1].color = vec4(xC, yC, zC, 1);
|
|
||||||
outVert[oldVertexOffset + 2].color = vec4(xC, yC, zC, 1);
|
|
||||||
outVert[oldVertexOffset + 3].color = vec4(xC, yC, zC, 1);
|
|
||||||
outVert[oldVertexOffset + 4].color = vec4(xC, yC, zC, 1);
|
|
||||||
outVert[oldVertexOffset + 5].color = vec4(xC, yC, zC, 1);
|
|
||||||
outVert[oldVertexOffset + 6].color = vec4(xC, yC, zC, 1);
|
|
||||||
outVert[oldVertexOffset + 7].color = vec4(xC, yC, zC, 1);
|
|
||||||
|
|
||||||
uint oldPrimOffset = old*12;
|
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 0] = uvec3(oldVertexOffset + 2, oldVertexOffset + 1, oldVertexOffset + 0);
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 1] = uvec3(oldVertexOffset + 0, oldVertexOffset + 3, oldVertexOffset + 2);
|
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 2] = uvec3(oldVertexOffset + 4, oldVertexOffset + 5, oldVertexOffset + 6);
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 3] = uvec3(oldVertexOffset + 4, oldVertexOffset + 6, oldVertexOffset + 7);
|
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 4] = uvec3(oldVertexOffset + 0, oldVertexOffset + 1, oldVertexOffset + 5);
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 5] = uvec3(oldVertexOffset + 5, oldVertexOffset + 4, oldVertexOffset + 0);
|
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 6] = uvec3(oldVertexOffset + 3, oldVertexOffset + 6, oldVertexOffset + 2);
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 7] = uvec3(oldVertexOffset + 3, oldVertexOffset + 7, oldVertexOffset + 6);
|
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 8] = uvec3(oldVertexOffset + 7, oldVertexOffset + 3, oldVertexOffset + 0);
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 9] = uvec3(oldVertexOffset + 4, oldVertexOffset + 7, oldVertexOffset + 0);
|
|
||||||
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 10] = uvec3(oldVertexOffset + 1, oldVertexOffset + 2, oldVertexOffset + 6);
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[oldPrimOffset + 11] = uvec3(oldVertexOffset + 6, oldVertexOffset + 5, oldVertexOffset + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
barrier();
|
|
||||||
|
|
||||||
SetMeshOutputsEXT(writeCounter*8, writeCounter*12);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
int z = gl_GlobalInvocationID.x / (ubo.sizeX * ubo.sizeY);
|
|
||||||
int y = (gl_GlobalInvocationID.x % (ubo.sizeX * ubo.sizeY)) / ubo.sizeX;
|
|
||||||
int x = gl_GlobalInvocationID.x % ubo.sizeX;
|
|
||||||
|
|
||||||
// Top (y+1) if within bounds
|
|
||||||
if (y < ubo.sizeY - 1 && vertex.pos[gl_GlobalInvocationID.x + ubo.sizeX]) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bottom (y-1) if within bounds
|
|
||||||
if (y > 0 && vertex.pos[gl_GlobalInvocationID.x - ubo.sizeX]) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Left (x-1) if within bounds
|
|
||||||
if (x > 0 && vertex.pos[gl_GlobalInvocationID.x - 1]) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Right (x+1) if within bounds
|
|
||||||
if (x < ubo.sizeX - 1 && vertex.pos[gl_GlobalInvocationID.x + 1]) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Front (z+1) if within bounds
|
|
||||||
if (z < ubo.sizeZ - 1 && vertex.pos[gl_GlobalInvocationID.x + ubo.sizeX * ubo.sizeY]) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Back (z-1) if within bounds
|
|
||||||
if (z > 0 && vertex.pos[gl_GlobalInvocationID.x - ubo.sizeX * ubo.sizeY]) {
|
|
||||||
|
|
||||||
}
|
|
||||||
**/
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
#extension GL_EXT_mesh_shader : require
|
|
||||||
|
|
||||||
layout (binding = 0) uniform UBO
|
|
||||||
{
|
|
||||||
mat4 modelProjectionView;
|
|
||||||
} ubo;
|
|
||||||
|
|
||||||
layout (binding = 1) buffer VERTEX
|
|
||||||
{
|
|
||||||
vec4 pos[];
|
|
||||||
} vertex;
|
|
||||||
|
|
||||||
layout (binding = 2) buffer INDEX {
|
|
||||||
uint index[];
|
|
||||||
} index;
|
|
||||||
|
|
||||||
|
|
||||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
||||||
layout(triangles, max_vertices = 192, max_primitives = 64) out;
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
SetMeshOutputsEXT(192, 64);
|
|
||||||
uint triangleID = ((gl_WorkGroupID.x * gl_WorkGroupSize.x) + gl_LocalInvocationIndex.x)*3;
|
|
||||||
uint localID = gl_LocalInvocationIndex.x*3;
|
|
||||||
gl_MeshVerticesEXT[localID].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID]];
|
|
||||||
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]];
|
|
||||||
gl_MeshVerticesEXT[localID+2].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]];
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
|
|
||||||
}
|
|
||||||
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
#extension GL_EXT_mesh_shader : require
|
|
||||||
|
|
||||||
layout (binding = 0) uniform UBO
|
|
||||||
{
|
|
||||||
mat4 modelProjectionView;
|
|
||||||
} ubo;
|
|
||||||
|
|
||||||
struct VertexType
|
|
||||||
{
|
|
||||||
vec4 position;
|
|
||||||
vec4 color;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (std140, binding = 1) buffer VERTEX
|
|
||||||
{
|
|
||||||
VertexType pos[];
|
|
||||||
} vertex;
|
|
||||||
|
|
||||||
layout (binding = 2) buffer INDEX {
|
|
||||||
uint index[];
|
|
||||||
} index;
|
|
||||||
|
|
||||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
||||||
layout(triangles, max_vertices = 192, max_primitives = 64) out;
|
|
||||||
|
|
||||||
layout (location = 0) out PerVertexData
|
|
||||||
{
|
|
||||||
vec4 color;
|
|
||||||
} outVert[];
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
SetMeshOutputsEXT(192, 64);
|
|
||||||
uint triangleID = ((gl_WorkGroupID.x * gl_WorkGroupSize.x) + gl_LocalInvocationIndex.x)*3;
|
|
||||||
uint localID = gl_LocalInvocationIndex.x*3;
|
|
||||||
gl_MeshVerticesEXT[localID].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID]].position;
|
|
||||||
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]].position;
|
|
||||||
gl_MeshVerticesEXT[localID+2].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]].position;
|
|
||||||
|
|
||||||
outVert[localID].color = vertex.pos[index.index[triangleID]].color;
|
|
||||||
outVert[localID + 1].color = vertex.pos[index.index[triangleID+1]].color;
|
|
||||||
outVert[localID + 2].color = vertex.pos[index.index[triangleID+2]].color;
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
|
|
||||||
}
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
/*
|
|
||||||
Crafter®.Graphics
|
|
||||||
Copyright (C) 2025 Catcrafts®
|
|
||||||
Catcrafts.net
|
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
|
||||||
modify it under the terms of the GNU Lesser General Public
|
|
||||||
License as published by the Free Software Foundation; either
|
|
||||||
version 3.0 of the License, or (at your option) any later version.
|
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
Lesser General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU Lesser General Public
|
|
||||||
License along with this library; if not, write to the Free Software
|
|
||||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
||||||
*/
|
|
||||||
|
|
||||||
#version 450
|
|
||||||
#extension GL_EXT_mesh_shader : require
|
|
||||||
|
|
||||||
layout (binding = 0) uniform UBO
|
|
||||||
{
|
|
||||||
mat4 modelProjectionView;
|
|
||||||
} ubo;
|
|
||||||
|
|
||||||
struct VertexType
|
|
||||||
{
|
|
||||||
vec4 position;
|
|
||||||
vec2 uv;
|
|
||||||
vec2 pad;
|
|
||||||
};
|
|
||||||
|
|
||||||
layout (std140, binding = 1) buffer VERTEX
|
|
||||||
{
|
|
||||||
VertexType pos[];
|
|
||||||
} vertex;
|
|
||||||
|
|
||||||
layout (binding = 2) buffer INDEX {
|
|
||||||
uint index[];
|
|
||||||
} index;
|
|
||||||
|
|
||||||
layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in;
|
|
||||||
layout(triangles, max_vertices = 192, max_primitives = 64) out;
|
|
||||||
|
|
||||||
layout (location = 0) out PerVertexData
|
|
||||||
{
|
|
||||||
vec2 uv;
|
|
||||||
} outVert[];
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
SetMeshOutputsEXT(192, 64);
|
|
||||||
uint triangleID = ((gl_WorkGroupID.x * gl_WorkGroupSize.x) + gl_LocalInvocationIndex.x)*3;
|
|
||||||
uint localID = gl_LocalInvocationIndex.x*3;
|
|
||||||
gl_MeshVerticesEXT[localID].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID]].position;
|
|
||||||
gl_MeshVerticesEXT[localID+1].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+1]].position;
|
|
||||||
gl_MeshVerticesEXT[localID+2].gl_Position = ubo.modelProjectionView * vertex.pos[index.index[triangleID+2]].position;
|
|
||||||
|
|
||||||
outVert[localID].uv = vertex.pos[index.index[triangleID]].uv;
|
|
||||||
outVert[localID + 1].uv = vertex.pos[index.index[triangleID+1]].uv;
|
|
||||||
outVert[localID + 2].uv = vertex.pos[index.index[triangleID+2]].uv;
|
|
||||||
gl_PrimitiveTriangleIndicesEXT[gl_LocalInvocationIndex.x] = uvec3(localID, localID+1, localID+2);
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue