├── .github └── workflows │ └── build.yml ├── .gitignore ├── .gitmodules ├── CHANGELOG.md ├── CMakeLists.txt ├── LICENSE ├── README.md ├── THIRD-PARTY.md ├── extra ├── actions │ ├── Compile all shader files to Spir-V.js │ ├── GenerateMesh │ │ ├── CMakeLists.txt │ │ ├── DoubleSpinBox.qml │ │ ├── jsonc.c │ │ ├── module.cpp │ │ ├── par_shapes.h │ │ ├── script.js │ │ └── ui.qml │ ├── ImportOBJ │ │ ├── CMakeLists.txt │ │ ├── DoubleSpinBox.qml │ │ ├── jsonc.c │ │ ├── module.cpp │ │ ├── rapidobj.hpp │ │ ├── script.js │ │ └── ui.qml │ ├── Import_glTF.js │ └── Insert Orbit Camera.js ├── libs │ └── gl-matrix.js ├── qml │ └── imports.qml ├── samples │ ├── Atomic Counters │ │ ├── atomics.comp │ │ └── atomics.gpjs │ ├── Bindless Texture │ │ ├── attributeless.vs │ │ ├── bindless.gpjs │ │ ├── setHandles.js │ │ └── textured.fs │ ├── Bitonic sort │ │ ├── BitonicSort.comp │ │ ├── FillRandom.comp │ │ ├── MatrixTranspose.comp │ │ ├── Script.js │ │ └── sort.gpjs │ ├── Buffer Reference │ │ ├── buffer_reference.frag │ │ ├── buffer_reference.gpjs │ │ ├── buffer_reference.vert │ │ ├── colors.bin │ │ └── setHandles.js │ ├── Compute │ │ ├── compute.gpjs │ │ └── gameoflife.comp │ ├── Cube HLSL │ │ ├── cube.fx │ │ ├── cube.gpjs │ │ ├── cube_position_normal_texcoords.bin │ │ ├── math.js │ │ └── planks.jpg │ ├── Cube │ │ ├── cube.fs │ │ ├── cube.gpjs │ │ ├── cube.vs │ │ ├── cube_position_normal_texcoords.bin │ │ ├── math.js │ │ └── planks.jpg │ ├── Custom Actions │ │ ├── OrbitCamera.js │ │ ├── actions.gpjs │ │ ├── cube.fs │ │ ├── cube.vs │ │ ├── meshes │ │ │ ├── cube │ │ │ │ ├── cube.obj │ │ │ │ ├── default.mtl │ │ │ │ └── default.png │ │ │ └── teapot │ │ │ │ ├── default.mtl │ │ │ │ ├── default.png │ │ │ │ └── teapot.obj │ │ └── script.js │ ├── Indirect │ │ ├── fragment.glsl │ │ ├── generate.glsl │ │ ├── indirect.gpjs │ │ ├── setup.glsl │ │ └── vertex.glsl │ ├── Instancing │ │ ├── instances.bin │ │ ├── instancing.fs │ │ ├── instancing.gpjs │ │ ├── instancing.vs │ │ └── vertices.bin │ ├── Javascript Library │ │ ├── delaunay-fast │ │ │ ├── README.md │ │ │ ├── bower.json │ │ │ ├── delaunay.js │ │ │ ├── index.html │ │ │ └── package.json │ │ ├── delaunay.gpjs │ │ ├── fragment.fs │ │ ├── generate.js │ │ └── vertex.vs │ ├── Mesh Shader │ │ ├── mesh.gpjs │ │ ├── textured.frag │ │ └── triangle.mesh │ ├── Nonuniform Indexing │ │ ├── attributeless.vs │ │ ├── nonuniform.gpjs │ │ └── textured.fs │ ├── Order-independent transparency │ │ ├── OrbitCamera.js │ │ ├── Readme.md │ │ ├── alpha.frag │ │ ├── compositing.frag │ │ ├── compositing.vert │ │ ├── cube.bin │ │ ├── cube.vert │ │ ├── cube_instanced.vert │ │ ├── generate_particles.js │ │ └── oit.gpjs │ ├── Paint │ │ ├── line.vs │ │ ├── paint.fs │ │ └── paint.gpjs │ ├── Particles │ │ ├── Particles.gpjs │ │ ├── particle.comp │ │ ├── particle.fs │ │ ├── particle.vs │ │ ├── reset.comp │ │ └── update.comp │ ├── Printf │ │ ├── attributeless.vs │ │ ├── printf.fs │ │ └── printf.gpjs │ ├── Quad │ │ ├── attributeless.vs │ │ ├── marble.png │ │ ├── quad.gpjs │ │ └── textured.fs │ ├── Ray Tracing In Vulkan 2 │ │ ├── Material.glsl │ │ ├── ProceduralHit.glsl │ │ ├── Random.glsl │ │ ├── RayPayload.glsl │ │ ├── RayTracing.rchit │ │ ├── RayTracing.rgen │ │ ├── RayTracing.rmiss │ │ ├── Scatter.glsl │ │ ├── UniformBufferObject.glsl │ │ ├── Vertex.glsl │ │ ├── camera.js │ │ ├── generateScene.js │ │ └── raytracing.gpjs │ ├── Ray Tracing In Vulkan │ │ ├── Material.glsl │ │ ├── README.md │ │ ├── Random.glsl │ │ ├── RayPayload.glsl │ │ ├── RayTracing.Procedural.rchit │ │ ├── RayTracing.Procedural.rint │ │ ├── RayTracing.rgen │ │ ├── RayTracing.rmiss │ │ ├── Scatter.glsl │ │ ├── UniformBufferObject.glsl │ │ ├── camera.js │ │ ├── generateSpheres.js │ │ └── raytracing.gpjs │ ├── Shadertoy 2 │ │ ├── Font 1.png │ │ ├── RGBA Noise Medium.png │ │ ├── attributeless.vs │ │ ├── bufferA.fs │ │ ├── image.fs │ │ ├── keyboard.js │ │ ├── shadertoy.fs │ │ └── shadertoy.gpjs │ ├── Shadertoy │ │ ├── Script.js │ │ ├── attributeless.vs │ │ ├── image.fs │ │ ├── shadertoy.fs │ │ └── shadertoy.gpjs │ ├── Stencil Buffer │ │ ├── attributeless.vs │ │ ├── fill.fs │ │ ├── mask.fs │ │ └── stencil.gpjs │ ├── Subroutine │ │ ├── attributeless.vs │ │ ├── subroutine.fs │ │ └── subroutine.gpjs │ ├── Sync Test │ │ ├── attributeless.vs │ │ ├── sync.frag │ │ └── synctest.gpjs │ ├── Tessellation │ │ ├── geodesic.frag │ │ ├── geodesic.geom │ │ ├── geodesic.tesc │ │ ├── geodesic.tese │ │ ├── geodesic.vert │ │ ├── geodesic_indices.bin │ │ ├── geodesic_positions.bin │ │ ├── math.js │ │ └── tessellation.gpjs │ ├── Uniforms │ │ ├── Uniforms.gpjs │ │ └── uniforms.comp │ ├── Video │ │ ├── attributeless.vs │ │ ├── robin.mp4 │ │ ├── textured.fs │ │ └── video.gpjs │ ├── Volume │ │ ├── fill.comp │ │ └── volume.gpjs │ └── gltf Viewer │ │ ├── DamagedHelmet │ │ ├── DamagedHelmet.bin │ │ ├── DamagedHelmet.gltf │ │ ├── Default_AO.jpg │ │ ├── Default_albedo.jpg │ │ ├── Default_emissive.jpg │ │ ├── Default_metalRoughness.jpg │ │ └── Default_normal.jpg │ │ ├── Readme.md │ │ ├── gltf-Viewer.gpjs │ │ ├── gltf-viewer │ │ ├── animation.vert │ │ ├── brdfLUT.png │ │ ├── functions.frag │ │ ├── header.frag │ │ ├── header.vert │ │ ├── metallic-roughness.frag │ │ ├── papermill │ │ │ ├── papermill_irr.ktx │ │ │ └── papermill_pmrem.ktx │ │ ├── primitive.vert │ │ ├── textures.frag │ │ └── tonemapping.frag │ │ └── math.js ├── share │ ├── applications │ │ └── io.github.houmain.gpupad.desktop │ ├── metainfo │ │ └── io.github.houmain.gpupad.metainfo.xml │ └── pixmaps │ │ └── io.github.houmain.gpupad.png ├── themes │ ├── base16-apprentice-scheme │ │ └── apprentice.yaml │ ├── base16-atlas-scheme │ │ ├── LICENSE │ │ └── atlas.yaml │ ├── base16-darcula-scheme │ │ └── darcula.yaml │ ├── base16-default-scheme │ │ ├── eighties.yaml │ │ ├── mocha.yaml │ │ └── ocean.yaml │ ├── base16-equilibrium-scheme │ │ ├── LICENSE │ │ ├── equilibrium-dark.yaml │ │ ├── equilibrium-gray-dark.yaml │ │ ├── equilibrium-gray-light.yaml │ │ └── equilibrium-light.yaml │ ├── base16-helios-scheme │ │ ├── LICENSE │ │ └── helios.yaml │ └── base16-woodland-scheme │ │ ├── LICENSE.md │ │ └── woodland.yaml └── wix │ ├── banner.png │ └── dialog.png ├── libs ├── SingleApplication │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── singleapplication.cpp │ ├── singleapplication.h │ ├── singleapplication_p.cpp │ └── singleapplication_p.h ├── dllreflect │ ├── CMakeLists.txt │ ├── include │ │ └── dllreflect.h │ └── test.cpp ├── spirv-reflect │ ├── LICENSE │ ├── README.md │ ├── include │ │ └── spirv │ │ │ └── unified1 │ │ │ └── spirv.h │ ├── spirv_reflect.c │ ├── spirv_reflect.cpp │ └── spirv_reflect.h └── stb │ └── stb_image_resize2.h ├── screenshot1.png ├── screenshot2.png └── src ├── .clang-format ├── EditActions.h ├── Evaluation.h ├── FileCache.cpp ├── FileCache.h ├── FileDialog.cpp ├── FileDialog.h ├── InputState.cpp ├── InputState.h ├── MessageList.cpp ├── MessageList.h ├── Range.h ├── Settings.cpp ├── Settings.h ├── Singletons.cpp ├── Singletons.h ├── SourceType.cpp ├── SourceType.h ├── Style.cpp ├── Style.h ├── SynchronizeLogic.cpp ├── SynchronizeLogic.h ├── TextureData.cpp ├── TextureData.h ├── Theme.cpp ├── Theme.h ├── VideoManager.cpp ├── VideoManager.h ├── VideoPlayer.cpp ├── VideoPlayer.h ├── editors ├── DockTitle.cpp ├── DockTitle.h ├── DockWindow.cpp ├── DockWindow.h ├── EditorManager.cpp ├── EditorManager.h ├── IEditor.h ├── binary │ ├── BinaryEditor.cpp │ ├── BinaryEditor.h │ ├── BinaryEditorToolBar.cpp │ ├── BinaryEditorToolBar.h │ ├── BinaryEditorToolBar.ui │ ├── BinaryEditor_DataModel.h │ ├── BinaryEditor_EditableRegion.h │ ├── BinaryEditor_HexModel.h │ └── BinaryEditor_SpinBoxDelegate.h ├── qml │ ├── QmlView.cpp │ └── QmlView.h ├── source │ ├── Completer.cpp │ ├── Completer.h │ ├── FindReplaceBar.cpp │ ├── FindReplaceBar.h │ ├── FindReplaceBar.ui │ ├── MultiTextCursors.cpp │ ├── MultiTextCursors.h │ ├── SourceEditor.cpp │ ├── SourceEditor.h │ ├── SourceEditorToolBar.cpp │ ├── SourceEditorToolBar.h │ ├── SourceEditorToolBar.ui │ ├── Syntax.h │ ├── SyntaxGLSL.cpp │ ├── SyntaxGeneric.cpp │ ├── SyntaxHLSL.cpp │ ├── SyntaxHighlighter.cpp │ ├── SyntaxHighlighter.h │ └── SyntaxJavaScript.cpp └── texture │ ├── GLWidget.cpp │ ├── GLWidget.h │ ├── Histogram.cpp │ ├── Histogram.h │ ├── TextureBackground.cpp │ ├── TextureBackground.h │ ├── TextureEditor.cpp │ ├── TextureEditor.h │ ├── TextureEditorToolBar.cpp │ ├── TextureEditorToolBar.h │ ├── TextureEditorToolBar.ui │ ├── TextureInfoBar.cpp │ ├── TextureInfoBar.h │ ├── TextureInfoBar.ui │ ├── TextureItem.cpp │ └── TextureItem.h ├── getEventPosition.h ├── icons ├── dark │ ├── icons │ │ ├── accessories-text-editor.svg │ │ ├── application-exit.svg │ │ ├── applications-system.svg │ │ ├── dialog-error.svg │ │ ├── dialog-information.svg │ │ ├── dialog-warning.svg │ │ ├── document-new.svg │ │ ├── document-open-recent.svg │ │ ├── document-open.svg │ │ ├── document-properties.svg │ │ ├── document-save-as.svg │ │ ├── document-save.svg │ │ ├── edit-copy.svg │ │ ├── edit-cut.svg │ │ ├── edit-delete.svg │ │ ├── edit-find-replace.svg │ │ ├── edit-paste.svg │ │ ├── edit-redo.svg │ │ ├── edit-undo.svg │ │ ├── folder-pictures.svg │ │ ├── folder.svg │ │ ├── font-select.svg │ │ ├── format-indent-more.svg │ │ ├── format-justify-left.svg │ │ ├── hamburger-menu.svg │ │ ├── help-about.svg │ │ ├── help-browser.svg │ │ ├── help-faq.svg │ │ ├── insert-text.svg │ │ ├── mail-attachment.svg │ │ ├── media-playback-pause.svg │ │ ├── media-playback-start-rtl.svg │ │ ├── media-playback-start.svg │ │ ├── media-seek-forward.svg │ │ ├── media-skip-forward.svg │ │ ├── pan-end.svg │ │ ├── pan-start.svg │ │ ├── preferences-desktop-font.svg │ │ ├── preferences-system-notifications.svg │ │ ├── process-stop.svg │ │ ├── user-bookmarks.svg │ │ ├── utilities-terminal.svg │ │ ├── video-display.svg │ │ ├── view-refresh.svg │ │ ├── wrap-lines.svg │ │ ├── x-office-spreadsheet.svg │ │ ├── zoom-fit-best.svg │ │ └── zoom-original.svg │ └── index.theme └── light │ ├── icons │ ├── accessories-text-editor.svg │ ├── application-exit.svg │ ├── applications-system.svg │ ├── dialog-error.svg │ ├── dialog-information.svg │ ├── dialog-warning.svg │ ├── document-new.svg │ ├── document-open-recent.svg │ ├── document-open.svg │ ├── document-properties.svg │ ├── document-save-as.svg │ ├── document-save.svg │ ├── edit-copy.svg │ ├── edit-cut.svg │ ├── edit-delete.svg │ ├── edit-find-replace.svg │ ├── edit-paste.svg │ ├── edit-redo.svg │ ├── edit-undo.svg │ ├── folder-pictures.svg │ ├── folder.svg │ ├── font-select.svg │ ├── format-indent-more.svg │ ├── format-justify-left.svg │ ├── hamburger-menu.svg │ ├── help-about.svg │ ├── help-browser.svg │ ├── help-faq.svg │ ├── insert-text.svg │ ├── mail-attachment.svg │ ├── media-playback-pause.svg │ ├── media-playback-start-rtl.svg │ ├── media-playback-start.svg │ ├── media-seek-forward.svg │ ├── media-skip-forward.svg │ ├── pan-end.svg │ ├── pan-start.svg │ ├── preferences-desktop-font.svg │ ├── preferences-system-notifications.svg │ ├── process-stop.svg │ ├── user-bookmarks.svg │ ├── utilities-terminal.svg │ ├── video-display.svg │ ├── view-refresh.svg │ ├── wrap-lines.svg │ ├── x-office-spreadsheet.svg │ ├── zoom-fit-best.svg │ └── zoom-original.svg │ └── index.theme ├── images ├── 16x16 │ └── window-close.png ├── 32x32 │ └── icon.png ├── 64x64 │ └── icon.png ├── dock-close.png ├── dock-restore.png ├── icon.ico └── icon.svg ├── main.cpp ├── qt6.natvis ├── render ├── ComputeRange.h ├── ProcessSource.cpp ├── ProcessSource.h ├── RenderSessionBase.cpp ├── RenderSessionBase.h ├── RenderTask.cpp ├── RenderTask.h ├── Renderer.h ├── ShaderBase.cpp ├── ShaderBase.h ├── ShaderPrintf.cpp ├── ShaderPrintf.h ├── ShareSync.h ├── Spirv.cpp ├── Spirv.h ├── SpirvInterface.cpp ├── TextureBase.cpp ├── TextureBase.h ├── opengl │ ├── GLBuffer.cpp │ ├── GLBuffer.h │ ├── GLCall.cpp │ ├── GLCall.h │ ├── GLComputeRange.cpp │ ├── GLComputeRange.h │ ├── GLContext.h │ ├── GLItem.h │ ├── GLObject.h │ ├── GLPrintf.cpp │ ├── GLPrintf.h │ ├── GLProgram.cpp │ ├── GLProgram.h │ ├── GLRenderSession.cpp │ ├── GLRenderSession.h │ ├── GLRenderer.cpp │ ├── GLRenderer.h │ ├── GLShader.cpp │ ├── GLShader.h │ ├── GLShareSync.h │ ├── GLStream.cpp │ ├── GLStream.h │ ├── GLTarget.cpp │ ├── GLTarget.h │ ├── GLTexture.cpp │ └── GLTexture.h └── vulkan │ ├── KDGpuEnums.cpp │ ├── KDGpuEnums.h │ ├── VKAccelerationStructure.cpp │ ├── VKAccelerationStructure.h │ ├── VKBuffer.cpp │ ├── VKBuffer.h │ ├── VKCall.cpp │ ├── VKCall.h │ ├── VKContext.h │ ├── VKItem.h │ ├── VKPipeline.cpp │ ├── VKPipeline.h │ ├── VKPrintf.cpp │ ├── VKPrintf.h │ ├── VKProgram.cpp │ ├── VKProgram.h │ ├── VKRenderSession.cpp │ ├── VKRenderSession.h │ ├── VKRenderer.cpp │ ├── VKRenderer.h │ ├── VKShader.cpp │ ├── VKShader.h │ ├── VKShareSync.h │ ├── VKStream.cpp │ ├── VKStream.h │ ├── VKTarget.cpp │ ├── VKTarget.h │ ├── VKTexture.cpp │ └── VKTexture.h ├── resources.qrc ├── resources.rc ├── scripting ├── CustomActions.cpp ├── CustomActions.h ├── IScriptRenderSession.h ├── ScriptEngine.cpp ├── ScriptEngine.h ├── ScriptEngine.js ├── ScriptSession.cpp ├── ScriptSession.h └── objects │ ├── AppScriptObject.cpp │ ├── AppScriptObject.h │ ├── ConsoleScriptObject.cpp │ ├── ConsoleScriptObject.h │ ├── EditorScriptObject.cpp │ ├── EditorScriptObject.h │ ├── KeyboardScriptObject.cpp │ ├── KeyboardScriptObject.h │ ├── LibraryScriptObject.cpp │ ├── LibraryScriptObject.h │ ├── MouseScriptObject.cpp │ ├── MouseScriptObject.h │ ├── SessionScriptObject.cpp │ └── SessionScriptObject.h ├── session ├── AccelerationStructureProperties.ui ├── AttachmentProperties.cpp ├── AttachmentProperties.h ├── AttachmentProperties.ui ├── AttributeProperties.ui ├── BindingProperties.cpp ├── BindingProperties.h ├── BindingProperties.ui ├── BlockProperties.ui ├── BufferProperties.ui ├── CallProperties.cpp ├── CallProperties.h ├── CallProperties.ui ├── ColorMask.cpp ├── ColorMask.h ├── ColorPicker.cpp ├── ColorPicker.h ├── DataComboBox.cpp ├── DataComboBox.h ├── ExpressionEditor.cpp ├── ExpressionEditor.h ├── ExpressionLineEdit.cpp ├── ExpressionLineEdit.h ├── ExpressionMatrix.cpp ├── ExpressionMatrix.h ├── FieldProperties.ui ├── GeometryProperties.ui ├── GroupProperties.ui ├── InstanceProperties.ui ├── Item.cpp ├── Item.h ├── ItemEnums.h ├── ProgramProperties.ui ├── PropertiesEditor.cpp ├── PropertiesEditor.h ├── ReferenceComboBox.cpp ├── ReferenceComboBox.h ├── ScriptProperties.ui ├── SessionEditor.cpp ├── SessionEditor.h ├── SessionModel.cpp ├── SessionModel.h ├── SessionModelCore.cpp ├── SessionModelCore.h ├── SessionModelPriv.h ├── SessionProperties.cpp ├── SessionProperties.h ├── SessionProperties.ui ├── ShaderProperties.ui ├── StreamProperties.ui ├── TargetProperties.ui ├── TextureProperties.cpp ├── TextureProperties.h └── TextureProperties.ui ├── version.h.in └── windows ├── AboutDialog.cpp ├── AboutDialog.h ├── AutoOrientationSplitter.h ├── FileBrowserWindow.cpp ├── FileBrowserWindow.h ├── MainWindow.cpp ├── MainWindow.h ├── MainWindow.ui ├── MessageWindow.cpp ├── MessageWindow.h ├── OutputWindow.cpp ├── OutputWindow.h ├── WindowTitle.cpp └── WindowTitle.h /.gitignore: -------------------------------------------------------------------------------- 1 | /_* 2 | /src/_version.h 3 | /**/build/ 4 | /vcpkg/ 5 | /*.user 6 | /extra/samples/**/*.gpjs.state 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "libs/KDGpu"] 2 | path = libs/KDGpu 3 | url = https://github.com/houmain/KDGpu 4 | branch = main 5 | -------------------------------------------------------------------------------- /extra/actions/Compile all shader files to Spir-V.js: -------------------------------------------------------------------------------- 1 | 2 | for (let shader of app.session.findItems(item => item.type == 'Shader')) { 3 | const result = app.session.processShader(shader, "spirvBinary") 4 | if (typeof(result) == 'string') { 5 | console.error(result) 6 | } 7 | else { 8 | app.writeBinaryFile(shader.fileName + '.spv', result) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /extra/actions/GenerateMesh/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(GenerateMesh LANGUAGES C CXX) 3 | 4 | add_library(${PROJECT_NAME} SHARED 5 | module.cpp 6 | ${CMAKE_SOURCE_DIR}/libs/dllreflect/include/dllreflect.h 7 | ) 8 | include_directories(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libs/dllreflect/include) 9 | -------------------------------------------------------------------------------- /extra/actions/GenerateMesh/DoubleSpinBox.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2 | import QtQuick.Controls 3 | 4 | Item { 5 | property int decimals: 2 6 | property real value: 0.0 7 | property real from: 0.0 8 | property real to: 100.0 9 | property real stepSize: 1.0 10 | property alias editable: spinbox.editable 11 | signal valueModified 12 | 13 | SpinBox{ 14 | id: spinbox 15 | property real factor: Math.pow(10, decimals) 16 | width: parent.width 17 | height: parent.height 18 | stepSize: parent.stepSize * factor 19 | value: parent.value * factor 20 | to: parent.to * factor 21 | from: parent.from * factor 22 | 23 | validator: RegularExpressionValidator { 24 | regularExpression: /[0-9]+[.]?[0-9]+/ 25 | } 26 | 27 | valueFromText: function(text, locale) { 28 | return Number.fromLocaleString(locale, text) * factor + 0.5 29 | } 30 | 31 | textFromValue: function(value, locale) { 32 | return parseFloat(value / factor).toFixed(decimals) 33 | } 34 | 35 | onValueModified: { 36 | parent.value = value / factor 37 | parent.valueModified() 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /extra/actions/ImportOBJ/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(ImportOBJ LANGUAGES C CXX) 3 | 4 | add_library(${PROJECT_NAME} SHARED 5 | module.cpp 6 | ${CMAKE_SOURCE_DIR}/libs/dllreflect/include/dllreflect.h 7 | ) 8 | include_directories(${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/libs/dllreflect/include) 9 | -------------------------------------------------------------------------------- /extra/actions/ImportOBJ/DoubleSpinBox.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2 | import QtQuick.Controls 3 | 4 | Item { 5 | property int decimals: 2 6 | property real value: 0.0 7 | property real from: 0.0 8 | property real to: 100.0 9 | property real stepSize: 1.0 10 | property alias editable: spinbox.editable 11 | signal valueModified 12 | 13 | SpinBox{ 14 | id: spinbox 15 | property real factor: Math.pow(10, decimals) 16 | width: parent.width 17 | height: parent.height 18 | stepSize: parent.stepSize * factor 19 | value: parent.value * factor 20 | to: parent.to * factor 21 | from: parent.from * factor 22 | 23 | validator: RegularExpressionValidator { 24 | regularExpression: /[0-9]+[.]?[0-9]+/ 25 | } 26 | 27 | valueFromText: function(text, locale) { 28 | return Number.fromLocaleString(locale, text) * factor + 0.5 29 | } 30 | 31 | textFromValue: function(value, locale) { 32 | return parseFloat(value / factor).toFixed(decimals) 33 | } 34 | 35 | onValueModified: { 36 | parent.value = value / factor 37 | parent.valueModified() 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /extra/qml/imports.qml: -------------------------------------------------------------------------------- 1 | import QtQuick 2.12 2 | import QtQuick.Shapes 1.15 3 | import QtQuick.Controls 2.12 4 | 5 | Shape { 6 | } 7 | -------------------------------------------------------------------------------- /extra/samples/Atomic Counters/atomics.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | layout (local_size_x = 1) in; 4 | 5 | layout(binding = 0, offset = 0) uniform atomic_uint uCounter0; 6 | layout(binding = 0, offset = 4) uniform atomic_uint uCounter1; 7 | 8 | layout(std430) buffer uCounters2 { 9 | uint uCounter2; 10 | uint uCounter3; 11 | }; 12 | 13 | layout(rgba8ui) uniform uimageBuffer uData; 14 | 15 | void main() { 16 | // increment counter0 in ACB once 17 | uint pos = atomicCounterIncrement(uCounter0); 18 | 19 | // increment counter1 in ACB twice 20 | atomicCounterIncrement(uCounter1); 21 | atomicCounterIncrement(uCounter1); 22 | 23 | // increment counter2 and counter3 in SSBO 24 | atomicAdd(uCounter2, 1); 25 | atomicAdd(uCounter3, 2); 26 | 27 | // use atomic values to update a texture buffer 28 | uint size = imageSize(uData).x; 29 | imageStore(uData, int(pos % size), uvec4(pos % 256, gl_GlobalInvocationID.x, 0, 0)); 30 | } 31 | -------------------------------------------------------------------------------- /extra/samples/Bindless Texture/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 pos[4] = vec2[]( 4 | vec2(-1,-1), 5 | vec2( 1,-1), 6 | vec2(-1, 1), 7 | vec2( 1, 1) 8 | ); 9 | 10 | const vec2 uv[4] = vec2[]( 11 | vec2(0, 1), 12 | vec2(1, 1), 13 | vec2(0, 0), 14 | vec2(1, 0) 15 | ); 16 | 17 | out vec2 vTexCoords; 18 | 19 | void main() { 20 | vTexCoords = uv[gl_VertexID]; 21 | gl_Position = vec4(pos[gl_VertexID], 0.0, 1.0); 22 | } 23 | -------------------------------------------------------------------------------- /extra/samples/Bindless Texture/setHandles.js: -------------------------------------------------------------------------------- 1 | 2 | let names = [ 3 | "marble.png", 4 | "planks.jpg", 5 | ] 6 | 7 | let handles = [] 8 | for (let name of names) 9 | handles.push(app.session.getTextureHandle(name)) 10 | 11 | app.session.setBufferData("Buffer", handles) 12 | -------------------------------------------------------------------------------- /extra/samples/Bindless Texture/textured.fs: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_bindless_texture : require 3 | 4 | layout(std430) readonly buffer bTextures { 5 | sampler2D textures[]; 6 | }; 7 | 8 | in vec2 vTexCoords; 9 | out vec4 oColor; 10 | 11 | void main() { 12 | uint index = uint(vTexCoords.x * textures.length()); 13 | oColor = texture(textures[index], vTexCoords); 14 | } 15 | -------------------------------------------------------------------------------- /extra/samples/Bitonic sort/BitonicSort.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #define BITONIC_BLOCK_SIZE 512 4 | 5 | layout(local_size_x = BITONIC_BLOCK_SIZE) in; 6 | layout(binding = 0, std430) buffer bData { uint data[]; }; 7 | 8 | uniform uvec4 uConstants; 9 | 10 | shared uint shared_data[BITONIC_BLOCK_SIZE]; 11 | 12 | void main() { 13 | uvec3 DTid = gl_GlobalInvocationID; 14 | uint GI = gl_LocalInvocationIndex; 15 | uint level = uConstants.x; 16 | uint levelMask = uConstants.y; 17 | 18 | // Load shared data 19 | shared_data[GI] = data[DTid.x]; 20 | barrier(); 21 | 22 | // Sort the shared data 23 | for (uint j = level >> 1 ; j > 0 ; j >>= 1) { 24 | uint result = ((shared_data[GI & ~j] <= shared_data[GI | j]) == 25 | bool(levelMask & DTid.x)) ? shared_data[GI ^ j] : shared_data[GI]; 26 | barrier(); 27 | shared_data[GI] = result; 28 | barrier(); 29 | } 30 | // Store shared data 31 | data[DTid.x] = shared_data[GI]; 32 | } 33 | -------------------------------------------------------------------------------- /extra/samples/Bitonic sort/FillRandom.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(local_size_x = 32) in; 4 | layout(binding = 0, std430) writeonly buffer bData { uint data[]; }; 5 | 6 | void main() { 7 | uint gid = gl_GlobalInvocationID.x; 8 | if(gid < data.length()) { 9 | data[gid] = (gid * 123456789) % 1000000; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /extra/samples/Bitonic sort/MatrixTranspose.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #define TRANSPOSE_BLOCK_SIZE 16 4 | 5 | layout(local_size_x = TRANSPOSE_BLOCK_SIZE, local_size_y = TRANSPOSE_BLOCK_SIZE) in; 6 | layout(binding = 0, std430) buffer bData { uint data[]; }; 7 | layout(binding = 1, std430) readonly buffer bInput { uint inputData[]; }; 8 | 9 | uniform uvec4 uConstants; 10 | 11 | shared uint transpose_shared_data[TRANSPOSE_BLOCK_SIZE * TRANSPOSE_BLOCK_SIZE]; 12 | 13 | void main() { 14 | uvec3 DTid = gl_GlobalInvocationID; 15 | uvec3 GTid = gl_LocalInvocationID; 16 | uint GI = gl_LocalInvocationIndex; 17 | uint width = uConstants.z; 18 | uint height = uConstants.w; 19 | 20 | transpose_shared_data[GI] = inputData[DTid.y * width + DTid.x]; 21 | barrier(); 22 | uvec2 XY = DTid.yx - GTid.yx + GTid.xy; 23 | data[XY.y * height + XY.x] = 24 | transpose_shared_data[GTid.x * TRANSPOSE_BLOCK_SIZE + GTid.y]; 25 | } 26 | -------------------------------------------------------------------------------- /extra/samples/Buffer Reference/buffer_reference.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(location = 0) in vec3 color; 4 | 5 | layout(location = 0) out vec4 fragColor; 6 | 7 | void main() 8 | { 9 | fragColor = vec4(color, 1.0); 10 | } 11 | -------------------------------------------------------------------------------- /extra/samples/Buffer Reference/buffer_reference.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_buffer_reference : enable 3 | #extension GL_EXT_scalar_block_layout : enable 4 | #extension GL_ARB_gpu_shader_int64 : enable 5 | 6 | const vec2 pos[4] = vec2[]( 7 | vec2(-1,-1), 8 | vec2( 1,-1), 9 | vec2(-1, 1), 10 | vec2( 1, 1) 11 | ); 12 | 13 | layout(location = 0) out vec3 color; 14 | 15 | // The reference to our buffer, aligned to 16 bytes (vec4) 16 | layout(buffer_reference, scalar, buffer_reference_align = 16) buffer VertexColors 17 | { 18 | vec4 colors[]; 19 | }; 20 | 21 | // Push constant holding the address of our VertexColors buffer 22 | layout(push_constant) uniform PushConstants 23 | { 24 | uint64_t vertexColors; 25 | } 26 | bufferReferences; 27 | 28 | void main() 29 | { 30 | VertexColors vColors = VertexColors(bufferReferences.vertexColors); // Retrieve Buffer from its address 31 | color = vColors.colors[gl_VertexIndex].rgb; 32 | gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0); 33 | } 34 | -------------------------------------------------------------------------------- /extra/samples/Buffer Reference/colors.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Buffer Reference/colors.bin -------------------------------------------------------------------------------- /extra/samples/Buffer Reference/setHandles.js: -------------------------------------------------------------------------------- 1 | 2 | let handles = [ 3 | app.session.getBufferHandle("colors.bin") 4 | ] 5 | 6 | app.session.setBufferData("BufferReferences", handles) 7 | -------------------------------------------------------------------------------- /extra/samples/Compute/gameoflife.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | layout (rgba8) uniform image2D uImageR; 4 | layout (rgba8) uniform image2D uImageW; 5 | layout (local_size_x = 16, local_size_y = 16) in; 6 | 7 | void main() { 8 | ivec2 size = imageSize(uImageR); 9 | ivec2 pos = ivec2(gl_GlobalInvocationID.xy); 10 | 11 | bool alive = false; 12 | int neighbors = 0; 13 | for (int y = -1; y <= 1; y++) 14 | for (int x = -1; x <= 1; x++) { 15 | ivec2 wrapped = (pos + ivec2(x, y) + size) % size; 16 | if (imageLoad(uImageR, wrapped).r == 0) { 17 | if (x == 0 && y == 0) 18 | alive = true; 19 | else 20 | neighbors++; 21 | } 22 | } 23 | 24 | if (alive) { 25 | if (neighbors < 2 || neighbors > 3) 26 | alive = false; 27 | } 28 | else { 29 | if (neighbors == 3) 30 | alive = true; 31 | } 32 | 33 | // create life 34 | if (floor(length(pos - size/2)) == size.x/3) 35 | alive = !alive; 36 | 37 | imageStore(uImageW, pos, vec4(vec3(alive ? 0 : 1), 1)); 38 | } 39 | -------------------------------------------------------------------------------- /extra/samples/Cube HLSL/cube.fx: -------------------------------------------------------------------------------- 1 | 2 | matrix uModel; 3 | matrix uView; 4 | matrix uProjection; 5 | float3 uAmbient; 6 | 7 | Texture2D uTexture; 8 | SamplerState sampleLinear; 9 | 10 | struct VS_INPUT { 11 | float4 position : POSITION; 12 | float3 normal : NORMAL; 13 | float2 texCoords : TEXCOORD0; 14 | }; 15 | 16 | struct PS_INPUT { 17 | float4 position : SV_POSITION; 18 | float3 normal : NORMAL; 19 | float2 texCoords : TEXCOORD0; 20 | }; 21 | 22 | PS_INPUT VS(VS_INPUT input) { 23 | PS_INPUT output = (PS_INPUT)0; 24 | output.position = mul(mul(mul(uProjection, uView), uModel), input.position); 25 | output.normal = mul(uModel, float4(input.normal, 0)).xyz; 26 | output.texCoords = input.texCoords; 27 | return output; 28 | } 29 | 30 | float4 PS(PS_INPUT input) : SV_Target { 31 | const float3 light = normalize(float3(-1, 3, 2)); 32 | const float3 normal = normalize(input.normal); 33 | float3 albedo = uTexture.Sample(sampleLinear, input.texCoords).rgb; 34 | float3 diffuse = float3(1) * max(dot(normal, light), 0.0); 35 | float3 color = albedo * (uAmbient + diffuse); 36 | return float4(color, 1); 37 | } 38 | -------------------------------------------------------------------------------- /extra/samples/Cube HLSL/cube_position_normal_texcoords.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Cube HLSL/cube_position_normal_texcoords.bin -------------------------------------------------------------------------------- /extra/samples/Cube HLSL/math.js: -------------------------------------------------------------------------------- 1 | 2 | function rotateY(t) { 3 | var s = Math.sin(t); 4 | var c = Math.cos(t); 5 | return [ 6 | c, 0,-s, 0, 7 | 0, 1, 0, 0, 8 | s, 0, c, 0, 9 | 0, 0, 0, 1 10 | ]; 11 | } 12 | 13 | function perspective(fovy, aspect, near, far) { 14 | var y = 1 / Math.tan(fovy / 2 * Math.PI / 180); 15 | var x = y / aspect; 16 | var c = (near + far) / (near - far); 17 | var d = (near * far) / (near - far) * 2; 18 | return [ 19 | x, 0, 0, 0, 20 | 0, y, 0, 0, 21 | 0, 0, c,-1, 22 | 0, 0, d, 0 23 | ]; 24 | } 25 | -------------------------------------------------------------------------------- /extra/samples/Cube HLSL/planks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Cube HLSL/planks.jpg -------------------------------------------------------------------------------- /extra/samples/Cube/cube.fs: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform vec3 uAmbient; 4 | 5 | uniform sampler2D uTexture; 6 | 7 | in vec2 vTexCoords; 8 | in vec3 vNormal; 9 | out vec4 oColor; 10 | 11 | void main() { 12 | const vec3 light = normalize(vec3(-1, 3, 2)); 13 | const vec3 normal = normalize(vNormal); 14 | vec3 albedo = texture(uTexture, vTexCoords).rgb; 15 | vec3 diffuse = vec3(1) * max(dot(normal, light), 0.0); 16 | vec3 color = albedo * (uAmbient + diffuse); 17 | oColor = vec4(color, 1); 18 | } 19 | -------------------------------------------------------------------------------- /extra/samples/Cube/cube.vs: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform mat4 uModel; 4 | uniform mat4 uView; 5 | uniform mat4 uProjection; 6 | 7 | in vec3 aPosition; 8 | in vec3 aNormal; 9 | in vec2 aTexCoords; 10 | 11 | out vec2 vTexCoords; 12 | out vec3 vNormal; 13 | 14 | void main() { 15 | vTexCoords = aTexCoords; 16 | vNormal = (uModel * vec4(aNormal, 0)).xyz; 17 | gl_Position = uProjection * uView * uModel * vec4(aPosition, 1); 18 | } 19 | -------------------------------------------------------------------------------- /extra/samples/Cube/cube_position_normal_texcoords.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Cube/cube_position_normal_texcoords.bin -------------------------------------------------------------------------------- /extra/samples/Cube/math.js: -------------------------------------------------------------------------------- 1 | 2 | function rotateY(t) { 3 | var s = Math.sin(t); 4 | var c = Math.cos(t); 5 | return [ 6 | c, 0,-s, 0, 7 | 0, 1, 0, 0, 8 | s, 0, c, 0, 9 | 0, 0, 0, 1 10 | ]; 11 | } 12 | 13 | function perspective(fovy, aspect, near, far) { 14 | var y = 1 / Math.tan(fovy / 2 * Math.PI / 180); 15 | var x = y / aspect; 16 | var c = (near + far) / (near - far); 17 | var d = (near * far) / (near - far) * 2; 18 | return [ 19 | x, 0, 0, 0, 20 | 0, y, 0, 0, 21 | 0, 0, c,-1, 22 | 0, 0, d, 0 23 | ]; 24 | } 25 | -------------------------------------------------------------------------------- /extra/samples/Cube/planks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Cube/planks.jpg -------------------------------------------------------------------------------- /extra/samples/Custom Actions/cube.fs: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform vec3 uAmbient; 4 | 5 | uniform sampler2D uTexture; 6 | 7 | in vec2 vTexCoords; 8 | in vec3 vNormal; 9 | out vec4 oColor; 10 | 11 | void main() { 12 | const vec3 light = normalize(vec3(-1, 3, 2)); 13 | const vec3 normal = normalize(vNormal); 14 | vec3 albedo = texture(uTexture, vTexCoords).rgb; 15 | vec3 diffuse = vec3(1) * max(dot(normal, light), 0.0); 16 | vec3 color = albedo * (uAmbient + diffuse); 17 | oColor = vec4(color, 1); 18 | } 19 | -------------------------------------------------------------------------------- /extra/samples/Custom Actions/cube.vs: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | uniform mat4 uView; 4 | uniform mat4 uProjection; 5 | 6 | in vec3 aPosition; 7 | in vec3 aNormal; 8 | in vec2 aTexCoords; 9 | 10 | out vec2 vTexCoords; 11 | out vec3 vNormal; 12 | 13 | void main() { 14 | vTexCoords = aTexCoords; 15 | vNormal = aNormal; 16 | gl_Position = uProjection * uView * vec4(aPosition, 1); 17 | } 18 | -------------------------------------------------------------------------------- /extra/samples/Custom Actions/meshes/cube/cube.obj: -------------------------------------------------------------------------------- 1 | # Unit-volume cube with the same texture coordinates on each face. 2 | # 3 | # Created by Morgan McGuire and released into the Public Domain on 4 | # July 16, 2011. 5 | # 6 | # http://graphics.cs.williams.edu/data 7 | 8 | mtllib default.mtl 9 | 10 | v -0.5 0.5 -0.5 11 | v -0.5 0.5 0.5 12 | v 0.5 0.5 0.5 13 | v 0.5 0.5 -0.5 14 | v -0.5 -0.5 -0.5 15 | v -0.5 -0.5 0.5 16 | v 0.5 -0.5 0.5 17 | v 0.5 -0.5 -0.5 18 | 19 | vt 0 1 20 | vt 0 0 21 | vt 1 0 22 | vt 1 1 23 | 24 | vn 0 1 0 25 | vn -1 0 0 26 | vn 1 0 0 27 | vn 0 0 -1 28 | vn 0 0 1 29 | vn 0 -1 0 30 | 31 | g cube 32 | usemtl default 33 | 34 | f -8/-4/-6 -7/-3/-6 -6/-2/-6 35 | f -8/-4/-6 -6/-2/-6 -5/-1/-6 36 | f -8/-4/-5 -4/-3/-5 -3/-2/-5 37 | f -8/-4/-5 -3/-2/-5 -7/-1/-5 38 | f -6/-4/-4 -2/-3/-4 -1/-2/-4 39 | f -6/-4/-4 -1/-2/-4 -5/-1/-4 40 | f -5/-4/-3 -1/-3/-3 -4/-2/-3 41 | f -5/-4/-3 -4/-2/-3 -8/-1/-3 42 | f -7/-4/-2 -3/-3/-2 -2/-2/-2 43 | f -7/-4/-2 -2/-2/-2 -6/-1/-2 44 | f -3/-4/-1 -4/-3/-1 -1/-2/-1 45 | f -3/-4/-1 -1/-2/-1 -2/-1/-1 46 | -------------------------------------------------------------------------------- /extra/samples/Custom Actions/meshes/cube/default.mtl: -------------------------------------------------------------------------------- 1 | # Default material file. Created by Morgan McGuire and released into 2 | # the Public Domain on July 16, 2011. 3 | # 4 | # http://graphics.cs.williams.edu/data 5 | 6 | newmtl default 7 | Ns 10.0000 8 | Ni 1.5000 9 | Tr 0 illum 2 10 | Ka 1 1 1 11 | Kd 1 1 1 12 | Ks 0.2 0.2 0.2 13 | Ke 0 0 0 14 | map_Kd default.png 15 | -------------------------------------------------------------------------------- /extra/samples/Custom Actions/meshes/cube/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Custom Actions/meshes/cube/default.png -------------------------------------------------------------------------------- /extra/samples/Custom Actions/meshes/teapot/default.mtl: -------------------------------------------------------------------------------- 1 | # Default material file. Created by Morgan McGuire and released into 2 | # the Public Domain on July 16, 2011. 3 | # 4 | # http://graphics.cs.williams.edu/data 5 | 6 | newmtl default 7 | Ns 10.0000 8 | Ni 1.5000 9 | d 1.0000 10 | Tr 0 0 11 | Tf 1 1 1 12 | illum 2 13 | Ka 1 1 1 14 | Kd 1 1 1 15 | Ks 0.2 0.2 0.2 16 | Ke 0 0 0 17 | map_Kd default.png 18 | -------------------------------------------------------------------------------- /extra/samples/Custom Actions/meshes/teapot/default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Custom Actions/meshes/teapot/default.png -------------------------------------------------------------------------------- /extra/samples/Custom Actions/script.js: -------------------------------------------------------------------------------- 1 | 2 | // cycle through OBJ files in directory 3 | if (!this.files) 4 | this.files = app.enumerateFiles("**/*.obj") 5 | 6 | const meshTypes = [ 7 | "Cylinder", 8 | "Icosahedron", 9 | "Dodecahedron", 10 | "Octahedron", 11 | "Tetrahedron", 12 | ] 13 | 14 | const total = meshTypes.length + this.files.length 15 | const index = app.frameIndex % total 16 | 17 | if (index < this.files.length) { 18 | group = app.callAction("ImportOBJ", { 19 | fileName = this.files[index], 20 | name = "Mesh", 21 | group = app.session.findItem("Mesh"), 22 | indexed = true, 23 | dynamic = true, 24 | normalize = true, 25 | center = true, 26 | }) 27 | console.log(`Wavefront OBJ (${index + 1}/${this.files.length}): '${this.files[index]}'`) 28 | } 29 | else { 30 | const meshType = meshTypes[index - this.files.length] 31 | group = app.callAction("GenerateMesh", { 32 | name = "Mesh", 33 | group = app.session.findItem("Mesh"), 34 | indexed = true, 35 | dynamic = true, 36 | type = meshType, 37 | facetted = true, 38 | }) 39 | console.log(`Generated mesh: ${meshType}`) 40 | } 41 | -------------------------------------------------------------------------------- /extra/samples/Indirect/fragment.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | out vec4 oColor; 4 | 5 | void main() { 6 | oColor = vec4(1); 7 | } 8 | -------------------------------------------------------------------------------- /extra/samples/Indirect/generate.glsl: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | layout (local_size_x = 16, local_size_y = 16) in; 4 | 5 | layout(std430, binding=0) buffer uVertexBuffer { 6 | vec2 positions[]; 7 | }; 8 | 9 | uniform int uCountX; 10 | uniform int uCountY; 11 | 12 | void main() { 13 | uint x = gl_GlobalInvocationID.x; 14 | uint y = gl_GlobalInvocationID.y; 15 | if (x >= uCountX || y >= uCountY) 16 | return; 17 | 18 | uint offset = (y * uCountX + x) * 6; 19 | 20 | float sx = 2.0f / uCountX; 21 | float sy = 2.0f / uCountY; 22 | vec2 v0 = vec2((x + 0) * sx, (y + 0) * sy) - vec2(1); 23 | vec2 v1 = vec2((x + 1) * sx, (y + 0) * sy) - vec2(1); 24 | vec2 v2 = vec2((x + 0) * sx, (y + 1) * sy) - vec2(1); 25 | vec2 v3 = vec2((x + 1) * sx, (y + 1) * sy) - vec2(1); 26 | 27 | float indent = 0.3; 28 | 29 | vec2 mid = (v0 + v1 + v2) / 3; 30 | positions[offset + 0] = mix(v0, mid, indent); 31 | positions[offset + 1] = mix(v1, mid, indent); 32 | positions[offset + 2] = mix(v2, mid, indent); 33 | 34 | mid = (v1 + v2 + v3) / 3; 35 | positions[offset + 4] = mix(v1, mid, indent); 36 | positions[offset + 3] = mix(v3, mid, indent); 37 | positions[offset + 5] = mix(v2, mid, indent); 38 | } 39 | -------------------------------------------------------------------------------- /extra/samples/Indirect/setup.glsl: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | layout (local_size_x = 1) in; 4 | 5 | layout(std430, binding=0) buffer uIndirectBuffer { 6 | uint num_groups_x; 7 | uint num_groups_y; 8 | uint num_groups_z; 9 | 10 | uint count; 11 | uint instanceCount; 12 | uint first; 13 | uint baseInstance; 14 | }; 15 | 16 | uniform int uCountX; 17 | uniform int uCountY; 18 | 19 | void main() { 20 | num_groups_x = max(0, uCountX + 15) / 16; 21 | num_groups_y = max(0, uCountY + 15) / 16; 22 | num_groups_z = 1; 23 | 24 | count = max(0, (uCountX * uCountY) * 6); 25 | instanceCount = 1; 26 | first = 0; 27 | baseInstance = 0; 28 | } 29 | -------------------------------------------------------------------------------- /extra/samples/Indirect/vertex.glsl: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec4 aPosition; 4 | 5 | void main() { 6 | gl_Position = aPosition; 7 | } 8 | -------------------------------------------------------------------------------- /extra/samples/Instancing/instances.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Instancing/instances.bin -------------------------------------------------------------------------------- /extra/samples/Instancing/instancing.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec4 vColor; 4 | out vec4 oColor; 5 | 6 | void main() { 7 | oColor = vColor; 8 | } 9 | -------------------------------------------------------------------------------- /extra/samples/Instancing/instancing.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 aPosition; 4 | in vec2 aInstancePosition; 5 | in vec4 aInstanceColor; 6 | 7 | out vec4 vColor; 8 | 9 | void main() { 10 | gl_Position = vec4(aPosition / 3 + aInstancePosition / 2, 0, 1); 11 | vColor = aInstanceColor; 12 | } 13 | -------------------------------------------------------------------------------- /extra/samples/Instancing/vertices.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Instancing/vertices.bin -------------------------------------------------------------------------------- /extra/samples/Javascript Library/delaunay-fast/bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "delaunay-fast", 3 | "main": "delaunay.js", 4 | "version": "1.0.2", 5 | "homepage": "https://github.com/ironwallaby/delaunay", 6 | "authors": [ 7 | "J. T. L." 8 | ], 9 | "description": "Fast Delaunay Triangulation in JavaScript", 10 | "moduleType": [ 11 | "globals", 12 | "node" 13 | ], 14 | "keywords": [ 15 | "delaunay", 16 | "triangulation", 17 | "geometry" 18 | ], 19 | "license": "CC0", 20 | "ignore": [ 21 | "**/.*", 22 | "node_modules", 23 | "bower_components", 24 | "test", 25 | "tests" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /extra/samples/Javascript Library/delaunay-fast/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "delaunay-fast", 3 | "version": "1.0.2", 4 | "description": "Fast Delaunay Triangulation in JavaScript", 5 | "main": "delaunay.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/ironwallaby/delaunay.git" 12 | }, 13 | "keywords": [ 14 | "delaunay", 15 | "triangulation", 16 | "geometry" 17 | ], 18 | "author": "J. T. L.", 19 | "license": "CC0", 20 | "readmeFilename": "README.md", 21 | "gitHead": "95feef2054313410efe336a1618699c4c96e507d" 22 | } 23 | -------------------------------------------------------------------------------- /extra/samples/Javascript Library/fragment.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | out vec4 oColor; 4 | 5 | void main() { 6 | oColor = vec4(vec3(0), 1); 7 | } 8 | -------------------------------------------------------------------------------- /extra/samples/Javascript Library/generate.js: -------------------------------------------------------------------------------- 1 | 2 | let vertices = new Array(count) 3 | for (let i = 0; i < vertices.length; ++i) { 4 | let x, y 5 | do { 6 | x = Math.random() - 0.5 7 | y = Math.random() - 0.5 8 | } while(x * x + y * y > 0.25) 9 | vertices[i] = [x + 0.5, y + 0.5] 10 | } 11 | let indices = Delaunay.triangulate(vertices) 12 | // convert to single array 13 | vertices = [].concat.apply([], vertices) 14 | 15 | app.session.setBlockData('Buffer/Vertices', vertices) 16 | 17 | let Indices = app.session.findItem('Buffer/Indices') 18 | Indices.offset = vertices.length * 4 19 | app.session.setBlockData(Indices, indices) 20 | 21 | let Draw = app.session.findItem('Draw') 22 | Draw.count = indices.length 23 | -------------------------------------------------------------------------------- /extra/samples/Javascript Library/vertex.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 aPosition; 4 | 5 | void main() { 6 | gl_Position = vec4(aPosition * 2 - vec2(1), 0.0, 1.0); 7 | } 8 | -------------------------------------------------------------------------------- /extra/samples/Mesh Shader/textured.frag: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout (location = 0) in PerVertexData 4 | { 5 | vec4 color; 6 | } fragIn; 7 | 8 | layout (location = 0) out vec4 FragColor; 9 | 10 | void main() 11 | { 12 | FragColor = fragIn.color; 13 | } -------------------------------------------------------------------------------- /extra/samples/Mesh Shader/triangle.mesh: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_NV_mesh_shader : require 3 | 4 | layout(local_size_x = 1) in; 5 | layout(triangles, max_vertices = 3, max_primitives = 1) out; 6 | 7 | // Custom vertex output block 8 | layout (location = 0) out PerVertexData { 9 | vec4 color; 10 | } v_out[]; // [max_vertices] 11 | 12 | 13 | float scale = 0.95; 14 | const vec3 vertices[3] = {vec3(-1,-1,0), vec3(0,1,0), vec3(1,-1,0)}; 15 | const vec3 colors[3] = {vec3(1.0,0.0,0.0), vec3(0.0,1.0,0.0), vec3(0.0,0.0,1.0)}; 16 | 17 | void main() { 18 | vec4 pos = vec4(vertices[0] * scale, 1.0); 19 | // GL->VK conventions... 20 | pos.y = -pos.y; pos.z = (pos.z + pos.w) / 2.0; 21 | gl_MeshVerticesNV[0].gl_Position = pos; 22 | 23 | pos = vec4(vertices[1] * scale, 1.0); 24 | pos.y = -pos.y; pos.z = (pos.z + pos.w) / 2.0; 25 | gl_MeshVerticesNV[1].gl_Position = pos; 26 | 27 | pos = vec4(vertices[2] * scale, 1.0); 28 | pos.y = -pos.y; pos.z = (pos.z + pos.w) / 2.0; 29 | gl_MeshVerticesNV[2].gl_Position = pos; 30 | 31 | v_out[0].color = vec4(colors[0], 1.0); 32 | v_out[1].color = vec4(colors[1], 1.0); 33 | v_out[2].color = vec4(colors[2], 1.0); 34 | 35 | gl_PrimitiveIndicesNV[0] = 0; 36 | gl_PrimitiveIndicesNV[1] = 1; 37 | gl_PrimitiveIndicesNV[2] = 2; 38 | 39 | gl_PrimitiveCountNV = 1; 40 | } 41 | -------------------------------------------------------------------------------- /extra/samples/Nonuniform Indexing/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #if defined(VULKAN) 4 | # define gl_VertexID gl_VertexIndex 5 | #endif 6 | 7 | const vec2 pos[4] = vec2[]( 8 | vec2(-1,-1), 9 | vec2( 1,-1), 10 | vec2(-1, 1), 11 | vec2( 1, 1) 12 | ); 13 | 14 | const vec2 uv[4] = vec2[]( 15 | vec2(0, 1), 16 | vec2(1, 1), 17 | vec2(0, 0), 18 | vec2(1, 0) 19 | ); 20 | 21 | layout(location = 0) out vec2 vTexCoords; 22 | 23 | void main() { 24 | vTexCoords = uv[gl_VertexID]; 25 | gl_Position = vec4(pos[gl_VertexID], 0.0, 1.0); 26 | } 27 | -------------------------------------------------------------------------------- /extra/samples/Nonuniform Indexing/textured.fs: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_nonuniform_qualifier : require 3 | 4 | // https://raw.githubusercontent.com/KhronosGroup/GLSL/refs/heads/main/extensions/ext/GL_EXT_nonuniform_qualifier.txt 5 | 6 | // https://github.com/KhronosGroup/Vulkan-Samples/blob/main/shaders/descriptor_indexing/glsl/nonuniform-quads.frag 7 | 8 | layout(binding = 0) uniform sampler2D uTexture[]; 9 | 10 | layout(location = 0) in vec2 vTexCoords; 11 | layout(location = 0) out vec4 oColor; 12 | 13 | void main() { 14 | const int index = int(vTexCoords.x * 2); 15 | oColor = texture(uTexture[nonuniformEXT(index)], vTexCoords); 16 | } 17 | -------------------------------------------------------------------------------- /extra/samples/Order-independent transparency/Readme.md: -------------------------------------------------------------------------------- 1 | 2 | Order-independent transparency Sample 3 | ------------------------------------- 4 | 5 | The sample uses shaders from the KDGpu repository (MIT license): 6 | https://github.com/KDAB/KDGpu/tree/main/assets/shaders/examples/compute_oit_transparency 7 | -------------------------------------------------------------------------------- /extra/samples/Order-independent transparency/compositing.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | vec3 vertices[6] = { 5 | vec3(-1.0, -1.0, 0.5), 6 | vec3(-1.0, 1.0, 0.5), 7 | vec3(1.0, 1.0, 0.5), 8 | vec3(1.0, 1.0, 0.5), 9 | vec3(1.0, -1.0, 0.5), 10 | vec3(-1.0, -1.0, 0.5), 11 | }; 12 | 13 | void main() 14 | { 15 | gl_Position = vec4(vertices[gl_VertexIndex], 1.0); 16 | } 17 | -------------------------------------------------------------------------------- /extra/samples/Order-independent transparency/cube.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Order-independent transparency/cube.bin -------------------------------------------------------------------------------- /extra/samples/Order-independent transparency/cube.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec3 vertexPosition; 5 | layout(location = 1) in vec3 vertexNormal; 6 | 7 | layout(location = 0) out vec4 color; 8 | layout(location = 1) out vec3 worldNormal; 9 | layout(location = 2) out vec3 worldPosition; 10 | layout(location = 3) out vec3 worldView; 11 | 12 | layout(set = 1, binding = 0) uniform Camera 13 | { 14 | mat4 viewMatrix; 15 | mat4 projectionMatrix; 16 | } 17 | camera; 18 | 19 | void main() 20 | { 21 | color = vec4(1.0, 1.0, 1.0, 0.05); 22 | worldNormal = vertexNormal; 23 | worldPosition = vertexPosition * 32.0; 24 | 25 | // Extract world eye pos from viewMatrix 26 | vec3 worldEyePos = inverse(camera.viewMatrix)[3].xyz; 27 | worldView = normalize(worldPosition - worldEyePos); 28 | 29 | gl_Position = camera.projectionMatrix * camera.viewMatrix * vec4(worldPosition, 1.0); 30 | } 31 | -------------------------------------------------------------------------------- /extra/samples/Order-independent transparency/cube_instanced.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location = 0) in vec3 vertexPosition; 5 | layout(location = 1) in vec3 vertexNormal; 6 | layout(location = 2) in vec4 particlePosition; 7 | layout(location = 3) in vec4 particleColor; 8 | 9 | layout(location = 0) out vec4 color; 10 | layout(location = 1) out vec3 worldNormal; 11 | layout(location = 2) out vec3 worldPosition; 12 | layout(location = 3) out vec3 worldView; 13 | 14 | layout(set = 1, binding = 0) uniform Camera 15 | { 16 | mat4 viewMatrix; 17 | mat4 projectionMatrix; 18 | } 19 | camera; 20 | 21 | void main() 22 | { 23 | color = particleColor; 24 | // TODO: inverted normal 25 | worldNormal = -vertexNormal; 26 | 27 | float radius = particlePosition.w; 28 | worldPosition = particlePosition.xyz + vertexPosition * radius; 29 | worldPosition = worldPosition; 30 | 31 | // Extract world eye pos from viewMatrix 32 | vec3 worldEyePos = inverse(camera.viewMatrix)[3].xyz; 33 | worldView = normalize(worldPosition - worldEyePos); 34 | 35 | gl_Position = camera.projectionMatrix * camera.viewMatrix * vec4(worldPosition, 1.0); 36 | } 37 | -------------------------------------------------------------------------------- /extra/samples/Order-independent transparency/generate_particles.js: -------------------------------------------------------------------------------- 1 | 2 | function random(min, max) { 3 | return Math.random() * (max - min) + min 4 | } 5 | 6 | let particles = new Array(ParticlesCount * 12) 7 | for (let i = 0, p = 0; i < ParticlesCount; ++i) { 8 | // position 9 | particles[p++] = random(-16, 16) 10 | particles[p++] = random(-16, 16) 11 | particles[p++] = random(-16, 16) 12 | 13 | // size 14 | particles[p++] = 3 15 | 16 | // velocity 17 | particles[p++] = random(0, 0.01) 18 | particles[p++] = random(0, 0.01) 19 | particles[p++] = random(0, 0.01) 20 | particles[p++] = 0 21 | 22 | // color 23 | particles[p++] = random(0, 1) 24 | particles[p++] = random(0, 1) 25 | particles[p++] = random(0, 1) 26 | particles[p++] = 0.4 27 | } 28 | 29 | app.session.setBufferData( 30 | 'Buffers/Particle Buffer', particles) 31 | -------------------------------------------------------------------------------- /extra/samples/Paint/line.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform vec2 uMouseCoord; 4 | uniform vec2 uPrevMouseCoord; 5 | uniform float uSize; 6 | out vec2 vTexCoords; 7 | 8 | void main() { 9 | vec2 coord[] = vec2[](uPrevMouseCoord, uMouseCoord); 10 | float size = uSize / (2 * length(coord[0] - coord[1])); 11 | vec2 dir = (coord[0] - coord[1]) * size; 12 | coord[0] += dir; 13 | coord[1] -= dir; 14 | vec2 perp[] = vec2[](vec2(-dir.y, dir.x), vec2(dir.y, -dir.x)); 15 | vec2 pos = coord[gl_VertexID % 2] + perp[gl_VertexID / 2]; 16 | gl_Position = vec4(pos, 0.0, 1.0); 17 | 18 | const vec2 uv[] = vec2[]( 19 | vec2(0, 1), 20 | vec2(0, 0), 21 | vec2(1, 1), 22 | vec2(1, 0)); 23 | vTexCoords = uv[gl_VertexID]; 24 | } 25 | -------------------------------------------------------------------------------- /extra/samples/Paint/paint.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform vec4 uColor; 4 | uniform float uMousePressed; 5 | 6 | in vec2 vTexCoords; 7 | out vec4 oColor; 8 | 9 | void main() { 10 | oColor = uColor; 11 | vec2 uv = vTexCoords; 12 | float vignette = uv.x * uv.y * (1 - uv.x) * (1 - uv.y); 13 | oColor.a = uMousePressed * smoothstep(0, 0.05, vignette); 14 | } 15 | -------------------------------------------------------------------------------- /extra/samples/Particles/particle.comp: -------------------------------------------------------------------------------- 1 | 2 | struct Particle { 3 | vec2 position; 4 | vec2 velocity; 5 | }; 6 | 7 | layout(std430, binding=0) buffer particles { 8 | Particle particle[]; 9 | }; 10 | 11 | uniform uint particleCount; 12 | -------------------------------------------------------------------------------- /extra/samples/Particles/particle.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | out vec4 oColor; 4 | 5 | void main() { 6 | float a = 1 - 2 * distance(gl_PointCoord, vec2(0.5)); 7 | oColor = vec4(0.9, 0.5, 0.2, a / 20); 8 | } 9 | -------------------------------------------------------------------------------- /extra/samples/Particles/particle.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec4 aPosition; 4 | 5 | void main() { 6 | gl_PointSize = max(aPosition.z * 32, 4.0); 7 | gl_Position = aPosition; 8 | } 9 | -------------------------------------------------------------------------------- /extra/samples/Particles/reset.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "particle.comp" 4 | 5 | layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 6 | 7 | vec3 hash(uvec3 x) { 8 | const uint k = 1103515245U; 9 | x = ((x >> 8U) ^ x.yzx) * k; 10 | x = ((x >> 8U) ^ x.yzx) * k; 11 | x = ((x >> 8U) ^ x.yzx) * k; 12 | return vec3(x) * (1.0 / float(0xffffffffU)); 13 | } 14 | 15 | void main() { 16 | uint gid = gl_GlobalInvocationID.x; 17 | if (gid < particleCount) { 18 | vec2 position = hash(uvec3(gid, 0, 1)).xy - vec2(0.5); 19 | particle[gid] = Particle(position, vec2(0)); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /extra/samples/Particles/update.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | #include "particle.comp" 4 | 5 | uniform vec2 attractor; 6 | 7 | layout (local_size_x = 256, local_size_y = 1, local_size_z = 1) in; 8 | 9 | void main() { 10 | uint gid = gl_GlobalInvocationID.x; 11 | if(gid < particleCount) { 12 | Particle p = particle[gid]; 13 | vec2 acceleration = normalize(attractor - p.position.xy) / 100; 14 | p.velocity += acceleration; 15 | p.position += p.velocity; 16 | p.position = clamp(p.position, -1.1, 1.1); 17 | particle[gid] = p; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /extra/samples/Printf/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 data[4] = vec2[]( 4 | vec2(-1.0, 1.0), 5 | vec2(-1.0, -1.0), 6 | vec2( 1.0, 1.0), 7 | vec2( 1.0, -1.0) 8 | ); 9 | 10 | out vec2 vTexCoords; 11 | 12 | void main() { 13 | 14 | #if defined(GPUPAD) 15 | // not supported by all GPUs in VS 16 | //printf("Vertex %i is at %.1f", gl_VertexID, gl_Position.xyz); 17 | #endif 18 | 19 | vTexCoords = (data[gl_VertexID] + 1) / 2; 20 | gl_Position = vec4(data[gl_VertexID], 0.0, 1.0); 21 | } 22 | -------------------------------------------------------------------------------- /extra/samples/Printf/printf.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 vTexCoords; 4 | uniform vec2 uMouseFragCoord; 5 | out vec4 oColor; 6 | 7 | void main() { 8 | vec2 tc = floor(vTexCoords * 10); 9 | oColor = vec4(sin(tc), 0.33, 1); 10 | 11 | #if defined(GPUPAD) 12 | if (gl_FragCoord.xy == uMouseFragCoord) 13 | printf("The color at %i is %u", 14 | ivec2(uMouseFragCoord), uvec3(oColor.rgb * 255)); 15 | #endif 16 | 17 | if (uMouseFragCoord.x == gl_FragCoord.x) 18 | oColor.g = 1; 19 | if (uMouseFragCoord.y == gl_FragCoord.y) 20 | oColor.r = 1; 21 | } 22 | -------------------------------------------------------------------------------- /extra/samples/Quad/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 pos[4] = vec2[]( 4 | vec2(-1,-1), 5 | vec2( 1,-1), 6 | vec2(-1, 1), 7 | vec2( 1, 1) 8 | ); 9 | 10 | const vec2 uv[4] = vec2[]( 11 | vec2(0, 1), 12 | vec2(1, 1), 13 | vec2(0, 0), 14 | vec2(1, 0) 15 | ); 16 | 17 | out vec2 vTexCoords; 18 | 19 | void main() { 20 | vTexCoords = uv[gl_VertexID]; 21 | gl_Position = vec4(pos[gl_VertexID], 0.0, 1.0); 22 | } 23 | -------------------------------------------------------------------------------- /extra/samples/Quad/marble.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Quad/marble.png -------------------------------------------------------------------------------- /extra/samples/Quad/textured.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D uTexture; 4 | uniform vec4 uColor; 5 | 6 | in vec2 vTexCoords; 7 | out vec4 oColor; 8 | 9 | void main() { 10 | oColor = texture(uTexture, vTexCoords) * uColor; 11 | } 12 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan 2/Material.glsl: -------------------------------------------------------------------------------- 1 | 2 | const uint MaterialLambertian = 0; 3 | const uint MaterialMetallic = 1; 4 | const uint MaterialDielectric = 2; 5 | const uint MaterialIsotropic = 3; 6 | const uint MaterialDiffuseLight = 4; 7 | 8 | struct Material 9 | { 10 | vec4 Diffuse; 11 | int DiffuseTextureId; 12 | float Fuzziness; 13 | float RefractionIndex; 14 | uint MaterialModel; 15 | }; 16 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan 2/ProceduralHit.glsl: -------------------------------------------------------------------------------- 1 | 2 | struct ProceduralHit 3 | { 4 | vec3 NormalAndObjectId 5 | }; -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan 2/RayPayload.glsl: -------------------------------------------------------------------------------- 1 | 2 | struct RayPayload 3 | { 4 | vec4 ColorAndDistance; // rgb + t 5 | vec4 ScatterDirection; // xyz + w (is scatter needed) 6 | uint RandomSeed; 7 | }; 8 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan 2/RayTracing.rmiss: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_GOOGLE_include_directive : require 3 | #extension GL_EXT_ray_tracing : require 4 | #include "RayPayload.glsl" 5 | #include "UniformBufferObject.glsl" 6 | 7 | layout(binding = 3) readonly uniform UniformBufferObjectStruct { UniformBufferObject Camera; }; 8 | 9 | layout(location = 0) rayPayloadInEXT RayPayload Ray; 10 | 11 | void main() 12 | { 13 | if (Camera.HasSky) 14 | { 15 | // Sky color 16 | const float t = 0.5*(normalize(gl_WorldRayDirectionEXT).y + 1); 17 | const vec3 skyColor = mix(vec3(1.0), vec3(0.5, 0.7, 1.0), t); 18 | 19 | Ray.ColorAndDistance = vec4(skyColor, -1); 20 | } 21 | else 22 | { 23 | Ray.ColorAndDistance = vec4(0, 0, 0, -1); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan 2/UniformBufferObject.glsl: -------------------------------------------------------------------------------- 1 | 2 | struct UniformBufferObject 3 | { 4 | mat4 ModelView; 5 | mat4 Projection; 6 | mat4 ModelViewInverse; 7 | mat4 ProjectionInverse; 8 | float Aperture; 9 | float FocusDistance; 10 | float HeatmapScale; 11 | uint TotalNumberOfSamples; 12 | uint NumberOfSamples; 13 | uint NumberOfBounces; 14 | uint RandomSeed; 15 | bool HasSky; 16 | }; 17 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan 2/Vertex.glsl: -------------------------------------------------------------------------------- 1 | 2 | struct Vertex 3 | { 4 | vec3 Position; 5 | vec3 Normal; 6 | vec2 TexCoord; 7 | }; 8 | 9 | Vertex UnpackVertex(uint index) 10 | { 11 | const uint vertexSize = 8; 12 | const uint offset = index * vertexSize; 13 | 14 | Vertex v; 15 | 16 | v.Position = vec3(Vertices[offset + 0], Vertices[offset + 1], Vertices[offset + 2]); 17 | v.Normal = vec3(Vertices[offset + 3], Vertices[offset + 4], Vertices[offset + 5]); 18 | v.TexCoord = vec2(Vertices[offset + 6], Vertices[offset + 7]); 19 | 20 | return v; 21 | } 22 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan 2/camera.js: -------------------------------------------------------------------------------- 1 | 2 | app.loadLibrary("gl-matrix.js") 3 | const vec3 = glMatrix.vec3 4 | const mat4 = glMatrix.mat4 5 | 6 | const fovy = 20 * 3.14 / 180 7 | const aspect = 1280 / 720 8 | const eye = vec3.fromValues(13, 2, 3) 9 | const center = vec3.fromValues(0, 0, 0) 10 | const up = vec3.fromValues(0, 1, 0) 11 | 12 | const radius = 5 13 | const angle = app.mouse.coord[0] * 3 14 | eye[0] = Math.cos(angle) * radius 15 | eye[2] = Math.sin(angle) * radius 16 | center[1] = app.mouse.coord[1] * -1 17 | 18 | view = mat4.lookAt(mat4.create(), eye, center, up) 19 | projection = mat4.perspective(mat4.create(), fovy, aspect, 0.1, 10000.0) 20 | 21 | viewInverse = mat4.invert(mat4.create(), view) 22 | projectionInverse = mat4.invert(mat4.create(), projection) 23 | 24 | // reset sample count when camera moved 25 | if (!this.totalSamples || app.mouse.delta[0] != 0 || app.mouse.delta[1] != 0) 26 | totalSamples = 0 27 | 28 | samples = 8 29 | totalSamples += samples -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan/Material.glsl: -------------------------------------------------------------------------------- 1 | 2 | const uint MaterialLambertian = 0; 3 | const uint MaterialMetallic = 1; 4 | const uint MaterialDielectric = 2; 5 | const uint MaterialIsotropic = 3; 6 | const uint MaterialDiffuseLight = 4; 7 | 8 | struct Material 9 | { 10 | vec4 Diffuse; 11 | float Fuzziness; 12 | float RefractionIndex; 13 | uint MaterialModel; 14 | uint _padding; 15 | }; 16 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan/README.md: -------------------------------------------------------------------------------- 1 | 2 | Ray Tracing In Vulkan Sample 3 | ---------------------------- 4 | 5 | The sample is based on Ray Tracing In Vulkan by Tanguy Fautré 6 | https://github.com/GPSnoopy/RayTracingInVulkan 7 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan/RayPayload.glsl: -------------------------------------------------------------------------------- 1 | 2 | struct RayPayload 3 | { 4 | vec4 ColorAndDistance; // rgb + t 5 | vec4 ScatterDirection; // xyz + w (is scatter needed) 6 | uint RandomSeed; 7 | }; 8 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan/RayTracing.Procedural.rint: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_GOOGLE_include_directive : require 3 | #extension GL_EXT_ray_tracing : require 4 | 5 | layout(binding = 5) readonly buffer SphereArray { vec4[] Spheres; }; 6 | 7 | hitAttributeEXT vec4 Sphere; 8 | 9 | void main() 10 | { 11 | const vec4 sphere = Spheres[gl_PrimitiveID]; 12 | const vec3 center = sphere.xyz; 13 | const float radius = sphere.w; 14 | 15 | const vec3 origin = gl_WorldRayOriginEXT; 16 | const vec3 direction = gl_WorldRayDirectionEXT; 17 | const float tMin = gl_RayTminEXT; 18 | const float tMax = gl_RayTmaxEXT; 19 | 20 | // https://en.wikipedia.org/wiki/Quadratic_formula 21 | 22 | const vec3 oc = origin - center; 23 | const float a = dot(direction, direction); 24 | const float b = dot(oc, direction); 25 | const float c = dot(oc, oc) - radius * radius; 26 | const float discriminant = b * b - a * c; 27 | 28 | if (discriminant >= 0) 29 | { 30 | const float t1 = (-b - sqrt(discriminant)) / a; 31 | const float t2 = (-b + sqrt(discriminant)) / a; 32 | 33 | if ((tMin <= t1 && t1 < tMax) || (tMin <= t2 && t2 < tMax)) 34 | { 35 | Sphere = sphere; 36 | reportIntersectionEXT((tMin <= t1 && t1 < tMax) ? t1 : t2, 0); 37 | } 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan/RayTracing.rmiss: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_GOOGLE_include_directive : require 3 | #extension GL_EXT_ray_tracing : require 4 | #include "RayPayload.glsl" 5 | #include "UniformBufferObject.glsl" 6 | 7 | layout(binding = 3) readonly uniform UniformBufferObjectStruct { UniformBufferObject Camera; }; 8 | 9 | layout(location = 0) rayPayloadInEXT RayPayload Ray; 10 | 11 | void main() 12 | { 13 | if (Camera.HasSky) 14 | { 15 | // Sky color 16 | const float t = 0.5*(normalize(gl_WorldRayDirectionEXT).y + 1); 17 | const vec3 skyColor = mix(vec3(1.0), vec3(0.5, 0.7, 1.0), t); 18 | 19 | Ray.ColorAndDistance = vec4(skyColor, -1); 20 | } 21 | else 22 | { 23 | Ray.ColorAndDistance = vec4(0, 0, 0, -1); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan/UniformBufferObject.glsl: -------------------------------------------------------------------------------- 1 | 2 | struct UniformBufferObject 3 | { 4 | mat4 ModelView; 5 | mat4 Projection; 6 | mat4 ModelViewInverse; 7 | mat4 ProjectionInverse; 8 | float Aperture; 9 | float FocusDistance; 10 | float HeatmapScale; 11 | uint TotalNumberOfSamples; 12 | uint NumberOfSamples; 13 | uint NumberOfBounces; 14 | uint RandomSeed; 15 | bool HasSky; 16 | }; 17 | -------------------------------------------------------------------------------- /extra/samples/Ray Tracing In Vulkan/camera.js: -------------------------------------------------------------------------------- 1 | 2 | app.loadLibrary("gl-matrix.js") 3 | const vec3 = glMatrix.vec3 4 | const mat4 = glMatrix.mat4 5 | 6 | const fovy = 20 * 3.14 / 180 7 | const aspect = 1280 / 720 8 | const eye = vec3.fromValues(13, 2, 3) 9 | const center = vec3.fromValues(0, 0, 0) 10 | const up = vec3.fromValues(0, 1, 0) 11 | 12 | const radius = 15 13 | const angle = app.mouse.coord[0] 14 | eye[0] = Math.cos(angle) * radius 15 | eye[2] = Math.sin(angle) * radius 16 | center[1] = app.mouse.coord[1] * -2 17 | 18 | view = mat4.lookAt(mat4.create(), eye, center, up) 19 | projection = mat4.perspective(mat4.create(), fovy, aspect, 0.1, 10000.0) 20 | 21 | viewInverse = mat4.invert(mat4.create(), view) 22 | projectionInverse = mat4.invert(mat4.create(), projection) 23 | 24 | // reset sample count when camera moved 25 | if (app.mouse.delta[0] != 0 || app.mouse.delta[1] != 0) 26 | totalSamples = 0 27 | 28 | samples = 8 29 | totalSamples += samples 30 | -------------------------------------------------------------------------------- /extra/samples/Shadertoy 2/Font 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Shadertoy 2/Font 1.png -------------------------------------------------------------------------------- /extra/samples/Shadertoy 2/RGBA Noise Medium.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Shadertoy 2/RGBA Noise Medium.png -------------------------------------------------------------------------------- /extra/samples/Shadertoy 2/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 data[4] = vec2[]( 4 | vec2(-1.0, 1.0), 5 | vec2(-1.0, -1.0), 6 | vec2( 1.0, 1.0), 7 | vec2( 1.0, -1.0) 8 | ); 9 | 10 | void main() { 11 | gl_Position = vec4(data[gl_VertexID], 0.0, 1.0); 12 | } 13 | -------------------------------------------------------------------------------- /extra/samples/Shadertoy 2/keyboard.js: -------------------------------------------------------------------------------- 1 | 2 | toggled = this.toggled || [] 3 | 4 | const keys = app.keyboard.keys 5 | const data = [] 6 | for (let i = 0; i < 256; ++i) { 7 | const key = keys[i] 8 | if (key == 2) 9 | toggled[i] = (toggled[i] == 1 ? 0 : 1) 10 | 11 | data[i] = (key > 0 ? 1 : 0) 12 | data[256 + i] = (key == 2 ? 1 : 0) 13 | data[512 + i] = toggled[i] 14 | } 15 | app.session.setTextureData("Textures/Keyboard", data) 16 | -------------------------------------------------------------------------------- /extra/samples/Shadertoy/Script.js: -------------------------------------------------------------------------------- 1 | 2 | target = app.session.openEditor("TargetTexture") 3 | -------------------------------------------------------------------------------- /extra/samples/Shadertoy/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 data[4] = vec2[]( 4 | vec2(-1.0, 1.0), 5 | vec2(-1.0, -1.0), 6 | vec2( 1.0, 1.0), 7 | vec2( 1.0, -1.0) 8 | ); 9 | 10 | void main() { 11 | gl_Position = vec4(data[gl_VertexID], 0.0, 1.0); 12 | } 13 | -------------------------------------------------------------------------------- /extra/samples/Stencil Buffer/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 data[4] = vec2[]( 4 | vec2(-1.0, 1.0), 5 | vec2(-1.0, -1.0), 6 | vec2( 1.0, 1.0), 7 | vec2( 1.0, -1.0) 8 | ); 9 | 10 | out vec2 vTexCoords; 11 | 12 | void main() { 13 | vTexCoords = data[gl_VertexID] / 2 + vec2(0.5); 14 | gl_Position = vec4(data[gl_VertexID], 0.0, 1.0); 15 | } 16 | -------------------------------------------------------------------------------- /extra/samples/Stencil Buffer/fill.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 vTexCoords; 4 | out vec4 oColor; 5 | 6 | uniform float frame; 7 | 8 | void main() { 9 | float time = frame / 60.0; 10 | float s = sin(time); 11 | float c = cos(time); 12 | vec2 pos = abs(vTexCoords.xy * mat2x2(c, s, -s, c) * 2); 13 | oColor = vec4(pos, 0.3, 1); 14 | } 15 | -------------------------------------------------------------------------------- /extra/samples/Stencil Buffer/mask.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec2 vTexCoords; 4 | 5 | uniform float frame; 6 | 7 | void main() { 8 | float size = 0.03 + sin(frame / 5) / 100.0; 9 | float pos = frame / 30; 10 | float radius = frame / 2000; 11 | vec2 center = vec2(0.5) + vec2(cos(pos), sin(pos)) * radius; 12 | if (distance(vTexCoords, center) > size) 13 | discard; 14 | } 15 | -------------------------------------------------------------------------------- /extra/samples/Subroutine/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 data[4] = vec2[]( 4 | vec2(-1.0, 1.0), 5 | vec2(-1.0, -1.0), 6 | vec2( 1.0, 1.0), 7 | vec2( 1.0, -1.0) 8 | ); 9 | 10 | out vec2 vTexCoords; 11 | 12 | void main() { 13 | vTexCoords = data[gl_VertexID] / 2 + vec2(0.5); 14 | gl_Position = vec4(data[gl_VertexID], 0.0, 1.0); 15 | } 16 | -------------------------------------------------------------------------------- /extra/samples/Subroutine/subroutine.fs: -------------------------------------------------------------------------------- 1 | #version 400 2 | 3 | subroutine vec4 FadeType(vec2 tc); 4 | subroutine uniform FadeType fadeType; 5 | 6 | in vec2 vTexCoords; 7 | out vec4 oColor; 8 | 9 | 10 | subroutine(FadeType) vec4 fade1(vec2 tc) { 11 | return vec4(0, 1 - tc.t, 0.7, 1); 12 | } 13 | 14 | subroutine(FadeType) vec4 fade2(vec2 tc) { 15 | return vec4(1, 1 - tc.s, 0, 1); 16 | } 17 | 18 | void main() { 19 | oColor = fadeType(vTexCoords); 20 | } 21 | -------------------------------------------------------------------------------- /extra/samples/Sync Test/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 data[4] = vec2[]( 4 | vec2(-1.0, 1.0), 5 | vec2(-1.0, -1.0), 6 | vec2( 1.0, 1.0), 7 | vec2( 1.0, -1.0) 8 | ); 9 | 10 | void main() { 11 | gl_Position = vec4(data[gl_VertexID], 0.0, 1.0); 12 | } 13 | -------------------------------------------------------------------------------- /extra/samples/Sync Test/sync.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform int frame; 4 | uniform ivec2 resolution; 5 | out vec4 color; 6 | 7 | void main() { 8 | float interval = 4; 9 | float frameRate = 60; 10 | int barWidth = 8; 11 | int width = resolution.x - barWidth; 12 | float speed = width / frameRate / interval; 13 | float pos = abs(int(frame * speed) % (width * 2) - width); 14 | float onLine = 15 | step(pos, gl_FragCoord.x) - 16 | step(pos + barWidth, gl_FragCoord.x); 17 | color = vec4(0, onLine, 0, 1); 18 | } 19 | -------------------------------------------------------------------------------- /extra/samples/Tessellation/geodesic.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Based on Philip Rideout's sample 4 | // Triangle Tessellation with OpenGL 4.0 5 | // https://prideout.net/blog/old/blog/index.html@p=48.html 6 | 7 | out vec4 FragColor; 8 | in vec3 gFacetNormal; 9 | in vec3 gPatchDistance; 10 | in vec3 gTriDistance; 11 | uniform vec3 LightPosition; 12 | uniform vec3 DiffuseMaterial; 13 | uniform vec3 AmbientMaterial; 14 | 15 | float amplify(float d, float scale, float offset) 16 | { 17 | d = scale * d + offset; 18 | d = clamp(d, 0, 1); 19 | d = 1 - exp2(-2*d*d); 20 | return d; 21 | } 22 | 23 | void main() 24 | { 25 | vec3 N = normalize(gFacetNormal); 26 | vec3 L = LightPosition; 27 | float df = abs(dot(N, L)); 28 | vec3 color = AmbientMaterial + df * DiffuseMaterial; 29 | 30 | float d1 = min(min(gTriDistance.x, gTriDistance.y), gTriDistance.z); 31 | float d2 = min(min(gPatchDistance.x, gPatchDistance.y), gPatchDistance.z); 32 | color = amplify(d1, 40, -0.5) * amplify(d2, 60, -0.5) * color; 33 | 34 | FragColor = vec4(color, 1.0); 35 | } 36 | -------------------------------------------------------------------------------- /extra/samples/Tessellation/geodesic.geom: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform mat4 Modelview; 4 | uniform mat3 NormalMatrix; 5 | layout(triangles) in; 6 | layout(triangle_strip, max_vertices = 3) out; 7 | in vec3 tePosition[3]; 8 | in vec3 tePatchDistance[3]; 9 | out vec3 gFacetNormal; 10 | out vec3 gPatchDistance; 11 | out vec3 gTriDistance; 12 | 13 | void main() 14 | { 15 | vec3 A = tePosition[2] - tePosition[0]; 16 | vec3 B = tePosition[1] - tePosition[0]; 17 | gFacetNormal = NormalMatrix * normalize(cross(A, B)); 18 | 19 | gPatchDistance = tePatchDistance[0]; 20 | gTriDistance = vec3(1, 0, 0); 21 | gl_Position = gl_in[0].gl_Position; EmitVertex(); 22 | 23 | gPatchDistance = tePatchDistance[1]; 24 | gTriDistance = vec3(0, 1, 0); 25 | gl_Position = gl_in[1].gl_Position; EmitVertex(); 26 | 27 | gPatchDistance = tePatchDistance[2]; 28 | gTriDistance = vec3(0, 0, 1); 29 | gl_Position = gl_in[2].gl_Position; EmitVertex(); 30 | 31 | EndPrimitive(); 32 | } 33 | -------------------------------------------------------------------------------- /extra/samples/Tessellation/geodesic.tesc: -------------------------------------------------------------------------------- 1 | #version 400 2 | 3 | layout(vertices = 3) out; 4 | in vec3 vPosition[]; 5 | out vec3 tcPosition[]; 6 | uniform float TessLevelInner; 7 | uniform float TessLevelOuter; 8 | 9 | #define ID gl_InvocationID 10 | 11 | void main() 12 | { 13 | tcPosition[ID] = vPosition[ID]; 14 | if (ID == 0) { 15 | gl_TessLevelInner[0] = TessLevelInner; 16 | gl_TessLevelOuter[0] = TessLevelOuter; 17 | gl_TessLevelOuter[1] = TessLevelOuter; 18 | gl_TessLevelOuter[2] = TessLevelOuter; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /extra/samples/Tessellation/geodesic.tese: -------------------------------------------------------------------------------- 1 | #version 400 2 | 3 | layout(triangles, equal_spacing, cw) in; 4 | in vec3 tcPosition[]; 5 | out vec3 tePosition; 6 | out vec3 tePatchDistance; 7 | uniform mat4 Projection; 8 | uniform mat4 Modelview; 9 | 10 | void main() 11 | { 12 | vec3 p0 = gl_TessCoord.x * tcPosition[0]; 13 | vec3 p1 = gl_TessCoord.y * tcPosition[1]; 14 | vec3 p2 = gl_TessCoord.z * tcPosition[2]; 15 | tePatchDistance = gl_TessCoord; 16 | tePosition = normalize(p0 + p1 + p2); 17 | gl_Position = Projection * Modelview * vec4(tePosition, 1); 18 | } 19 | -------------------------------------------------------------------------------- /extra/samples/Tessellation/geodesic.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | in vec4 Position; 4 | out vec3 vPosition; 5 | 6 | void main() 7 | { 8 | vPosition = Position.xyz; 9 | } 10 | -------------------------------------------------------------------------------- /extra/samples/Tessellation/geodesic_indices.bin: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /extra/samples/Tessellation/geodesic_positions.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Tessellation/geodesic_positions.bin -------------------------------------------------------------------------------- /extra/samples/Video/attributeless.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | const vec2 data[4] = vec2[]( 4 | vec2(-1.0, 1.0), 5 | vec2(-1.0, -1.0), 6 | vec2( 1.0, 1.0), 7 | vec2( 1.0, -1.0) 8 | ); 9 | 10 | out vec2 vTexCoords; 11 | 12 | void main() { 13 | vTexCoords = data[gl_VertexID] / 2 + vec2(0.5); 14 | gl_Position = vec4(data[gl_VertexID], 0.0, 1.0); 15 | } 16 | -------------------------------------------------------------------------------- /extra/samples/Video/robin.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/Video/robin.mp4 -------------------------------------------------------------------------------- /extra/samples/Video/textured.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | uniform sampler2D uTexture; 4 | uniform float uTime; 5 | 6 | in vec2 vTexCoords; 7 | out vec4 oColor; 8 | 9 | void main() { 10 | vec2 uv = vTexCoords; 11 | uv.y *= 2.1; 12 | uv.x += mix(0, sin(uv.y * 50 + uTime * 8) * 0.02, clamp(1 - uv.y, 0, 1)); 13 | vec4 color = texture(uTexture, uv); 14 | color.rgb -= vec3(0.5, 0.2, 0.1) * smoothstep(0, 1, max(1 - uv.y, 0)); 15 | oColor = color; 16 | } 17 | -------------------------------------------------------------------------------- /extra/samples/Volume/fill.comp: -------------------------------------------------------------------------------- 1 | #version 430 2 | 3 | layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in; 4 | 5 | layout (r8) uniform image3D uImage; 6 | uniform float frame; 7 | 8 | // https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm 9 | float sdTorus( vec3 p, vec2 t ) 10 | { 11 | vec2 q = vec2(length(p.xz)-t.x,p.y); 12 | return length(q)-t.y; 13 | } 14 | 15 | float opSubtraction( float d1, float d2 ) 16 | { 17 | return max(-d1,d2); 18 | } 19 | 20 | mat3 rotateX(float t) 21 | { 22 | float s = sin(t); 23 | float c = cos(t); 24 | return mat3( 25 | 1, 0, 0, 26 | 0, c,-s, 27 | 0, s, c); 28 | } 29 | 30 | void main() 31 | { 32 | ivec3 coord = ivec3(gl_GlobalInvocationID.xyz); 33 | vec3 pos = vec3(coord) / 128.0 - vec3(0.5, 0.5, 0); 34 | 35 | // a rotating hollow doughnut 36 | pos = rotateX(frame / 60.0) * pos; 37 | float outer = sdTorus(pos, vec2(0.3, 0.2)); 38 | float inner = sdTorus(pos, vec2(0.3, 0.15)); 39 | float d = opSubtraction(inner, outer); 40 | 41 | float aa = 1 / 128.0; 42 | imageStore(uImage, coord, vec4(smoothstep(aa, -aa, d))); 43 | } 44 | -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/DamagedHelmet/DamagedHelmet.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/DamagedHelmet/DamagedHelmet.bin -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/DamagedHelmet/Default_AO.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/DamagedHelmet/Default_AO.jpg -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/DamagedHelmet/Default_albedo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/DamagedHelmet/Default_albedo.jpg -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/DamagedHelmet/Default_emissive.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/DamagedHelmet/Default_emissive.jpg -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/DamagedHelmet/Default_metalRoughness.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/DamagedHelmet/Default_metalRoughness.jpg -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/DamagedHelmet/Default_normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/DamagedHelmet/Default_normal.jpg -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/gltf-viewer/brdfLUT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/gltf-viewer/brdfLUT.png -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/gltf-viewer/header.frag: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | #define varying in 4 | #define texture2D texture 5 | #define textureCube texture 6 | #define textureCubeLodEXT textureLod 7 | #define USE_TEX_LOD 8 | 9 | #define gl_FragColor out_color 10 | 11 | out vec4 out_color; 12 | 13 | #define MATERIAL_METALLICROUGHNESS 14 | #define HAS_BASE_COLOR_MAP 15 | #define HAS_NORMAL_MAP 16 | #define HAS_METALLIC_ROUGHNESS_MAP 17 | #define HAS_EMISSIVE_MAP 18 | #define HAS_OCCLUSION_MAP 19 | 20 | #define USE_IBL 21 | #define USE_HDR 22 | #define USE_PUNCTUAL 23 | #define LIGHT_COUNT 1 24 | 25 | #define TONEMAP_UNCHARTED 26 | 27 | #define HAS_NORMALS 28 | //#define HAS_TANGENTS 29 | 30 | //#define MATERIAL_UNLIT 31 | 32 | //#define DEBUG_OUTPUT 33 | //#define DEBUG_METALLIC 34 | //#define DEBUG_ROUGHNESS 35 | //#define DEBUG_NORMAL 36 | //#define DEBUG_BASECOLOR 37 | //#define DEBUG_OCCLUSION 38 | //#define DEBUG_EMISSIVE 39 | //#define DEBUG_F0 -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/gltf-viewer/header.vert: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | #define attribute in 4 | #define varying out 5 | 6 | #define HAS_UV_SET1 7 | #define HAS_NORMALS 8 | //#define HAS_TANGENTS 9 | -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/gltf-viewer/papermill/papermill_irr.ktx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/gltf-viewer/papermill/papermill_irr.ktx -------------------------------------------------------------------------------- /extra/samples/gltf Viewer/gltf-viewer/papermill/papermill_pmrem.ktx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/samples/gltf Viewer/gltf-viewer/papermill/papermill_pmrem.ktx -------------------------------------------------------------------------------- /extra/share/applications/io.github.houmain.gpupad.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Name=GPUpad 4 | Comment=GLSL Shader Editor 5 | Exec=gpupad %F 6 | Icon=io.github.houmain.gpupad 7 | Terminal=false 8 | Categories=Development;IDE; 9 | StartupNotify=true 10 | Keywords=Text;Editor; 11 | -------------------------------------------------------------------------------- /extra/share/metainfo/io.github.houmain.gpupad.metainfo.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | io.github.houmain.gpupad 4 | 5 | GPUpad 6 | A flexible GLSL shader editor and IDE. 7 | 8 | CC-BY-SA-4.0 9 | GPL-3.0-or-later 10 | 11 | 12 | 13 | A lightweight editor for GLSL shaders of all kinds and a fully-featured IDE for developing GPU based algorithms. 14 | 15 | 16 | 17 | io.github.houmain.gpupad.desktop 18 | 19 | 20 | https://raw.githubusercontent.com/houmain/gpupad/main/screenshot2.png 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /extra/share/pixmaps/io.github.houmain.gpupad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/share/pixmaps/io.github.houmain.gpupad.png -------------------------------------------------------------------------------- /extra/themes/base16-apprentice-scheme/apprentice.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Apprentice" 2 | author: "romainl" 3 | base00: "262626" 4 | base01: "303030" 5 | base02: "333333" 6 | base03: "6C6C6C" 7 | base04: "787878" 8 | base05: "BCBCBC" 9 | base06: "C9C9C9" 10 | base07: "FFFFFF" 11 | base08: "5F8787" 12 | base09: "FF8700" 13 | base0A: "5F8787" 14 | base0B: "87AF87" 15 | base0C: "5F875F" 16 | base0D: "FFFFAF" 17 | base0E: "87AFD7" 18 | base0F: "5F87AF" 19 | -------------------------------------------------------------------------------- /extra/themes/base16-atlas-scheme/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alex Lende 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 | -------------------------------------------------------------------------------- /extra/themes/base16-atlas-scheme/atlas.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Atlas" 2 | author: "Alex Lende (https://ajlende.com)" 3 | base00: "002635" 4 | base01: "00384d" 5 | base02: "517F8D" 6 | base03: "6C8B91" 7 | base04: "869696" 8 | base05: "a1a19a" 9 | base06: "e6e6dc" 10 | base07: "fafaf8" 11 | base08: "ff5a67" 12 | base09: "f08e48" 13 | base0A: "ffcc1b" 14 | base0B: "7fc06e" 15 | base0D: "5dd7b9" 16 | base0C: "14747e" 17 | base0E: "9a70a4" 18 | base0F: "c43060" -------------------------------------------------------------------------------- /extra/themes/base16-darcula-scheme/darcula.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Darcula" 2 | author: "jetbrains" 3 | base00: "2b2b2b" # background 4 | base01: "323232" # line cursor 5 | base02: "323232" # statusline 6 | base03: "606366" # line numbers 7 | base04: "a4a3a3" # selected line number 8 | base05: "a9b7c6" # foreground 9 | base06: "ffc66d" # function bright yellow 10 | base07: "ffffff" 11 | base08: "4eade5" # cyan 12 | base09: "689757" # blue 13 | base0A: "bbb529" # yellow 14 | base0B: "6a8759" # string green 15 | base0C: "629755" # comment green 16 | base0D: "9876aa" # purple 17 | base0E: "cc7832" # orange 18 | base0F: "808080" # gray 19 | -------------------------------------------------------------------------------- /extra/themes/base16-default-scheme/eighties.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Eighties" 2 | author: "Chris Kempson (http://chriskempson.com)" 3 | base00: "2d2d2d" 4 | base01: "393939" 5 | base02: "515151" 6 | base03: "747369" 7 | base04: "a09f93" 8 | base05: "d3d0c8" 9 | base06: "e8e6df" 10 | base07: "f2f0ec" 11 | base08: "f2777a" 12 | base09: "f99157" 13 | base0A: "ffcc66" 14 | base0B: "99cc99" 15 | base0C: "66cccc" 16 | base0D: "6699cc" 17 | base0E: "cc99cc" 18 | base0F: "d27b53" -------------------------------------------------------------------------------- /extra/themes/base16-default-scheme/mocha.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Mocha" 2 | author: "Chris Kempson (http://chriskempson.com)" 3 | base00: "3B3228" 4 | base01: "534636" 5 | base02: "645240" 6 | base03: "7e705a" 7 | base04: "b8afad" 8 | base05: "d0c8c6" 9 | base06: "e9e1dd" 10 | base07: "f5eeeb" 11 | base08: "cb6077" 12 | base09: "d28b71" 13 | base0A: "f4bc87" 14 | base0B: "beb55b" 15 | base0C: "7bbda4" 16 | base0D: "8ab3b5" 17 | base0E: "a89bb9" 18 | base0F: "bb9584" -------------------------------------------------------------------------------- /extra/themes/base16-default-scheme/ocean.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Ocean" 2 | author: "Chris Kempson (http://chriskempson.com)" 3 | base00: "2b303b" 4 | base01: "343d46" 5 | base02: "4f5b66" 6 | base03: "65737e" 7 | base04: "a7adba" 8 | base05: "c0c5ce" 9 | base06: "dfe1e8" 10 | base07: "eff1f5" 11 | base08: "bf616a" 12 | base09: "d08770" 13 | base0A: "ebcb8b" 14 | base0B: "a3be8c" 15 | base0C: "96b5b4" 16 | base0D: "8fa1b3" 17 | base0E: "b48ead" 18 | base0F: "ab7967" -------------------------------------------------------------------------------- /extra/themes/base16-equilibrium-scheme/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Carlo Abelli 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 | -------------------------------------------------------------------------------- /extra/themes/base16-equilibrium-scheme/equilibrium-dark.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Equilibrium Dark" 2 | author: "Carlo Abelli" 3 | base00: "0c1118" 4 | base01: "181c22" 5 | base02: "22262d" 6 | base03: "7b776e" 7 | base04: "949088" 8 | base05: "afaba2" 9 | base06: "cac6bd" 10 | base07: "e7e2d9" 11 | base08: "f04339" 12 | base09: "df5923" 13 | base0A: "bb8801" 14 | base0B: "7f8b00" 15 | base0C: "00948b" 16 | base0D: "008dd1" 17 | base0E: "6a7fd2" 18 | base0F: "e3488e" 19 | -------------------------------------------------------------------------------- /extra/themes/base16-equilibrium-scheme/equilibrium-gray-dark.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Equilibrium Gray Dark" 2 | author: "Carlo Abelli" 3 | base00: "111111" 4 | base01: "1b1b1b" 5 | base02: "262626" 6 | base03: "777777" 7 | base04: "919191" 8 | base05: "ababab" 9 | base06: "c6c6c6" 10 | base07: "e2e2e2" 11 | base08: "f04339" 12 | base09: "df5923" 13 | base0A: "bb8801" 14 | base0B: "7f8b00" 15 | base0C: "00948b" 16 | base0D: "008dd1" 17 | base0E: "6a7fd2" 18 | base0F: "e3488e" 19 | -------------------------------------------------------------------------------- /extra/themes/base16-equilibrium-scheme/equilibrium-gray-light.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Equilibrium Gray Light" 2 | author: "Carlo Abelli" 3 | base00: "f1f1f1" 4 | base01: "e2e2e2" 5 | base02: "d4d4d4" 6 | base03: "777777" 7 | base04: "5e5e5e" 8 | base05: "474747" 9 | base06: "303030" 10 | base07: "1b1b1b" 11 | base08: "d02023" 12 | base09: "bf3e05" 13 | base0A: "9d6f00" 14 | base0B: "637200" 15 | base0C: "007a72" 16 | base0D: "0073b5" 17 | base0E: "4e66b6" 18 | base0F: "c42775" 19 | -------------------------------------------------------------------------------- /extra/themes/base16-equilibrium-scheme/equilibrium-light.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Equilibrium Light" 2 | author: "Carlo Abelli" 3 | base00: "f5f0e7" 4 | base01: "e7e2d9" 5 | base02: "d8d4cb" 6 | base03: "73777f" 7 | base04: "5a5f66" 8 | base05: "43474e" 9 | base06: "2c3138" 10 | base07: "181c22" 11 | base08: "d02023" 12 | base09: "bf3e05" 13 | base0A: "9d6f00" 14 | base0B: "637200" 15 | base0C: "007a72" 16 | base0D: "0073b5" 17 | base0E: "4e66b6" 18 | base0F: "c42775" 19 | -------------------------------------------------------------------------------- /extra/themes/base16-helios-scheme/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Alex Meyer 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 | -------------------------------------------------------------------------------- /extra/themes/base16-helios-scheme/helios.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Helios" 2 | author: "Alex Meyer (https://github.com/reyemxela)" 3 | base00: "1d2021" # ---- 4 | base01: "383c3e" # --- 5 | base02: "53585b" # -- 6 | base03: "6f7579" # - 7 | base04: "cdcdcd" # + 8 | base05: "d5d5d5" # ++ 9 | base06: "dddddd" # +++ 10 | base07: "e5e5e5" # ++++ 11 | base08: "d72638" # red 12 | base09: "eb8413" # orange 13 | base0A: "f19d1a" # yellow 14 | base0B: "88b92d" # green 15 | base0C: "1ba595" # aqua/cyan 16 | base0D: "1e8bac" # blue 17 | base0E: "be4264" # purple 18 | base0F: "c85e0d" # brown 19 | 20 | -------------------------------------------------------------------------------- /extra/themes/base16-woodland-scheme/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jay Cornwall 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 | -------------------------------------------------------------------------------- /extra/themes/base16-woodland-scheme/woodland.yaml: -------------------------------------------------------------------------------- 1 | scheme: "Woodland" 2 | author: "Jay Cornwall (https://jcornwall.com)" 3 | base00: "231e18" 4 | base01: "302b25" 5 | base02: "48413a" 6 | base03: "9d8b70" 7 | base04: "b4a490" 8 | base05: "cabcb1" 9 | base06: "d7c8bc" 10 | base07: "e4d4c8" 11 | base08: "d35c5c" 12 | base09: "ca7f32" 13 | base0A: "e0ac16" 14 | base0B: "b7ba53" 15 | base0C: "6eb958" 16 | base0D: "88a4d3" 17 | base0E: "bb90e2" 18 | base0F: "b49368" 19 | -------------------------------------------------------------------------------- /extra/wix/banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/wix/banner.png -------------------------------------------------------------------------------- /extra/wix/dialog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/extra/wix/dialog.png -------------------------------------------------------------------------------- /libs/SingleApplication/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Itay Grudev 2015 - 2020 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 13 | all 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 21 | THE SOFTWARE. 22 | 23 | Note: Some of the examples include code not distributed under the terms of the 24 | MIT License. 25 | -------------------------------------------------------------------------------- /libs/dllreflect/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | project(dllreflect-test LANGUAGES CXX) 3 | 4 | set(CMAKE_CXX_STANDARD 17) 5 | 6 | add_executable(dllreflect-test 7 | test.cpp 8 | include/dllreflect.h 9 | ) 10 | -------------------------------------------------------------------------------- /libs/spirv-reflect/spirv_reflect.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // This file exists to force compiling spirv_reflect.c as C++. 3 | // 4 | #include "spirv_reflect.c" -------------------------------------------------------------------------------- /screenshot1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/screenshot1.png -------------------------------------------------------------------------------- /screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/screenshot2.png -------------------------------------------------------------------------------- /src/EditActions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class QAction; 4 | 5 | struct EditActions 6 | { 7 | QAction *windowFileName; 8 | QAction *undo; 9 | QAction *redo; 10 | QAction *cut; 11 | QAction *copy; 12 | QAction *paste; 13 | QAction *delete_; 14 | QAction *selectAll; 15 | QAction *rename; 16 | QAction *findReplace; 17 | }; 18 | -------------------------------------------------------------------------------- /src/Evaluation.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | enum class EvaluationMode { 4 | Paused, 5 | Automatic, 6 | Steady, 7 | }; 8 | 9 | enum class EvaluationType { 10 | Steady, 11 | Automatic, 12 | Manual, 13 | Reset, 14 | }; 15 | -------------------------------------------------------------------------------- /src/Range.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct Range 4 | { 5 | double minimum; 6 | double maximum; 7 | 8 | double range() const { return maximum - minimum; } 9 | 10 | friend bool operator==(const Range &a, const Range &b) 11 | { 12 | return (a.minimum == b.minimum && a.maximum == b.maximum); 13 | } 14 | 15 | friend bool operator!=(const Range &a, const Range &b) { return !(a == b); } 16 | }; 17 | -------------------------------------------------------------------------------- /src/SourceType.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class SourceType { 6 | PlainText, 7 | Generic, 8 | GLSL_VertexShader, 9 | GLSL_FragmentShader, 10 | GLSL_GeometryShader, 11 | GLSL_TessControlShader, 12 | GLSL_TessEvaluationShader, 13 | GLSL_ComputeShader, 14 | GLSL_TaskShader, 15 | GLSL_MeshShader, 16 | GLSL_RayGenerationShader, 17 | GLSL_RayIntersectionShader, 18 | GLSL_RayAnyHitShader, 19 | GLSL_RayClosestHitShader, 20 | GLSL_RayMissShader, 21 | GLSL_RayCallableShader, 22 | HLSL_VertexShader, 23 | HLSL_PixelShader, 24 | HLSL_GeometryShader, 25 | HLSL_HullShader, 26 | HLSL_DomainShader, 27 | HLSL_ComputeShader, 28 | HLSL_AmplificationShader, 29 | HLSL_MeshShader, 30 | HLSL_RayGenerationShader, 31 | HLSL_RayIntersectionShader, 32 | HLSL_RayAnyHitShader, 33 | HLSL_RayClosestHitShader, 34 | HLSL_RayMissShader, 35 | HLSL_RayCallableShader, 36 | JavaScript, 37 | }; 38 | 39 | SourceType deduceSourceType(SourceType current, const QString &extension, 40 | const QString &text); 41 | -------------------------------------------------------------------------------- /src/Style.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Style.h" 3 | #include 4 | #include 5 | 6 | Style::Style() 7 | : QProxyStyle(QStyleFactory::create("Fusion")) 8 | , mDockClose(":images/dock-close.png") 9 | , mDockRestore(":images/dock-restore.png") 10 | { 11 | } 12 | 13 | QIcon Style::standardIcon(QStyle::StandardPixmap standardIcon, 14 | const QStyleOption *option, const QWidget *widget) const 15 | { 16 | switch (standardIcon) { 17 | case SP_DockWidgetCloseButton: 18 | case SP_TitleBarCloseButton: return mDockClose; 19 | case SP_TitleBarNormalButton: return mDockRestore; 20 | default: return QProxyStyle::standardIcon(standardIcon, option, widget); 21 | } 22 | } 23 | 24 | QPixmap Style::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, 25 | const QStyleOption *opt) const 26 | { 27 | if (iconMode == QIcon::Mode::Disabled) { 28 | auto dark = pixmap; 29 | QPainter p(&dark); 30 | p.setCompositionMode(QPainter::CompositionMode_DestinationIn); 31 | p.fillRect(dark.rect(), QColor(0, 0, 0, 128)); 32 | return dark; 33 | } 34 | return pixmap; 35 | } 36 | -------------------------------------------------------------------------------- /src/Style.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Style : public QProxyStyle 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | Style(); 11 | 12 | QIcon standardIcon(StandardPixmap standardIcon, 13 | const QStyleOption *opt = nullptr, 14 | const QWidget *widget = nullptr) const override; 15 | 16 | QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, 17 | const QStyleOption *opt) const override; 18 | 19 | private: 20 | QIcon mDockClose; 21 | QIcon mDockRestore; 22 | }; 23 | -------------------------------------------------------------------------------- /src/Theme.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | enum class ThemeColor { 8 | Function, 9 | Keyword, 10 | BuiltinFunction, 11 | BuiltinConstant, 12 | Number, 13 | Quotation, 14 | Preprocessor, 15 | Comment, 16 | WhiteSpace, 17 | }; 18 | 19 | class Theme 20 | { 21 | public: 22 | static const Theme &getTheme(const QString &fileName); 23 | static QStringList getThemeFileNames(); 24 | 25 | const QString &fileName() const { return mFileName; } 26 | const QString &name() const { return mName; } 27 | const QString &author() const { return mAuthor; } 28 | bool isDarkTheme() const { return mIsDarkTheme; } 29 | const QPalette &palette() const { return mPalette; } 30 | QColor getColor(ThemeColor color) const; 31 | 32 | private: 33 | explicit Theme(const QString &fileName); 34 | 35 | QString mFileName; 36 | QString mName; 37 | QString mAuthor; 38 | bool mIsDarkTheme{}; 39 | QPalette mPalette; 40 | QMap mColors; 41 | }; 42 | 43 | Q_DECLARE_METATYPE(const Theme *); 44 | -------------------------------------------------------------------------------- /src/VideoManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class VideoPlayer; 8 | 9 | class VideoManager : public QObject 10 | { 11 | Q_OBJECT 12 | public: 13 | explicit VideoManager(QObject *parent = nullptr); 14 | VideoManager(const VideoManager &) = delete; 15 | VideoManager &operator=(const VideoManager &) = delete; 16 | ~VideoManager(); 17 | 18 | void unloadAll(); 19 | void playVideoFiles(); 20 | void pauseVideoFiles(); 21 | void rewindVideoFiles(); 22 | 23 | void handleVideoPlayerRequested(const QString &fileName, 24 | bool flipVertically); 25 | 26 | private: 27 | void handleVideoPlayerLoaded(); 28 | 29 | std::map> mVideoPlayers; 30 | bool mVideosPlaying{}; 31 | }; 32 | -------------------------------------------------------------------------------- /src/editors/DockWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class DockWindow : public QMainWindow 6 | { 7 | Q_OBJECT 8 | public: 9 | explicit DockWindow(QWidget *parent = nullptr); 10 | 11 | void raiseDock(QDockWidget *dock); 12 | void closeDock(QDockWidget *dock); 13 | void closeDocksExcept(QTabBar *tabBar, QDockWidget *dock); 14 | 15 | bool eventFilter(QObject *watched, QEvent *event) override; 16 | 17 | Q_SIGNALS: 18 | void openNewDock(); 19 | void dockCloseRequested(QDockWidget *dock); 20 | 21 | private Q_SLOTS: 22 | void openContextMenu(QPoint pos, QTabBar *tabBar, QDockWidget *dock); 23 | void onDockTopLevelChanged(bool topLevel); 24 | 25 | protected: 26 | void childEvent(QChildEvent *event) override; 27 | 28 | private: 29 | void initializeTabBar(QTabBar *tabBar); 30 | void initializeDock(QDockWidget *dock); 31 | void setDockTitleBar(QDockWidget *dock); 32 | }; 33 | -------------------------------------------------------------------------------- /src/editors/IEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "EditActions.h" 4 | #include 5 | #include 6 | 7 | class IEditor 8 | { 9 | public: 10 | virtual ~IEditor() = default; 11 | virtual QList connectEditActions( 12 | const EditActions &actions) = 0; 13 | virtual QString fileName() const = 0; 14 | virtual void setFileName(QString fileName) = 0; 15 | virtual bool load() = 0; 16 | virtual bool save() = 0; 17 | virtual void setModified() = 0; 18 | virtual int tabifyGroup() const = 0; 19 | }; 20 | -------------------------------------------------------------------------------- /src/editors/binary/BinaryEditorToolBar.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "BinaryEditorToolBar.h" 3 | #include "ui_BinaryEditorToolBar.h" 4 | 5 | BinaryEditorToolBar::BinaryEditorToolBar(QWidget *parent) 6 | : QWidget(parent) 7 | , mUi(new Ui::BinaryEditorToolBar()) 8 | { 9 | mUi->setupUi(this); 10 | 11 | connect(mUi->block, qOverload(&QComboBox::currentIndexChanged), this, 12 | &BinaryEditorToolBar::blockIndexChanged); 13 | } 14 | 15 | BinaryEditorToolBar::~BinaryEditorToolBar() 16 | { 17 | delete mUi; 18 | } 19 | 20 | void BinaryEditorToolBar::setBlocks(const QList &blocks) 21 | { 22 | mUi->block->clear(); 23 | for (const auto &block : blocks) 24 | mUi->block->addItem(block.name); 25 | mUi->labelBlock->setVisible(!blocks.empty()); 26 | mUi->block->setVisible(!blocks.empty()); 27 | } 28 | 29 | void BinaryEditorToolBar::setCurrentBlockIndex(int index) 30 | { 31 | mUi->block->setCurrentIndex(index); 32 | } 33 | -------------------------------------------------------------------------------- /src/editors/binary/BinaryEditorToolBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BinaryEditor.h" 4 | #include 5 | 6 | namespace Ui { 7 | class BinaryEditorToolBar; 8 | } 9 | 10 | class BinaryEditorToolBar final : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit BinaryEditorToolBar(QWidget *parent); 15 | ~BinaryEditorToolBar() override; 16 | 17 | void setBlocks(const QList &blocks); 18 | void setCurrentBlockIndex(int index); 19 | 20 | Q_SIGNALS: 21 | void blockIndexChanged(int index); 22 | 23 | private: 24 | Ui::BinaryEditorToolBar *mUi; 25 | }; 26 | -------------------------------------------------------------------------------- /src/editors/source/Completer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | class Completer : public QCompleter 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit Completer(QObject *parent = nullptr); 11 | void setStrings(const QStringList &strings); 12 | void setContextText(const QString &contextText); 13 | 14 | private: 15 | QSet mStrings; 16 | }; 17 | -------------------------------------------------------------------------------- /src/editors/source/FindReplaceBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace Ui { 7 | class FindReplaceBar; 8 | } 9 | 10 | class FindReplaceBar final : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | enum Action { FindTextChanged, Find, Replace, ReplaceAll, Refresh, Cancel }; 15 | 16 | explicit FindReplaceBar(QWidget *parent = nullptr); 17 | ~FindReplaceBar() override; 18 | 19 | void setTarget(QWidget *target); 20 | void setText(const QString &text); 21 | void focus(); 22 | void resetTarget(); 23 | void cancel(); 24 | QWidget *target() const { return mTarget; } 25 | 26 | void findTextChanged(); 27 | void findNext(); 28 | void findPrevious(); 29 | void replace(); 30 | void replaceAll(); 31 | bool replacing() const { return mReplacing; } 32 | 33 | Q_SIGNALS: 34 | void cancelled(); 35 | void action(FindReplaceBar::Action action, QString find, QString replace, 36 | QTextDocument::FindFlags flags); 37 | 38 | protected: 39 | void keyPressEvent(QKeyEvent *event) override; 40 | 41 | private: 42 | void triggerAction(Action action, QTextDocument::FindFlag extraFlags = {}); 43 | QTextDocument::FindFlags findFlags() const; 44 | 45 | Ui::FindReplaceBar *ui; 46 | QWidget *mTarget{}; 47 | bool mReplacing{}; 48 | }; 49 | -------------------------------------------------------------------------------- /src/editors/source/SourceEditorToolBar.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SourceType.h" 4 | #include 5 | 6 | namespace Ui { 7 | class SourceEditorToolBar; 8 | } 9 | 10 | class SourceEditorToolBar final : public QWidget 11 | { 12 | Q_OBJECT 13 | public: 14 | explicit SourceEditorToolBar(QWidget *parent); 15 | ~SourceEditorToolBar() override; 16 | 17 | SourceType sourceType() const { return mSourceType; } 18 | void setSourceType(SourceType sourceType); 19 | bool validateSource() const; 20 | void setValidateSource(bool validate); 21 | bool showWhiteSpace() const; 22 | void setShowWhiteSpace(bool how); 23 | 24 | Q_SIGNALS: 25 | void sourceTypeChanged(SourceType sourceType); 26 | void validateSourceChanged(bool validate); 27 | 28 | private: 29 | Ui::SourceEditorToolBar *mUi; 30 | SourceType mSourceType{}; 31 | }; 32 | -------------------------------------------------------------------------------- /src/editors/source/Syntax.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class Syntax 6 | { 7 | public: 8 | virtual ~Syntax() = default; 9 | virtual QStringList keywords() const { return {}; } 10 | virtual QStringList builtinFunctions() const { return {}; } 11 | virtual QStringList builtinConstants() const { return {}; } 12 | virtual QStringList completerStrings() const { return {}; } 13 | virtual bool hasPreprocessor() const { return false; } 14 | virtual bool hasFunctions() const { return true; } 15 | virtual QString singleLineCommentBegin() const { return "//.*"; } 16 | virtual QString multiLineCommentBegin() const { return "/\\*"; } 17 | virtual QString multiLineCommentEnd() const { return "\\*/"; } 18 | }; 19 | 20 | Syntax *makeSyntaxGeneric(); 21 | Syntax *makeSyntaxGLSL(); 22 | Syntax *makeSyntaxHLSL(); 23 | Syntax *makeSyntaxJavaScript(); 24 | -------------------------------------------------------------------------------- /src/editors/source/SyntaxGeneric.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "Syntax.h" 3 | 4 | class SyntaxGeneric : public Syntax 5 | { 6 | public: 7 | bool hasFunctions() const override { return false; } 8 | QString singleLineCommentBegin() const override { return "^\\s*(#|//).*"; } 9 | QString multiLineCommentBegin() const override { return ""; } 10 | QString multiLineCommentEnd() const override { return ""; } 11 | }; 12 | 13 | Syntax *makeSyntaxGeneric() 14 | { 15 | return new SyntaxGeneric(); 16 | } 17 | -------------------------------------------------------------------------------- /src/editors/source/SyntaxHighlighter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SourceType.h" 4 | #include 5 | #include 6 | 7 | class QCompleter; 8 | class Theme; 9 | 10 | class SyntaxHighlighter final : public QSyntaxHighlighter 11 | { 12 | Q_OBJECT 13 | public: 14 | struct Data; 15 | 16 | SyntaxHighlighter(SourceType sourceType, const Theme &theme, 17 | bool showWhiteSpace, QObject *parent = nullptr); 18 | void highlightBlock(const QString &text) override; 19 | const QStringList &completerStrings() const; 20 | 21 | private: 22 | QSharedPointer mData; 23 | }; 24 | -------------------------------------------------------------------------------- /src/editors/texture/GLWidget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class GLWidget : public QOpenGLWidget 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit GLWidget(QWidget *parent); 19 | ~GLWidget(); 20 | 21 | QOpenGLFunctions_3_3_Core &gl(); 22 | QOpenGLFunctions_4_2_Core *gl42(); 23 | QOpenGLFunctions_4_5_Core *gl45(); 24 | 25 | using QOpenGLWidget::paintEvent; 26 | 27 | Q_SIGNALS: 28 | void initializingGL(); 29 | void paintingGL(); 30 | void releasingGL(); 31 | 32 | protected: 33 | void initializeGL() override; 34 | void paintGL() override; 35 | 36 | private: 37 | void handleDebugMessage(const QOpenGLDebugMessage &message); 38 | void releaseGL(); 39 | 40 | bool mInitialized{}; 41 | QOpenGLFunctions_3_3_Core mGL; 42 | std::optional mGL42; 43 | std::optional mGL45; 44 | QOpenGLVertexArrayObject mVao; 45 | std::unique_ptr mDebugLogger; 46 | }; 47 | -------------------------------------------------------------------------------- /src/editors/texture/Histogram.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Range.h" 4 | #include 5 | 6 | class Histogram : public QWidget 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit Histogram(QWidget *parent = nullptr); 11 | 12 | QSize sizeHint() const override; 13 | 14 | void updateHistogram(const QVector &histogram); 15 | void setHistogramBounds(const Range &bounds); 16 | void setMappingRange(const Range &range); 17 | const Range &mappingRange() const { return mMappingRange; } 18 | 19 | Q_SIGNALS: 20 | void mappingRangeChanged(Range range); 21 | 22 | protected: 23 | void paintEvent(QPaintEvent *ev) override; 24 | void mousePressEvent(QMouseEvent *event) override; 25 | void mouseMoveEvent(QMouseEvent *event) override; 26 | 27 | private: 28 | void updateRange(int mouseX); 29 | 30 | int mHeight{}; 31 | QVector mHistogram; 32 | Range mHistogramBounds{}; 33 | Range mMappingRange{}; 34 | }; 35 | -------------------------------------------------------------------------------- /src/editors/texture/TextureBackground.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class GLWidget; 6 | class QOpenGLShaderProgram; 7 | 8 | class TextureBackground final : public QObject 9 | { 10 | Q_OBJECT 11 | public: 12 | explicit TextureBackground(GLWidget *parent); 13 | ~TextureBackground() override; 14 | void releaseGL(); 15 | void paintGL(const QSizeF &size, const QPointF &offset); 16 | 17 | private: 18 | GLWidget &widget(); 19 | std::unique_ptr mProgram; 20 | }; 21 | -------------------------------------------------------------------------------- /src/getEventPosition.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | template 6 | QPoint getEventPosition(const Event *event) 7 | { 8 | return event->position().toPoint(); 9 | } 10 | 11 | template 12 | QPoint getGlobalEventPosition(const Event *event) 13 | { 14 | return event->globalPosition().toPoint(); 15 | } 16 | -------------------------------------------------------------------------------- /src/icons/dark/icons/application-exit.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/dialog-error.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/dialog-information.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/dialog-warning.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/document-new.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/document-open-recent.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/document-properties.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/document-save-as.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/document-save.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/edit-copy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/edit-delete.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/edit-find-replace.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/edit-paste.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/edit-redo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/edit-undo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/folder-pictures.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/folder.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/font-select.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/icons/dark/icons/format-indent-more.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/format-justify-left.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/help-about.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/help-faq.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/icons/dark/icons/insert-text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/media-playback-pause.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/media-seek-forward.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/media-skip-forward.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/dark/icons/pan-end.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/pan-start.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/preferences-desktop-font.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/icons/dark/icons/preferences-system-notifications.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/icons/dark/icons/process-stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/user-bookmarks.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/icons/dark/icons/video-display.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/view-refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/x-office-spreadsheet.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/icons/zoom-original.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/dark/index.theme: -------------------------------------------------------------------------------- 1 | [Icon Theme] 2 | Name=Dark-icons 3 | Comment=icon theme 4 | 5 | # Directory list 6 | Directories=icons 7 | 8 | [icons] 9 | Size=48 10 | Context=Icons 11 | MinSize=8 12 | MaxSize=512 13 | Type=Scalable -------------------------------------------------------------------------------- /src/icons/light/icons/application-exit.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/dialog-error.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/dialog-warning.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/document-new.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/document-open-recent.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/document-properties.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/document-save-as.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/document-save.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/edit-copy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/edit-delete.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/edit-find-replace.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/edit-paste.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/edit-redo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/edit-undo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/folder-pictures.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/folder.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/font-select.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/icons/light/icons/format-indent-more.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/format-justify-left.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/help-about.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/help-faq.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/icons/light/icons/insert-text.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/media-playback-pause.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/media-seek-forward.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/media-skip-forward.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/icons/light/icons/pan-end.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/pan-start.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/preferences-desktop-font.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/icons/light/icons/preferences-system-notifications.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/icons/light/icons/process-stop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/user-bookmarks.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/icons/light/icons/video-display.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/view-refresh.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/x-office-spreadsheet.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/icons/zoom-original.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/icons/light/index.theme: -------------------------------------------------------------------------------- 1 | [Icon Theme] 2 | Name=Light-icons 3 | Comment=icon theme 4 | 5 | # Directory list 6 | Directories=icons 7 | 8 | [icons] 9 | Size=48 10 | Context=Icons 11 | MinSize=8 12 | MaxSize=512 13 | Type=Scalable -------------------------------------------------------------------------------- /src/images/16x16/window-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/src/images/16x16/window-close.png -------------------------------------------------------------------------------- /src/images/32x32/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/src/images/32x32/icon.png -------------------------------------------------------------------------------- /src/images/64x64/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/src/images/64x64/icon.png -------------------------------------------------------------------------------- /src/images/dock-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/src/images/dock-close.png -------------------------------------------------------------------------------- /src/images/dock-restore.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/src/images/dock-restore.png -------------------------------------------------------------------------------- /src/images/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/houmain/gpupad/39e884945a98174d2efa5980eef3d63570612d3e/src/images/icon.ico -------------------------------------------------------------------------------- /src/render/ComputeRange.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "RenderTask.h" 4 | #include "opengl/GLComputeRange.h" 5 | 6 | class ComputeRange final : public RenderTask 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit ComputeRange(RendererPtr renderer, QObject *parent = nullptr) 11 | : RenderTask(std::move(renderer), parent) 12 | { 13 | Q_ASSERT(RenderTask::renderer().api() == RenderAPI::OpenGL); 14 | } 15 | 16 | ~ComputeRange() override { releaseResources(); } 17 | 18 | void setImage(QOpenGLTexture::Target target, GLuint textureId, 19 | const TextureData &texture, int level, int layer, int face) 20 | { 21 | mImpl.setImage(target, textureId, texture, level, layer, face); 22 | } 23 | 24 | Q_SIGNALS: 25 | void rangeComputed(const Range &range); 26 | 27 | private: 28 | void render() override { mImpl.render(); } 29 | 30 | void finish() override { Q_EMIT rangeComputed(mImpl.range()); } 31 | 32 | void release() override { mImpl.release(); } 33 | 34 | GLComputeRange mImpl; 35 | }; 36 | -------------------------------------------------------------------------------- /src/render/ProcessSource.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "RenderTask.h" 4 | #include "SourceType.h" 5 | #include "MessageList.h" 6 | #include 7 | 8 | class ShaderBase; 9 | using ScriptEnginePtr = std::shared_ptr; 10 | 11 | class ProcessSource final : public RenderTask 12 | { 13 | Q_OBJECT 14 | public: 15 | explicit ProcessSource(RendererPtr renderer, QObject *parent = nullptr); 16 | ~ProcessSource() override; 17 | 18 | void setFileName(QString fileName); 19 | void setSourceType(SourceType sourceType); 20 | void setValidateSource(bool validate); 21 | void setProcessType(QString processType); 22 | void clearMessages(); 23 | 24 | Q_SIGNALS: 25 | void outputChanged(QVariant output); 26 | 27 | private: 28 | void prepare(bool itemsChanged, EvaluationType) override; 29 | void render() override; 30 | void finish() override; 31 | 32 | private: 33 | std::unique_ptr mShader; 34 | QString mFileName; 35 | SourceType mSourceType{}; 36 | MessagePtrSet mMessages; 37 | bool mValidateSource{}; 38 | QString mProcessType{}; 39 | QVariant mOutput; 40 | }; 41 | -------------------------------------------------------------------------------- /src/render/Renderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | enum class RenderAPI : int { 6 | OpenGL, 7 | Vulkan, 8 | }; 9 | 10 | using RendererPtr = std::shared_ptr; 11 | class QThread; 12 | class RenderTask; 13 | 14 | class Renderer 15 | { 16 | public: 17 | explicit Renderer(RenderAPI api) : mApi(api) { } 18 | 19 | virtual ~Renderer() = default; 20 | virtual QThread *renderThread() = 0; 21 | 22 | RenderAPI api() const { return mApi; } 23 | 24 | private: 25 | friend class RenderTask; 26 | virtual void render(RenderTask *task) = 0; 27 | virtual void release(RenderTask *task) = 0; 28 | 29 | RenderAPI mApi; 30 | }; 31 | -------------------------------------------------------------------------------- /src/render/ShareSync.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class QOpenGLFunctions_3_3_Core; 6 | using ShareSyncPtr = std::shared_ptr; 7 | 8 | class ShareSync 9 | { 10 | public: 11 | ~ShareSync() = default; 12 | virtual void beginUsage(QOpenGLFunctions_3_3_Core &gl) = 0; 13 | virtual void endUsage(QOpenGLFunctions_3_3_Core &gl) = 0; 14 | }; 15 | -------------------------------------------------------------------------------- /src/render/opengl/GLComputeRange.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Range.h" 4 | #include "TextureData.h" 5 | #include 6 | #include 7 | #include 8 | 9 | class GLComputeRange 10 | { 11 | public: 12 | void render(); 13 | void release(); 14 | 15 | void setImage(QOpenGLTexture::Target target, GLuint textureId, 16 | const TextureData &texture, int level, int layer, int face); 17 | const Range &range() const { return mRange; } 18 | 19 | private: 20 | using ProgramKey = 21 | std::tuple; 22 | 23 | QOpenGLShaderProgram *getProgram(QOpenGLTexture::Target target, 24 | QOpenGLTexture::TextureFormat format); 25 | 26 | QOpenGLTexture::Target mTarget{}; 27 | QOpenGLTexture::TextureFormat mFormat{}; 28 | QSize mSize{}; 29 | int mLevel{}; 30 | int mLayer{}; 31 | int mFace{}; 32 | GLuint mTextureId{}; 33 | Range mRange{ 0, 1 }; 34 | QOpenGLBuffer mBuffer; 35 | std::map mPrograms; 36 | }; 37 | -------------------------------------------------------------------------------- /src/render/opengl/GLItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "FileCache.h" 4 | #include "FileDialog.h" 5 | #include "GLContext.h" 6 | #include "GLObject.h" 7 | #include "Singletons.h" 8 | #include "session/Item.h" 9 | #include "GLRenderSession.h" 10 | #include 11 | #include 12 | 13 | template 14 | inline T *checkVersion(T *gl, const char *name, ItemId itemId, 15 | MessagePtrSet &messages) 16 | { 17 | if (gl) 18 | return gl; 19 | messages += MessageList::insert(itemId, 20 | MessageType::OpenGLVersionNotAvailable, name); 21 | return nullptr; 22 | } 23 | 24 | inline auto check(QOpenGLFunctions_4_0_Core *gl, ItemId itemId, 25 | MessagePtrSet &messages) 26 | { 27 | return checkVersion(gl, "4.0", itemId, messages); 28 | } 29 | 30 | inline auto check(QOpenGLFunctions_4_2_Core *gl, ItemId itemId, 31 | MessagePtrSet &messages) 32 | { 33 | return checkVersion(gl, "4.2", itemId, messages); 34 | } 35 | 36 | inline auto check(QOpenGLFunctions_4_3_Core *gl, ItemId itemId, 37 | MessagePtrSet &messages) 38 | { 39 | return checkVersion(gl, "4.3", itemId, messages); 40 | } 41 | 42 | inline auto check(QOpenGLFunctions_4_5_Core *gl, ItemId itemId, 43 | MessagePtrSet &messages) 44 | { 45 | return checkVersion(gl, "4.5", itemId, messages); 46 | } 47 | -------------------------------------------------------------------------------- /src/render/opengl/GLObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class GLObject 6 | { 7 | public: 8 | using GLuint = unsigned int; 9 | using Free = void (*)(GLuint object); 10 | 11 | GLObject() = default; 12 | 13 | GLObject(GLuint object, Free free) noexcept : mObject(object), mFree(free) 14 | { 15 | } 16 | 17 | GLObject(GLObject &&rhs) noexcept 18 | { 19 | std::swap(mObject, rhs.mObject); 20 | std::swap(mFree, rhs.mFree); 21 | } 22 | 23 | GLObject &operator=(GLObject &&rhs) noexcept 24 | { 25 | auto tmp = std::move(rhs); 26 | std::swap(mObject, tmp.mObject); 27 | std::swap(mFree, tmp.mFree); 28 | return *this; 29 | } 30 | 31 | ~GLObject() { reset(); } 32 | 33 | explicit operator bool() const { return (mObject != 0); } 34 | operator GLuint() const { return mObject; } 35 | 36 | void reset() 37 | { 38 | if (mFree) { 39 | mFree(mObject); 40 | mObject = {}; 41 | mFree = nullptr; 42 | } 43 | } 44 | 45 | private: 46 | GLuint mObject{}; 47 | Free mFree{}; 48 | }; 49 | -------------------------------------------------------------------------------- /src/render/opengl/GLPrintf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GLItem.h" 4 | #include "render/ShaderPrintf.h" 5 | 6 | class GLPrintf : public ShaderPrintf 7 | { 8 | public: 9 | const GLObject &bufferObject() const { return mBufferObject; } 10 | void clear(); 11 | MessagePtrSet formatMessages(ItemId callItemId); 12 | 13 | private: 14 | GLObject mBufferObject; 15 | }; 16 | -------------------------------------------------------------------------------- /src/render/opengl/GLRenderSession.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "render/RenderSessionBase.h" 4 | #include 5 | 6 | class GLShareSync; 7 | class QOpenGLTimerQuery; 8 | 9 | class GLRenderSession final : public RenderSessionBase 10 | { 11 | public: 12 | GLRenderSession(RendererPtr renderer, const QString &basePath); 13 | ~GLRenderSession(); 14 | 15 | void render() override; 16 | void finish() override; 17 | void release() override; 18 | quint64 getTextureHandle(ItemId itemId) override; 19 | quint64 getBufferHandle(ItemId itemId) override { return 0; } 20 | 21 | private: 22 | struct CommandQueue; 23 | 24 | void createCommandQueue(); 25 | void buildCommandQueue(); 26 | void reuseUnmodifiedItems(); 27 | void executeCommandQueue(); 28 | void downloadModifiedResources(); 29 | void outputTimerQueries(); 30 | 31 | QOpenGLVertexArrayObject mVao; 32 | std::shared_ptr mShareSync; 33 | std::unique_ptr mCommandQueue; 34 | std::unique_ptr mPrevCommandQueue; 35 | MessagePtrSet mTimerMessages; 36 | }; 37 | -------------------------------------------------------------------------------- /src/render/opengl/GLRenderer.h: -------------------------------------------------------------------------------- 1 | 2 | #include "render/Renderer.h" 3 | #include 4 | #include 5 | 6 | class GLRenderer : public QObject, public Renderer 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit GLRenderer(QObject *parent = nullptr); 11 | ~GLRenderer() override; 12 | 13 | void render(RenderTask *task) override; 14 | void release(RenderTask *task) override; 15 | QThread* renderThread() override { return &mThread; } 16 | 17 | Q_SIGNALS: 18 | void configureTask(RenderTask *renderTask, QPrivateSignal); 19 | void renderTask(RenderTask *renderTask, QPrivateSignal); 20 | void releaseTask(RenderTask *renderTask, void *userData, QPrivateSignal); 21 | 22 | private: 23 | class Worker; 24 | void handleTaskConfigured(); 25 | void handleTaskRendered(); 26 | void renderNextTask(); 27 | 28 | QThread mThread; 29 | std::unique_ptr mWorker; 30 | QList mPendingTasks; 31 | RenderTask *mCurrentTask{}; 32 | }; 33 | 34 | QString getFirstGLError(); 35 | -------------------------------------------------------------------------------- /src/render/opengl/GLShader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GLPrintf.h" 4 | #include "render/ShaderBase.h" 5 | 6 | class GLShader : public ShaderBase 7 | { 8 | public: 9 | static void parseLog(const QString &log, MessagePtrSet &messages, 10 | ItemId itemId, const QStringList &fileNames); 11 | 12 | GLShader(Shader::ShaderType type, const QList &shaders, 13 | const Session &session); 14 | 15 | bool compile(ShaderPrintf &printf); 16 | bool specialize(const Spirv &spirv); 17 | GLuint shaderObject() const { return mShaderObject; } 18 | 19 | private: 20 | GLObject createShader(); 21 | bool setShaderObject(GLObject shader, const QStringList &usedFileNames); 22 | QStringList preprocessorDefinitions() const override; 23 | 24 | GLObject mShaderObject; 25 | }; 26 | 27 | QString tryGetProgramBinary(const GLShader &shader); 28 | void tryGetLinkerWarnings(const GLShader &shader, MessagePtrSet &messages); 29 | -------------------------------------------------------------------------------- /src/render/opengl/GLStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GLBuffer.h" 4 | #include "GLProgram.h" 5 | 6 | struct GLAttribute 7 | { 8 | QSet usedItems; 9 | QString name; 10 | bool normalize{}; 11 | int divisor{}; 12 | GLBuffer *buffer{}; 13 | Field::DataType type{}; 14 | int count{}; 15 | int stride{}; 16 | int offset{}; 17 | }; 18 | 19 | class GLStream 20 | { 21 | public: 22 | explicit GLStream(const Stream &stream); 23 | void setAttribute(int attributeIndex, const Field &column, GLBuffer *buffer, 24 | ScriptEngine &scriptEngine); 25 | 26 | ItemId itemId() const { return mItemId; } 27 | const GLAttribute *findAttribute(const QString &name) const; 28 | int maxElementCount() const { return mMaxElementCount; } 29 | 30 | private: 31 | bool validateAttribute(const GLAttribute &attribute) const; 32 | 33 | ItemId mItemId{}; 34 | MessagePtrSet mMessages; 35 | QMap mAttributes; 36 | int mMaxElementCount{ -1 }; 37 | }; 38 | -------------------------------------------------------------------------------- /src/render/opengl/GLTarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "GLTexture.h" 4 | 5 | class GLTarget 6 | { 7 | public: 8 | GLTarget(const Target &target, GLRenderSession &renderSession); 9 | void setAttachment(int index, GLTexture *texture); 10 | 11 | bool bind(); 12 | void unbind(); 13 | const QSet &usedItems() const { return mUsedItems; } 14 | 15 | private: 16 | struct GLAttachment : Attachment 17 | { 18 | GLTexture *texture{}; 19 | GLenum attachmentPoint{}; 20 | }; 21 | 22 | bool create(); 23 | void applyStates(); 24 | void applyAttachmentStates(const GLAttachment &attachment); 25 | 26 | ItemId mItemId{}; 27 | MessagePtrSet mMessages; 28 | QSet mUsedItems; 29 | Target::FrontFace mFrontFace{}; 30 | Target::CullMode mCullMode{}; 31 | Target::PolygonMode mPolygonMode{}; 32 | Target::LogicOperation mLogicOperation{}; 33 | QColor mBlendConstant{}; 34 | QMap mAttachments; 35 | int mDefaultWidth{}; 36 | int mDefaultHeight{}; 37 | int mDefaultLayers{}; 38 | int mDefaultSamples{}; 39 | GLObject mFramebufferObject; 40 | }; 41 | -------------------------------------------------------------------------------- /src/render/vulkan/KDGpuEnums.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VKContext.h" 4 | #include "session/Item.h" 5 | #include 6 | 7 | KDGpu::Format toKDGpu(QOpenGLTexture::TextureFormat format); 8 | KDGpu::Format toKDGpu(Field::DataType dataType, int count); 9 | KDGpu::Format toKDGpu(Binding::ImageFormat format); 10 | KDGpu::PrimitiveTopology toKDGpu(Call::PrimitiveType primitiveType); 11 | KDGpu::CullModeFlags toKDGpu(Target::CullMode cullMode); 12 | KDGpu::FrontFace toKDGpu(Target::FrontFace frontFace); 13 | KDGpu::PolygonMode toKDGpu(Target::PolygonMode polygonMode); 14 | KDGpu::BlendOperation toKDGpu(Attachment::BlendEquation eq); 15 | KDGpu::BlendFactor toKDGpu(Attachment::BlendFactor factor); 16 | KDGpu::CompareOperation toKDGpu(Attachment::ComparisonFunc func); 17 | KDGpu::StencilOperation toKDGpu(Attachment::StencilOperation op); 18 | KDGpu::SampleCountFlagBits getKDSampleCount(int samples); 19 | int getKDSamples(KDGpu::SampleCountFlags sampleCounts); 20 | std::optional getKDIndexType(int size); 21 | -------------------------------------------------------------------------------- /src/render/vulkan/VKItem.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "FileCache.h" 4 | #include "FileDialog.h" 5 | #include "KDGpuEnums.h" 6 | #include "MessageList.h" 7 | #include "Singletons.h" 8 | #include "VKRenderSession.h" 9 | 10 | // prevent COM from polluting global scope 11 | #if defined(interface) 12 | # undef interface 13 | #endif 14 | -------------------------------------------------------------------------------- /src/render/vulkan/VKPrintf.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VKItem.h" 4 | #include "render/ShaderPrintf.h" 5 | 6 | class VKPrintf : public ShaderPrintf 7 | { 8 | public: 9 | KDGpu::Buffer &getInitializedBuffer(VKContext &context); 10 | MessagePtrSet formatMessages(VKContext &context, ItemId callItemId); 11 | 12 | private: 13 | KDGpu::Buffer mBuffer; 14 | }; 15 | -------------------------------------------------------------------------------- /src/render/vulkan/VKProgram.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VKShader.h" 4 | 5 | class VKProgram 6 | { 7 | public: 8 | using StageInterface = 9 | std::map; 10 | 11 | VKProgram(const Program &program, const Session &session); 12 | bool operator==(const VKProgram &rhs) const; 13 | 14 | bool link(KDGpu::Device &device); 15 | std::vector getShaderStages(); 16 | ItemId itemId() const { return mItemId; } 17 | const Session &session() const { return mSession; } 18 | const QSet &usedItems() const { return mUsedItems; } 19 | const StageInterface &interface() const { return mInterface; } 20 | const std::vector &shaders() const { return mShaders; } 21 | VKPrintf &printf() { return mPrintf; } 22 | 23 | private: 24 | ItemId mItemId{}; 25 | Session mSession{}; 26 | QSet mUsedItems; 27 | MessagePtrSet mLinkMessages; 28 | std::vector mShaders; 29 | std::vector mIncludableShaders; 30 | StageInterface mInterface; 31 | VKPrintf mPrintf; 32 | bool mCompileShadersSeparately{}; 33 | bool mFailed{}; 34 | }; 35 | -------------------------------------------------------------------------------- /src/render/vulkan/VKRenderSession.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "render/RenderSessionBase.h" 4 | #include "VKContext.h" 5 | 6 | class VKRenderer; 7 | class VKShareSync; 8 | 9 | class VKRenderSession final : public RenderSessionBase 10 | { 11 | public: 12 | VKRenderSession(RendererPtr renderer, const QString &basePath); 13 | ~VKRenderSession(); 14 | 15 | void render() override; 16 | void finish() override; 17 | void release() override; 18 | quint64 getTextureHandle(ItemId itemId) override { return 0; } 19 | quint64 getBufferHandle(ItemId itemId) override; 20 | 21 | private: 22 | struct CommandQueue; 23 | 24 | VKRenderer &renderer(); 25 | void createCommandQueue(); 26 | void buildCommandQueue(); 27 | void reuseUnmodifiedItems(); 28 | void executeCommandQueue(); 29 | void downloadModifiedResources(); 30 | void outputTimerQueries(); 31 | 32 | std::shared_ptr mShareSync; 33 | std::unique_ptr mCommandQueue; 34 | std::unique_ptr mPrevCommandQueue; 35 | MessagePtrSet mTimerMessages; 36 | }; 37 | -------------------------------------------------------------------------------- /src/render/vulkan/VKRenderer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "render/Renderer.h" 4 | #include 5 | #include 6 | 7 | namespace KDGpu { 8 | class Device; 9 | class Queue; 10 | } 11 | struct ktxVulkanDeviceInfo; 12 | 13 | class VKRenderer : public QObject, public Renderer 14 | { 15 | Q_OBJECT 16 | public: 17 | explicit VKRenderer(QObject *parent = nullptr); 18 | ~VKRenderer() override; 19 | 20 | void render(RenderTask *task) override; 21 | void release(RenderTask *task) override; 22 | QThread *renderThread() override { return &mThread; } 23 | 24 | KDGpu::Device &device(); 25 | KDGpu::Queue &queue(); 26 | ktxVulkanDeviceInfo &ktxDeviceInfo(); 27 | 28 | Q_SIGNALS: 29 | void configureTask(RenderTask *renderTask, QPrivateSignal); 30 | void renderTask(RenderTask *renderTask, QPrivateSignal); 31 | void releaseTask(RenderTask *renderTask, void *userData, QPrivateSignal); 32 | 33 | private: 34 | class Worker; 35 | void handleTaskConfigured(); 36 | void handleTaskRendered(); 37 | void renderNextTask(); 38 | 39 | QThread mThread; 40 | std::unique_ptr mWorker; 41 | QList mPendingTasks; 42 | RenderTask *mCurrentTask{}; 43 | KDGpu::Device *mDevice{}; 44 | KDGpu::Queue *mQueue{}; 45 | ktxVulkanDeviceInfo *mKtxDeviceInfo{}; 46 | }; 47 | -------------------------------------------------------------------------------- /src/render/vulkan/VKShader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VKPrintf.h" 4 | #include "render/ShaderBase.h" 5 | 6 | class VKShader : public ShaderBase 7 | { 8 | public: 9 | VKShader(Shader::ShaderType type, const QList &shaders, 10 | const Session &session); 11 | 12 | void setShaderIndex(int index) { mShaderIndex = index; } 13 | int shaderIndex() const { return mShaderIndex; } 14 | void create(KDGpu::Device &device, const Spirv &spirv); 15 | const Spirv::Interface &interface() const { return mInterface; } 16 | KDGpu::ShaderStage getShaderStage() const; 17 | 18 | private: 19 | QStringList preprocessorDefinitions() const override; 20 | 21 | KDGpu::ShaderModule mShaderModule; 22 | Spirv::Interface mInterface; 23 | int mShaderIndex{ -1 }; 24 | }; 25 | -------------------------------------------------------------------------------- /src/render/vulkan/VKStream.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VKBuffer.h" 4 | 5 | class VKStream 6 | { 7 | public: 8 | explicit VKStream(const Stream &stream); 9 | void setAttribute(int attributeIndex, const Field &column, VKBuffer *buffer, 10 | ScriptEngine &scriptEngine); 11 | 12 | const std::vector &getBuffers(); 13 | const std::vector &getBufferOffsets(); 14 | const KDGpu::VertexOptions &getVertexOptions(); 15 | const QSet &usedItems() const { return mUsedItems; } 16 | int maxElementCount() const { return mMaxElementCount; } 17 | 18 | private: 19 | struct VKAttribute 20 | { 21 | QString name; 22 | bool normalize{}; 23 | int divisor{}; 24 | VKBuffer *buffer{}; 25 | Field::DataType type{}; 26 | int count{}; 27 | int stride{}; 28 | int offset{}; 29 | }; 30 | 31 | bool validateAttribute(const VKAttribute &attribute) const; 32 | void invalidateVertexOptions(); 33 | void updateVertexOptions(); 34 | 35 | ItemId mItemId{}; 36 | MessagePtrSet mMessages; 37 | QSet mUsedItems; 38 | QMap mAttributes; 39 | std::vector mBuffers; 40 | std::vector mBufferOffsets; 41 | KDGpu::VertexOptions mVertexOptions; 42 | int mMaxElementCount{ -1 }; 43 | }; 44 | -------------------------------------------------------------------------------- /src/render/vulkan/VKTarget.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "VKTexture.h" 4 | 5 | class VKTarget 6 | { 7 | public: 8 | VKTarget(const Target &target, VKRenderSession &renderSession); 9 | void setTexture(int index, VKTexture *texture); 10 | 11 | KDGpu::RenderPassCommandRecorderOptions prepare(VKContext &context); 12 | std::vector getRenderTargetOptions(); 13 | KDGpu::DepthStencilOptions getDepthStencilOptions(); 14 | KDGpu::MultisampleOptions getMultisampleOptions(); 15 | KDGpu::PrimitiveOptions getPrimitiveOptions(); 16 | 17 | bool hasAttachment(const VKTexture *texture) const; 18 | const QSet &usedItems() const { return mUsedItems; }; 19 | 20 | private: 21 | struct VKAttachment : Attachment 22 | { 23 | VKTexture *texture{}; 24 | }; 25 | 26 | ItemId mItemId{}; 27 | MessagePtrSet mMessages; 28 | QSet mUsedItems; 29 | Target::FrontFace mFrontFace{}; 30 | Target::CullMode mCullMode{}; 31 | Target::PolygonMode mPolygonMode{}; 32 | Target::LogicOperation mLogicOperation{}; 33 | QColor mBlendConstant{}; 34 | QMap mAttachments; 35 | int mSamples{}; 36 | int mDefaultWidth{}; 37 | int mDefaultHeight{}; 38 | int mDefaultLayers{}; 39 | }; 40 | -------------------------------------------------------------------------------- /src/resources.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON ICON "images/icon.ico" 2 | 3 | #include 4 | 5 | 1 VERSIONINFO FILEVERSION 1, 6 | 0, 0, 0 PRODUCTVERSION 1, 0, 0, 7 | 0 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK FILEFLAGS 0 FILEOS VOS_NT_WINDOWS32 8 | FILETYPE VFT_APP FILESUBTYPE VFT2_UNKNOWN 9 | 10 | BEGIN BLOCK "StringFileInfo" BEGIN BLOCK 11 | "040904B0" // US English, Unicode 12 | BEGIN VALUE "CompanyName", 13 | "\0" VALUE "FileDescription", "GPUpad\0" VALUE "FileVersion", 14 | "1.0\0" VALUE "InternalName", "gpupad\0" VALUE "OriginalFilename", 15 | "gpupad.exe\0" VALUE "ProductName", "GPUpad\0" VALUE "ProductVersion", 16 | "1,0,0,0\0" VALUE "LegalCopyright", 17 | "\0" END END 18 | 19 | BLOCK "VarFileInfo" BEGIN VALUE "Translation", 20 | 0x0409, 0x04B0 END END 21 | -------------------------------------------------------------------------------- /src/scripting/IScriptRenderSession.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "session/Item.h" 4 | 5 | class SessionModel; 6 | 7 | class IScriptRenderSession 8 | { 9 | public: 10 | virtual ~IScriptRenderSession() = default; 11 | virtual QThread *renderThread() = 0; 12 | virtual const QString &basePath() = 0; 13 | virtual SessionModel &sessionModelCopy() = 0; 14 | virtual quint64 getTextureHandle(ItemId itemId) = 0; 15 | virtual quint64 getBufferHandle(ItemId itemId) = 0; 16 | }; 17 | -------------------------------------------------------------------------------- /src/scripting/ScriptEngine.js: -------------------------------------------------------------------------------- 1 | 2 | (function() { 3 | function output(level) { 4 | return function() { 5 | var text = '' 6 | for (var i = 0, n = arguments.length; i < n; i++) { 7 | text += (i == 0 ? '' : ' ') 8 | if (typeof arguments[i] === 'object') 9 | text += JSON.stringify(arguments[i], null, 2) 10 | else 11 | text += arguments[i] 12 | } 13 | console.output(text, level) 14 | } 15 | } 16 | console.log = output(0) 17 | console.warn = output(1) 18 | console.error = output(2) 19 | })(); 20 | -------------------------------------------------------------------------------- /src/scripting/ScriptSession.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MessageList.h" 4 | #include 5 | 6 | using ScriptEnginePtr = std::shared_ptr; 7 | using ScriptValue = double; 8 | using ScriptValueList = QList; 9 | class IScriptRenderSession; 10 | 11 | class ScriptSession final : public QObject 12 | { 13 | Q_OBJECT 14 | public: 15 | ScriptSession(IScriptRenderSession *renderSession, 16 | QObject *parent = nullptr); 17 | void resetEngine(); 18 | 19 | // 1. called in main thread 20 | bool usesMouseState() const; 21 | bool usesKeyboardState() const; 22 | bool usesViewportSize(const QString &fileName) const; 23 | void update(); 24 | MessagePtrSet resetMessages(); 25 | 26 | // 2. called in render thread 27 | void beginSessionUpdate(); 28 | ScriptEngine &engine(); 29 | 30 | // 3. called in main thread 31 | void endSessionUpdate(); 32 | 33 | private: 34 | IScriptRenderSession &mRenderSession; 35 | ScriptEnginePtr mScriptEngine; 36 | }; 37 | -------------------------------------------------------------------------------- /src/scripting/objects/ConsoleScriptObject.cpp: -------------------------------------------------------------------------------- 1 | #include "ConsoleScriptObject.h" 2 | #include 3 | 4 | ConsoleScriptObject::ConsoleScriptObject(MessagePtrSet *messages, 5 | QObject *parent) 6 | : QObject(parent) 7 | , mMessages(*messages) 8 | { 9 | } 10 | 11 | void ConsoleScriptObject::setFileName(const QString &fileName) 12 | { 13 | mFileName = fileName; 14 | mItemId = {}; 15 | } 16 | 17 | void ConsoleScriptObject::setItemId(ItemId itemId) 18 | { 19 | mItemId = itemId; 20 | mFileName.clear(); 21 | } 22 | 23 | void ConsoleScriptObject::output(QString message, int level) 24 | { 25 | static const auto emptyObjectName = QRegularExpression( 26 | R"("objectName":\s*"",\s*)", QRegularExpression::MultilineOption); 27 | message = message.replace(emptyObjectName, ""); 28 | 29 | const auto messageType = (level == 2 ? MessageType::ScriptError 30 | : level == 1 ? MessageType::ScriptWarning 31 | : MessageType::ScriptMessage); 32 | 33 | mMessages += (!mFileName.isEmpty() 34 | ? MessageList::insert(mFileName, 0, messageType, message, false) 35 | : MessageList::insert(mItemId, messageType, message, false)); 36 | } 37 | -------------------------------------------------------------------------------- /src/scripting/objects/ConsoleScriptObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MessageList.h" 4 | #include 5 | 6 | class ConsoleScriptObject : public QObject 7 | { 8 | Q_OBJECT 9 | public: 10 | explicit ConsoleScriptObject(MessagePtrSet *messages, QObject *parent = 0); 11 | 12 | void setFileName(const QString &fileName); 13 | void setItemId(ItemId itemId); 14 | 15 | Q_INVOKABLE void output(QString message, int level); 16 | 17 | private: 18 | MessagePtrSet &mMessages; 19 | QString mFileName; 20 | ItemId mItemId{}; 21 | }; 22 | -------------------------------------------------------------------------------- /src/scripting/objects/EditorScriptObject.cpp: -------------------------------------------------------------------------------- 1 | #include "EditorScriptObject.h" 2 | #include "AppScriptObject.h" 3 | #include "Singletons.h" 4 | #include "editors/EditorManager.h" 5 | #include 6 | 7 | EditorScriptObject::EditorScriptObject(AppScriptObject *appScriptObject, 8 | const QString &fileName) 9 | : QObject(appScriptObject) 10 | , mAppScriptObject(appScriptObject) 11 | , mFileName(fileName) 12 | { 13 | } 14 | 15 | EditorScriptObject::~EditorScriptObject() 16 | { 17 | if (mAppScriptObject) 18 | mAppScriptObject->deregisterEditorScriptObject(this); 19 | } 20 | 21 | void EditorScriptObject::resetAppScriptObject() 22 | { 23 | mAppScriptObject = nullptr; 24 | } 25 | 26 | void EditorScriptObject::update() 27 | { 28 | mViewportSizeWasRead = false; 29 | mViewportSize = Singletons::editorManager().getViewportSize(mFileName); 30 | } 31 | 32 | QJsonValue EditorScriptObject::viewportSize() const 33 | { 34 | mViewportSizeWasRead = true; 35 | return QJsonArray({ mViewportSize.width(), mViewportSize.height() }); 36 | } 37 | -------------------------------------------------------------------------------- /src/scripting/objects/EditorScriptObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | class AppScriptObject; 8 | 9 | class EditorScriptObject final : public QObject 10 | { 11 | Q_OBJECT 12 | Q_PROPERTY(QString fileName READ fileName CONSTANT); 13 | Q_PROPERTY(QJsonValue viewportSize READ viewportSize NOTIFY viewportResized) 14 | 15 | public: 16 | EditorScriptObject(AppScriptObject *appScriptObject, 17 | const QString &fileName); 18 | ~EditorScriptObject(); 19 | 20 | void resetAppScriptObject(); 21 | void update(); 22 | 23 | const QString &fileName() const { return mFileName; } 24 | QJsonValue viewportSize() const; 25 | bool viewportSizeWasRead() const { return mViewportSizeWasRead; } 26 | 27 | Q_SIGNALS: 28 | void viewportResized(); 29 | 30 | private: 31 | AppScriptObject *mAppScriptObject{ }; 32 | QString mFileName; 33 | QSize mViewportSize{ 256, 256 }; 34 | mutable bool mViewportSizeWasRead{}; 35 | }; 36 | -------------------------------------------------------------------------------- /src/scripting/objects/KeyboardScriptObject.cpp: -------------------------------------------------------------------------------- 1 | #include "KeyboardScriptObject.h" 2 | #include 3 | 4 | KeyboardScriptObject::KeyboardScriptObject(QObject *parent) : QObject(parent) 5 | { 6 | update(InputState()); 7 | } 8 | 9 | void KeyboardScriptObject::update(const InputState &state) 10 | { 11 | mWasRead = false; 12 | auto keys = QJsonArray(); 13 | for (auto key : state.keyStates()) 14 | keys.push_back(static_cast(key)); 15 | mKeys = keys; 16 | Q_EMIT changed(); 17 | } 18 | 19 | const QJsonValue &KeyboardScriptObject::keys() const 20 | { 21 | mWasRead = true; 22 | return mKeys; 23 | } 24 | -------------------------------------------------------------------------------- /src/scripting/objects/KeyboardScriptObject.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "InputState.h" 4 | #include 5 | #include 6 | 7 | class KeyboardScriptObject final : public QObject 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(QJsonValue keys READ keys NOTIFY changed) 11 | 12 | public: 13 | explicit KeyboardScriptObject(QObject *parent = nullptr); 14 | 15 | void update(const InputState &state); 16 | 17 | const QJsonValue &keys() const; 18 | bool wasRead() const { return mWasRead; } 19 | 20 | Q_SIGNALS: 21 | void changed(); 22 | 23 | private: 24 | QJsonValue mKeys; 25 | mutable bool mWasRead{}; 26 | }; 27 | -------------------------------------------------------------------------------- /src/session/AttachmentProperties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class AttachmentProperties; 9 | } 10 | 11 | class QDataWidgetMapper; 12 | class PropertiesEditor; 13 | 14 | class AttachmentProperties final : public QWidget 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit AttachmentProperties(PropertiesEditor *propertiesEditor); 19 | ~AttachmentProperties(); 20 | 21 | TextureKind currentTextureKind() const; 22 | void addMappings(QDataWidgetMapper &mapper); 23 | 24 | protected: 25 | void showEvent(QShowEvent *event) override; 26 | 27 | private: 28 | void updateWidgets(); 29 | 30 | PropertiesEditor &mPropertiesEditor; 31 | Ui::AttachmentProperties *mUi; 32 | }; 33 | -------------------------------------------------------------------------------- /src/session/BindingProperties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class BindingProperties; 9 | } 10 | 11 | class PropertiesEditor; 12 | class QDataWidgetMapper; 13 | 14 | class BindingProperties final : public QWidget 15 | { 16 | Q_OBJECT 17 | Q_PROPERTY(QStringList values READ values WRITE setValues NOTIFY 18 | valuesChanged USER true) 19 | public: 20 | explicit BindingProperties(PropertiesEditor *propertiesEditor); 21 | ~BindingProperties(); 22 | 23 | void addMappings(QDataWidgetMapper &mapper); 24 | Binding::BindingType currentType() const; 25 | Binding::Editor currentEditor() const; 26 | TextureKind currentTextureKind() const; 27 | void setValues(const QStringList &values); 28 | QStringList values() const; 29 | 30 | Q_SIGNALS: 31 | void valuesChanged(); 32 | 33 | private: 34 | void updateWidgets(); 35 | int getTextureStride(QVariant textureId) const; 36 | int getBufferStride(QVariant blockId) const; 37 | void filterImageFormats(int stride); 38 | 39 | PropertiesEditor &mPropertiesEditor; 40 | Ui::BindingProperties *mUi; 41 | QStringList mValues; 42 | bool mSuspendSetValues{}; 43 | }; 44 | -------------------------------------------------------------------------------- /src/session/CallProperties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class CallProperties; 9 | } 10 | 11 | class QDataWidgetMapper; 12 | class PropertiesEditor; 13 | 14 | class CallProperties final : public QWidget 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit CallProperties(PropertiesEditor *propertiesEditor); 19 | ~CallProperties(); 20 | 21 | Call::CallType currentType() const; 22 | Call::PrimitiveType currentPrimitiveType() const; 23 | CallKind currentCallKind() const; 24 | TextureKind currentTextureKind() const; 25 | void addMappings(QDataWidgetMapper &mapper); 26 | 27 | private: 28 | void updateWidgets(); 29 | 30 | PropertiesEditor &mPropertiesEditor; 31 | Ui::CallProperties *mUi; 32 | }; 33 | -------------------------------------------------------------------------------- /src/session/ColorMask.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class QCheckBox; 6 | 7 | class ColorMask final : public QWidget 8 | { 9 | Q_OBJECT 10 | Q_PROPERTY(unsigned int colorMask READ colorMask WRITE setColorMask NOTIFY 11 | colorMaskChanged USER true) 12 | public: 13 | explicit ColorMask(QWidget *parent = nullptr); 14 | unsigned int colorMask() const; 15 | void setColorMask(unsigned int colorMask); 16 | 17 | Q_SIGNALS: 18 | void colorMaskChanged(unsigned int colorMask); 19 | 20 | private: 21 | void handleColorMaskToggled(); 22 | 23 | QCheckBox *mColorR{}; 24 | QCheckBox *mColorG{}; 25 | QCheckBox *mColorB{}; 26 | QCheckBox *mColorA{}; 27 | unsigned int mColorMask{}; 28 | }; 29 | -------------------------------------------------------------------------------- /src/session/ColorPicker.cpp: -------------------------------------------------------------------------------- 1 | #include "ColorPicker.h" 2 | #include 3 | 4 | ColorPicker::ColorPicker(QWidget *parent) : QToolButton(parent) 5 | { 6 | setIconSize(QSize(16, 16)); 7 | setAutoFillBackground(true); 8 | connect(this, &ColorPicker::clicked, this, &ColorPicker::openColorDialog); 9 | } 10 | 11 | void ColorPicker::setColor(QColor color) 12 | { 13 | if (color != mColor) { 14 | mColor = color; 15 | setStyleSheet( 16 | "QToolButton { background: " + color.name(QColor::HexRgb) + "}"); 17 | Q_EMIT colorChanged(color); 18 | } 19 | } 20 | 21 | void ColorPicker::openColorDialog() 22 | { 23 | auto prevColor = mColor; 24 | QColorDialog dialog(mColor, this); 25 | connect(&dialog, &QColorDialog::currentColorChanged, this, 26 | &ColorPicker::setColor); 27 | dialog.setOption(QColorDialog::ShowAlphaChannel); 28 | dialog.setCurrentColor(mColor); 29 | setColor(dialog.exec() == QDialog::Accepted ? dialog.selectedColor() 30 | : prevColor); 31 | } 32 | -------------------------------------------------------------------------------- /src/session/ColorPicker.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ColorPicker final : public QToolButton 6 | { 7 | Q_OBJECT 8 | Q_PROPERTY( 9 | QColor color READ color WRITE setColor NOTIFY colorChanged USER true) 10 | public: 11 | explicit ColorPicker(QWidget *parent = nullptr); 12 | QColor color() const { return mColor; } 13 | void setColor(QColor color); 14 | 15 | Q_SIGNALS: 16 | void colorChanged(QColor color); 17 | 18 | private: 19 | void openColorDialog(); 20 | 21 | QColor mColor{ Qt::white }; 22 | }; 23 | -------------------------------------------------------------------------------- /src/session/DataComboBox.cpp: -------------------------------------------------------------------------------- 1 | #include "DataComboBox.h" 2 | 3 | DataComboBox::DataComboBox(QWidget *parent) : QComboBox(parent) 4 | { 5 | connect(this, qOverload(&QComboBox::currentIndexChanged), 6 | [this]() { Q_EMIT currentDataChanged(currentData()); }); 7 | } 8 | 9 | void DataComboBox::setCurrentData(QVariant data) 10 | { 11 | auto index = findData(data); 12 | if (index >= 0) 13 | setCurrentIndex(index); 14 | } 15 | 16 | QSize DataComboBox::minimumSizeHint() const 17 | { 18 | return QSize(50, QComboBox::minimumSizeHint().height()); 19 | } 20 | -------------------------------------------------------------------------------- /src/session/DataComboBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class DataComboBox final : public QComboBox 6 | { 7 | Q_OBJECT 8 | Q_PROPERTY(QVariant currentData READ currentData WRITE setCurrentData NOTIFY 9 | currentDataChanged USER true) 10 | public: 11 | explicit DataComboBox(QWidget *parent = nullptr); 12 | void setCurrentData(QVariant data); 13 | 14 | QSize minimumSizeHint() const override; 15 | 16 | Q_SIGNALS: 17 | void currentDataChanged(QVariant data); 18 | }; 19 | -------------------------------------------------------------------------------- /src/session/ExpressionEditor.cpp: -------------------------------------------------------------------------------- 1 | #include "ExpressionEditor.h" 2 | #include 3 | 4 | extern QString simpleDoubleString(double value); 5 | 6 | ExpressionEditor::ExpressionEditor(QWidget *parent) : QPlainTextEdit(parent) 7 | { 8 | setTabChangesFocus(true); 9 | } 10 | 11 | void ExpressionEditor::wheelEvent(QWheelEvent *event) 12 | { 13 | mWheelDeltaRemainder += event->angleDelta().y(); 14 | const int steps = mWheelDeltaRemainder / 120; 15 | mWheelDeltaRemainder -= steps * 120; 16 | stepBy(event->modifiers() & Qt::ShiftModifier ? steps / 10.0 17 | : event->modifiers() & Qt::ControlModifier ? steps * 10.0 18 | : steps); 19 | event->accept(); 20 | } 21 | 22 | void ExpressionEditor::stepBy(double steps) 23 | { 24 | const auto singleStep = 0.1; 25 | auto ok = false; 26 | auto value = toPlainText().toDouble(&ok); 27 | if (ok) { 28 | value += steps * singleStep; 29 | setText(simpleDoubleString(value)); 30 | selectAll(); 31 | } 32 | } 33 | 34 | void ExpressionEditor::setText(const QString &text) 35 | { 36 | if (text != toPlainText()) 37 | setPlainText(text); 38 | } 39 | 40 | QString ExpressionEditor::text() const 41 | { 42 | return toPlainText(); 43 | } 44 | -------------------------------------------------------------------------------- /src/session/ExpressionEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ExpressionEditor final : public QPlainTextEdit 6 | { 7 | Q_OBJECT 8 | Q_PROPERTY( 9 | QString text READ text WRITE setText NOTIFY textChanged USER true) 10 | public: 11 | explicit ExpressionEditor(QWidget *parent = nullptr); 12 | 13 | void setText(const QString &text); 14 | QString text() const; 15 | 16 | using QAbstractScrollArea::setViewportMargins; 17 | 18 | protected: 19 | void wheelEvent(QWheelEvent *event) override; 20 | 21 | private: 22 | void stepBy(double steps); 23 | 24 | int mWheelDeltaRemainder{}; 25 | }; 26 | -------------------------------------------------------------------------------- /src/session/ExpressionLineEdit.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ExpressionLineEdit final : public QLineEdit 6 | { 7 | Q_OBJECT 8 | Q_PROPERTY( 9 | QString text READ text WRITE setText NOTIFY textChanged USER true) 10 | public: 11 | explicit ExpressionLineEdit(QWidget *parent = nullptr); 12 | 13 | void setValue(double value); 14 | void setText(const QString &text); 15 | QString text() const; 16 | bool hasValue(double value) const; 17 | 18 | bool decimal() const { return mDecimal; } 19 | void setDecimal(bool decimal) { mDecimal = decimal; } 20 | 21 | Q_SIGNALS: 22 | // overridden so base class does not emit 23 | void textChanged(const QString &); 24 | 25 | protected: 26 | void wheelEvent(QWheelEvent *event) override; 27 | 28 | private: 29 | void stepBy(int steps); 30 | void stepBy(double steps); 31 | 32 | int mWheelDeltaRemainder{}; 33 | bool mDecimal{}; 34 | }; 35 | -------------------------------------------------------------------------------- /src/session/ExpressionMatrix.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ExpressionMatrix final : public QTableWidget 6 | { 7 | Q_OBJECT 8 | public: 9 | explicit ExpressionMatrix(QWidget *parent = nullptr); 10 | 11 | void setRowCount(int rows); 12 | void setColumnCount(int columns); 13 | void setValues(QStringList values); 14 | QStringList values() const; 15 | 16 | protected: 17 | void resizeEvent(QResizeEvent *event) override; 18 | void focusInEvent(QFocusEvent *event) override; 19 | 20 | private: 21 | void updateCells(); 22 | }; 23 | -------------------------------------------------------------------------------- /src/session/ReferenceComboBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class ReferenceComboBox final : public QComboBox 6 | { 7 | Q_OBJECT 8 | Q_PROPERTY(QVariant currentData READ currentData WRITE setCurrentData NOTIFY 9 | currentDataChanged USER true) 10 | public: 11 | explicit ReferenceComboBox(QWidget *parent = nullptr); 12 | void setCurrentData(QVariant data); 13 | void validate(); 14 | 15 | QSize minimumSizeHint() const override; 16 | void showPopup() override; 17 | void showEvent(QShowEvent *event) override; 18 | 19 | Q_SIGNALS: 20 | QVariantList listRequired(); 21 | QString textRequired(QVariant data); 22 | void currentDataChanged(QVariant data); 23 | 24 | protected: 25 | void paintEvent(QPaintEvent *event) override; 26 | 27 | private: 28 | void refreshList(); 29 | void insertItem(int index, QVariant data); 30 | 31 | bool mSuspendDataChangedSignal{}; 32 | }; 33 | -------------------------------------------------------------------------------- /src/session/SessionProperties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | #include 5 | #include 6 | 7 | namespace Ui { 8 | class SessionProperties; 9 | } 10 | 11 | class QDataWidgetMapper; 12 | class PropertiesEditor; 13 | 14 | class SessionProperties final : public QWidget 15 | { 16 | Q_OBJECT 17 | public: 18 | explicit SessionProperties(PropertiesEditor *propertiesEditor); 19 | ~SessionProperties(); 20 | 21 | void addMappings(QDataWidgetMapper &mapper); 22 | 23 | private: 24 | void updateWidgets(); 25 | 26 | PropertiesEditor &mPropertiesEditor; 27 | Ui::SessionProperties *mUi; 28 | }; 29 | -------------------------------------------------------------------------------- /src/session/TextureProperties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Item.h" 4 | #include 5 | 6 | namespace Ui { 7 | class TextureProperties; 8 | } 9 | 10 | class PropertiesEditor; 11 | class QDataWidgetMapper; 12 | 13 | class TextureProperties final : public QWidget 14 | { 15 | Q_OBJECT 16 | Q_PROPERTY(QVariant format READ format WRITE setFormat NOTIFY formatChanged 17 | USER true) 18 | public: 19 | explicit TextureProperties(PropertiesEditor *propertiesEditor); 20 | ~TextureProperties(); 21 | 22 | QVariant format() const { return static_cast(mFormat); } 23 | void setFormat(QVariant format); 24 | void addMappings(QDataWidgetMapper &mapper); 25 | TextureKind currentTextureKind() const; 26 | bool hasFile() const; 27 | 28 | Q_SIGNALS: 29 | void formatChanged(); 30 | 31 | private: 32 | void updateWidgets(); 33 | void updateFormatDataWidget(QVariant formatType); 34 | void updateFormat(QVariant formatData); 35 | void applyFileFormat(); 36 | 37 | PropertiesEditor &mPropertiesEditor; 38 | Ui::TextureProperties *mUi; 39 | Texture::Format mFormat{}; 40 | bool mSuspendUpdateFormat{}; 41 | }; 42 | -------------------------------------------------------------------------------- /src/version.h.in: -------------------------------------------------------------------------------- 1 | "${VERSION}" 2 | -------------------------------------------------------------------------------- /src/windows/AboutDialog.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class AboutDialog : public QDialog 6 | { 7 | public: 8 | AboutDialog(QWidget *parent); 9 | }; 10 | -------------------------------------------------------------------------------- /src/windows/AutoOrientationSplitter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class AutoOrientationSplitter final : public QSplitter 6 | { 7 | Q_OBJECT 8 | public: 9 | AutoOrientationSplitter(QWidget *parent) : QSplitter(parent) 10 | { 11 | setFrameShape(QFrame::StyledPanel); 12 | setChildrenCollapsible(false); 13 | } 14 | 15 | void resizeEvent(QResizeEvent *event) override 16 | { 17 | setOrientation(2 * width() > 3 * height() ? Qt::Horizontal 18 | : Qt::Vertical); 19 | 20 | const auto vertical = (orientation() == Qt::Vertical); 21 | setStretchFactor(vertical ? 1 : 0, 0); 22 | setStretchFactor(vertical ? 0 : 1, 100); 23 | 24 | QSplitter::resizeEvent(event); 25 | } 26 | }; 27 | -------------------------------------------------------------------------------- /src/windows/FileBrowserWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class QFileSystemModel; 6 | class QTreeView; 7 | class QDir; 8 | class QModelIndex; 9 | class QComboBox; 10 | class QToolButton; 11 | class QStringListModel; 12 | 13 | class FileBrowserWindow final : public QFrame 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit FileBrowserWindow(QWidget *parent = nullptr); 19 | QWidget *titleBar() { return mTitleBar; } 20 | 21 | void setRootPath(const QString &path); 22 | void browseDirectory(); 23 | void showInFileManager(); 24 | 25 | private Q_SLOTS: 26 | void itemActivated(const QModelIndex &index); 27 | void currentDirectoryChanged(const QDir &dir); 28 | 29 | Q_SIGNALS: 30 | void fileActivated(const QString &filename); 31 | 32 | private: 33 | bool revealDirectory(const QDir &dir); 34 | void focusDirectory(const QDir &dir); 35 | void updateRecentDirectories(const QString &path); 36 | QString completeToRecentDirectory(const QString &path); 37 | 38 | QWidget *mTitleBar{}; 39 | QFileSystemModel *mModel{}; 40 | QTreeView *mFileSystemTree{}; 41 | QComboBox *mRootDirectory{}; 42 | QToolButton *mBrowseButton{}; 43 | QToolButton *mShowInFileManagerButton{}; 44 | QStringListModel *mRecentDirectories{}; 45 | }; 46 | -------------------------------------------------------------------------------- /src/windows/MessageWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "MessageList.h" 4 | #include 5 | #include 6 | 7 | class QTimer; 8 | 9 | class MessageWindow final : public QTableWidget 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit MessageWindow(QWidget *parent = nullptr); 15 | 16 | Q_SIGNALS: 17 | void messageActivated(int itemId, QString fileName, int line, int column); 18 | void messagesAdded(); 19 | 20 | private: 21 | void updateMessages(); 22 | void handleItemActivated(QTableWidgetItem *item); 23 | QIcon getMessageIcon(const Message &message) const; 24 | QString getMessageText(const Message &message) const; 25 | QString getLocationText(const Message &message) const; 26 | void removeMessagesExcept(const QSet &messageIds); 27 | bool addMessageOnce(const Message &message); 28 | 29 | QTimer *mUpdateItemsTimer; 30 | QIcon mInfoIcon; 31 | QIcon mWarningIcon; 32 | QIcon mErrorIcon; 33 | QList mMessageIds; 34 | }; 35 | -------------------------------------------------------------------------------- /src/windows/OutputWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class QPlainTextEdit; 6 | class DataComboBox; 7 | class Theme; 8 | 9 | class OutputWindow final : public QFrame 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit OutputWindow(QWidget *parent = nullptr); 15 | QWidget *titleBar() const { return mTitleBar; } 16 | 17 | QString selectedType() const; 18 | void setText(QString text); 19 | 20 | Q_SIGNALS: 21 | void typeSelectionChanged(QString type); 22 | 23 | private: 24 | void handleThemeChanged(const Theme &theme); 25 | 26 | QWidget *mTitleBar{}; 27 | DataComboBox *mTypeSelector{}; 28 | QPlainTextEdit *mTextEdit{}; 29 | int mLastScrollPosVertical{}; 30 | }; 31 | -------------------------------------------------------------------------------- /src/windows/WindowTitle.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class QDockWidget; 6 | class QAbstractButton; 7 | class QLabel; 8 | 9 | class WindowTitle : public QFrame 10 | { 11 | Q_OBJECT 12 | 13 | public: 14 | explicit WindowTitle(QWidget *parent = nullptr); 15 | 16 | void setWidget(QWidget *widget); 17 | QWidget *widget() const { return mWidget; } 18 | 19 | protected: 20 | bool event(QEvent *event) override; 21 | 22 | private: 23 | void parentChanged(QWidget *parent); 24 | 25 | QLabel *mTitle{}; 26 | QAbstractButton *mCloseButton{}; 27 | QWidget *mWidget{}; 28 | }; 29 | --------------------------------------------------------------------------------
13 | A lightweight editor for GLSL shaders of all kinds and a fully-featured IDE for developing GPU based algorithms. 14 |