├── input └── game.input_binding ├── game.project ├── .gitignore ├── main ├── system_font.font └── main.collection ├── vulkan ├── ext.manifest └── src │ └── vulkan.cpp ├── LICENSE └── README.md /input/game.input_binding: -------------------------------------------------------------------------------- 1 | mouse_trigger { 2 | input: MOUSE_BUTTON_1 3 | action: "touch" 4 | } 5 | -------------------------------------------------------------------------------- /game.project: -------------------------------------------------------------------------------- 1 | [bootstrap] 2 | main_collection = /main/main.collectionc 3 | 4 | [script] 5 | shared_state = 1 6 | 7 | [display] 8 | width = 960 9 | height = 640 10 | 11 | [android] 12 | input_method = HiddenInputField 13 | 14 | [project] 15 | title = extension-vulkan 16 | 17 | [library] 18 | include_dirs = vulkan 19 | 20 | [shader] 21 | output_spirv = 1 22 | 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | /.internal 34 | /build -------------------------------------------------------------------------------- /main/system_font.font: -------------------------------------------------------------------------------- 1 | font: "/builtins/fonts/vera_mo_bd.ttf" 2 | material: "/builtins/fonts/system_font.material" 3 | size: 30 4 | antialias: 1 5 | alpha: 1.0 6 | outline_alpha: 0.0 7 | outline_width: 0.0 8 | shadow_alpha: 0.0 9 | shadow_blur: 0 10 | shadow_x: 0.0 11 | shadow_y: 0.0 12 | extra_characters: "" 13 | output_format: TYPE_DISTANCE_FIELD 14 | all_chars: false 15 | cache_width: 0 16 | cache_height: 0 17 | render_mode: MODE_SINGLE_LAYER 18 | -------------------------------------------------------------------------------- /vulkan/ext.manifest: -------------------------------------------------------------------------------- 1 | name: 'Vulkan' 2 | 3 | platforms: 4 | x86_64-osx: 5 | context: 6 | frameworks: ['Metal', 'IOSurface', 'QuartzCore'] 7 | libs: ['graphics_vulkan', 'MoltenVK'] 8 | arm64-ios: 9 | context: 10 | frameworks: ['Metal', 'QuartzCore'] 11 | libs: ['graphics_vulkan', 'MoltenVK'] 12 | arm64-ios: 13 | context: 14 | frameworks: ['Metal', 'QuartzCore'] 15 | libs: ['graphics_vulkan', 'MoltenVK'] 16 | x86_64-linux: 17 | context: 18 | libs: ['graphics_vulkan', 'X11-xcb'] 19 | x86-win32: 20 | context: 21 | libs: ['libgraphics_vulkan.lib', 'vulkan-1.lib'] 22 | x86_64-win32: 23 | context: 24 | libs: ['libgraphics_vulkan.lib', 'vulkan-1.lib'] 25 | armv7-android: 26 | context: 27 | libs: ['graphics_vulkan'] 28 | arm64-android: 29 | context: 30 | libs: ['graphics_vulkan'] 31 | -------------------------------------------------------------------------------- /vulkan/src/vulkan.cpp: -------------------------------------------------------------------------------- 1 | // Defold SDK 2 | #include 3 | #include 4 | 5 | 6 | #if defined(DM_HEADLESS) || defined(DM_PLATFORM_IOS) && !defined(__arm64__) 7 | #define VULKAN_NOT_SUPPORTED 1 8 | #endif 9 | 10 | #if defined(VULKAN_NOT_SUPPORTED) 11 | 12 | extern "C" void GraphicsAdapterVulkan() {} 13 | 14 | #else 15 | 16 | #define LIB_NAME "Vulkan" 17 | 18 | extern "C" void GraphicsAdapterVulkan(); 19 | 20 | dmExtension::Result AppInitializeVulkan(dmExtension::AppParams* params) 21 | { 22 | GraphicsAdapterVulkan(); 23 | return dmExtension::RESULT_OK; 24 | } 25 | 26 | dmExtension::Result InitializeVulkan(dmExtension::Params* params) 27 | { 28 | return dmExtension::RESULT_OK; 29 | } 30 | 31 | dmExtension::Result AppFinalizeVulkan(dmExtension::AppParams* params) 32 | { 33 | return dmExtension::RESULT_OK; 34 | } 35 | 36 | dmExtension::Result FinalizeVulkan(dmExtension::Params* params) 37 | { 38 | return dmExtension::RESULT_OK; 39 | } 40 | 41 | DM_DECLARE_EXTENSION(Vulkan, LIB_NAME, AppInitializeVulkan, AppFinalizeVulkan, InitializeVulkan, 0, 0, FinalizeVulkan) 42 | 43 | #endif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Defold 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /main/main.collection: -------------------------------------------------------------------------------- 1 | name: "main" 2 | scale_along_z: 0 3 | embedded_instances { 4 | id: "go" 5 | data: "embedded_components {\n" 6 | " id: \"label\"\n" 7 | " type: \"label\"\n" 8 | " data: \"size {\\n" 9 | " x: 128.0\\n" 10 | " y: 32.0\\n" 11 | " z: 0.0\\n" 12 | " w: 0.0\\n" 13 | "}\\n" 14 | "scale {\\n" 15 | " x: 1.0\\n" 16 | " y: 1.0\\n" 17 | " z: 1.0\\n" 18 | " w: 0.0\\n" 19 | "}\\n" 20 | "color {\\n" 21 | " x: 1.0\\n" 22 | " y: 1.0\\n" 23 | " z: 1.0\\n" 24 | " w: 1.0\\n" 25 | "}\\n" 26 | "outline {\\n" 27 | " x: 0.0\\n" 28 | " y: 0.0\\n" 29 | " z: 0.0\\n" 30 | " w: 1.0\\n" 31 | "}\\n" 32 | "shadow {\\n" 33 | " x: 0.0\\n" 34 | " y: 0.0\\n" 35 | " z: 0.0\\n" 36 | " w: 1.0\\n" 37 | "}\\n" 38 | "leading: 1.0\\n" 39 | "tracking: 0.0\\n" 40 | "pivot: PIVOT_CENTER\\n" 41 | "blend_mode: BLEND_MODE_ALPHA\\n" 42 | "line_break: false\\n" 43 | "text: \\\"Defold <3 Vulkan\\\"\\n" 44 | "font: \\\"/main/system_font.font\\\"\\n" 45 | "material: \\\"/builtins/fonts/label-df.material\\\"\\n" 46 | "\"\n" 47 | " position {\n" 48 | " x: 0.0\n" 49 | " y: 0.0\n" 50 | " z: 0.0\n" 51 | " }\n" 52 | " rotation {\n" 53 | " x: 0.0\n" 54 | " y: 0.0\n" 55 | " z: 0.0\n" 56 | " w: 1.0\n" 57 | " }\n" 58 | "}\n" 59 | "" 60 | position { 61 | x: 480.0 62 | y: 320.0 63 | z: 0.0 64 | } 65 | rotation { 66 | x: 0.0 67 | y: 0.0 68 | z: 0.0 69 | w: 1.0 70 | } 71 | scale3 { 72 | x: 2.0 73 | y: 2.0 74 | z: 2.0 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vulkan Extension 2 | 3 | ## **THIS EXTENSION IS DEPRECATED** 4 | 5 | This extension is no longer maintained and is no longer needed to use vulkan in Defold. To enable vulkan support, you can select graphics adapters via the app manifest: 6 | 7 | image 8 | 9 | **Please report any issues to the main Defold repository! (https://github.com/defold/defold)** 10 | 11 | This extension enables Vulkan support for Defold, by adding a Vulkan graphics adapter that will be used if the client device supports it. If Vulkan is not supported, the default OpenGL will be used instead. 12 | 13 | 14 | ## Installation 15 | 16 | ### Add project dependencies 17 | 18 | In order to add Vulkan support you need to add the extension to your own project by adding this extension as a [Defold library dependency](http://www.defold.com/manuals/libraries/). Open your ["game.project"](defold://open?path=/game.project) file and in the dependencies field under project add: 19 | 20 | > https://github.com/defold/extension-vulkan/archive/master.zip 21 | 22 | Or point to the ZIP file of a [specific release](https://github.com/defold/extension-vulkan/releases) (recommended!). 23 | 24 | 25 | ### Enable Output Spirv option 26 | 27 | Note that this extension requires that the 'Output Spirv' (`shader.output_spirv`) setting is enabled in the ["game.project"](defold://open?path=/game.project) file, otherwise you will get compilation errors when building your projects. 28 | 29 | 30 | ## Getting help 31 | 32 | If you run into trouble or if you notice any artifacts while using this extension, please visit [our forum](https://forum.defold.com) and let us know about it. You can also [create an issue here](https://github.com/defold/extension-vulkan/issues/new/choose). 33 | 34 | --- 35 | 36 | ### Using only Vulkan 37 | 38 | If you want to only build using only Vulkan you need to exclude the OpenGL graphics adapter. You can do this by creating an application manifest and using it in the Native Extension section of your ["game.project"](defold://open?path=/game.project) file. You can create an application manifest using this tool: https://britzl.github.io/manifestation/ 39 | --------------------------------------------------------------------------------