Rework API graphique Vulkan - EnTT pour ECS + Chargement modèle 3D assimp + SDL3 pour events input et fenetre + mesh texture camera transform ok + attention tous les assets nouveaus ne sont pas commités et il y a du code test en dur dans scene addentity + restructuration globale

This commit is contained in:
Tom Ray
2026-03-14 20:24:17 +01:00
parent 7c352bc280
commit 6695d46bcd
672 changed files with 238656 additions and 1821 deletions

View File

@@ -0,0 +1,44 @@
#version 450
layout (set = 0, binding = 1) uniform Ubo {
vec4 data;
} ubo;
layout (location = 1) in vec3 pos;
layout (location = 0) in vec2 iUV;
layout (location = 0) out vec2 oUV;
layout (push_constant) uniform PushConstantVert {
float val;
} push_constant_vert;
out gl_PerVertex {
vec4 gl_Position;
};
vec4 getData() {
return ubo.data;
}
void entry_vert() {
oUV = iUV;
gl_Position = vec4(pos, 1.0) * push_constant_vert.val * getData();
}
layout (set = 0, binding = 0) uniform sampler2D tex;
layout (location = 1) out vec4 colour;
/*
layout (push_constant) uniform PushConstantFrag {
float val;
} push_constant_frag;
*/
void entry_frag() {
colour = texture(tex, iUV) * push_constant_vert.val * getData();
}
void main() {
entry_vert();
entry_frag();
}

View File

@@ -0,0 +1,121 @@
; SPIR-V
; Version: 1.0
; Generator: Google Shaderc over Glslang; 6
; Bound: 70
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %entry_vert_ "entry_vert" %_ %iUV %oUV %pos
OpEntryPoint Fragment %entry_frag_ "entry_frag" %iUV %colour
OpSource GLSL 450
OpSourceExtension "GL_GOOGLE_cpp_style_line_directive"
OpSourceExtension "GL_GOOGLE_include_directive"
OpName %getData_ "getData("
OpName %entry_vert_ "entry_vert("
OpName %entry_frag_ "entry_frag("
OpName %Ubo "Ubo"
OpMemberName %Ubo 0 "data"
OpName %ubo "ubo"
OpName %oUV "oUV"
OpName %iUV "iUV"
OpName %gl_PerVertex "gl_PerVertex"
OpMemberName %gl_PerVertex 0 "gl_Position"
OpName %_ ""
OpName %pos "pos"
OpName %PushConstantVert "PushConstantVert"
OpMemberName %PushConstantVert 0 "val"
OpName %push_constant_vert "push_constant_vert"
OpName %PushConstantFrag "PushConstantFrag"
OpMemberName %PushConstantFrag 0 "val"
OpName %push_constant_frag "push_constant_frag"
OpName %colour "colour"
OpName %tex "tex"
OpMemberDecorate %Ubo 0 Offset 0
OpDecorate %Ubo Block
OpDecorate %ubo DescriptorSet 0
OpDecorate %ubo Binding 1
OpDecorate %oUV Location 0
OpDecorate %iUV Location 0
OpMemberDecorate %gl_PerVertex 0 BuiltIn Position
OpDecorate %gl_PerVertex Block
OpDecorate %pos Location 1
OpMemberDecorate %PushConstantVert 0 Offset 0
OpDecorate %PushConstantVert Block
OpDecorate %colour Location 0
OpDecorate %tex DescriptorSet 0
OpDecorate %tex Binding 0
%void = OpTypeVoid
%3 = OpTypeFunction %void
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%8 = OpTypeFunction %v4float
%Ubo = OpTypeStruct %v4float
%_ptr_Uniform_Ubo = OpTypePointer Uniform %Ubo
%ubo = OpVariable %_ptr_Uniform_Ubo Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%v2float = OpTypeVector %float 2
%_ptr_Output_v2float = OpTypePointer Output %v2float
%oUV = OpVariable %_ptr_Output_v2float Output
%_ptr_Input_v2float = OpTypePointer Input %v2float
%iUV = OpVariable %_ptr_Input_v2float Input
%gl_PerVertex = OpTypeStruct %v4float
%_ptr_Output_gl_PerVertex = OpTypePointer Output %gl_PerVertex
%_ = OpVariable %_ptr_Output_gl_PerVertex Output
%v3float = OpTypeVector %float 3
%_ptr_Input_v3float = OpTypePointer Input %v3float
%pos = OpVariable %_ptr_Input_v3float Input
%float_1 = OpConstant %float 1
%PushConstantVert = OpTypeStruct %float
%_ptr_PushConstant_PushConstantVert = OpTypePointer PushConstant %PushConstantVert
%push_constant_vert = OpVariable %_ptr_PushConstant_PushConstantVert PushConstant
%PushConstantFrag = OpTypeStruct %float
%_ptr_PushConstant_PushConstantFrag = OpTypePointer PushConstant %PushConstantFrag
%push_constant_frag = OpVariable %_ptr_PushConstant_PushConstantFrag PushConstant
%_ptr_PushConstant_float = OpTypePointer PushConstant %float
%_ptr_Output_v4float = OpTypePointer Output %v4float
%colour = OpVariable %_ptr_Output_v4float Output
%55 = OpTypeImage %float 2D 0 0 0 1 Unknown
%56 = OpTypeSampledImage %55
%_ptr_UniformConstant_56 = OpTypePointer UniformConstant %56
%tex = OpVariable %_ptr_UniformConstant_56 UniformConstant
%float_0 = OpConstant %float 0
%getData_ = OpFunction %v4float None %8
%10 = OpLabel
%21 = OpAccessChain %_ptr_Uniform_v4float %ubo %int_0
%22 = OpLoad %v4float %21
OpReturnValue %22
OpFunctionEnd
%entry_vert_ = OpFunction %void None %3
%12 = OpLabel
%30 = OpLoad %v2float %iUV
OpStore %oUV %30
%37 = OpLoad %v3float %pos
%39 = OpCompositeExtract %float %37 0
%40 = OpCompositeExtract %float %37 1
%41 = OpCompositeExtract %float %37 2
%42 = OpCompositeConstruct %v4float %39 %40 %41 %float_1
%47 = OpAccessChain %_ptr_PushConstant_float %push_constant_vert %int_0
%48 = OpLoad %float %47
%49 = OpVectorTimesScalar %v4float %42 %48
%50 = OpFunctionCall %v4float %getData_
%51 = OpFMul %v4float %49 %50
%53 = OpAccessChain %_ptr_Output_v4float %_ %int_0
OpStore %53 %51
OpReturn
OpFunctionEnd
%entry_frag_ = OpFunction %void None %3
%14 = OpLabel
%59 = OpLoad %56 %tex
%60 = OpLoad %v2float %iUV
%62 = OpImageSampleExplicitLod %v4float %59 %60 Lod %float_0
%63 = OpAccessChain %_ptr_PushConstant_float %push_constant_frag %int_0
%64 = OpLoad %float %63
%65 = OpVectorTimesScalar %v4float %62 %64
%66 = OpFunctionCall %v4float %getData_
%67 = OpFMul %v4float %65 %66
OpStore %colour %67
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,30 @@
9c9,10
< OpEntryPoint Vertex %main "main" %oUV %iUV %_ %pos %colour
---
> OpEntryPoint Vertex %entry_vert_ "entry_vert" %_ %iUV %oUV %pos
> OpEntryPoint Fragment %entry_frag_ "entry_frag" %iUV %colour
13d13
< OpName %main "main"
28a29,31
> OpName %PushConstantFrag "PushConstantFrag"
> OpMemberName %PushConstantFrag 0 "val"
> OpName %push_constant_frag "push_constant_frag"
42c45
< OpDecorate %colour Location 1
---
> OpDecorate %colour Location 0
70a74,76
> %PushConstantFrag = OpTypeStruct %float
> %_ptr_PushConstant_PushConstantFrag = OpTypePointer PushConstant %PushConstantFrag
> %push_constant_frag = OpVariable %_ptr_PushConstant_PushConstantFrag PushConstant
79,84d84
< %main = OpFunction %void None %3
< %5 = OpLabel
< %68 = OpFunctionCall %void %entry_vert_
< %69 = OpFunctionCall %void %entry_frag_
< OpReturn
< OpFunctionEnd
114c114
< %63 = OpAccessChain %_ptr_PushConstant_float %push_constant_vert %int_0
---
> %63 = OpAccessChain %_ptr_PushConstant_float %push_constant_frag %int_0

View File

@@ -0,0 +1,471 @@
%YAML 1.1
---
all_type_descriptions:
- &td0
id: 39
op: 27
type_name:
struct_member_name:
storage_class: -1 # NOT APPLICABLE
type_flags: 0x00050008 # EXTERNAL_SAMPLED_IMAGE EXTERNAL_IMAGE FLOAT
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 1, depth: 0, arrayed: 0, ms: 0, sampled: 1, image_format: 0 } # dim=2D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
- &td1
id: 21
op: 23
type_name:
struct_member_name: "data"
storage_class: 0 # UniformConstant
type_flags: 0x00000108 # VECTOR FLOAT
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 4 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
- &td2
id: 10
op: 30
type_name: "Ubo"
struct_member_name:
storage_class: -1 # NOT APPLICABLE
type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK
decoration_flags: 0x00000001 # BLOCK
traits:
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 1
members:
- *td1
- &td3
id: 20
op: 22
type_name:
struct_member_name: "val"
storage_class: 0 # UniformConstant
type_flags: 0x00000008 # FLOAT
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
- &td4
id: 13
op: 30
type_name: "PushConstantVert"
struct_member_name:
storage_class: -1 # NOT APPLICABLE
type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK
decoration_flags: 0x00000001 # BLOCK
traits:
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 1
members:
- *td3
- &td5
id: 20
op: 22
type_name:
struct_member_name: "val"
storage_class: 0 # UniformConstant
type_flags: 0x00000008 # FLOAT
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
- &td6
id: 15
op: 30
type_name: "PushConstantFrag"
struct_member_name:
storage_class: -1 # NOT APPLICABLE
type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 1
members:
- *td5
- &td7
id: 27
op: 23
type_name:
struct_member_name:
storage_class: -1 # NOT APPLICABLE
type_flags: 0x00000108 # VECTOR FLOAT
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 2 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
- &td8
id: 31
op: 23
type_name:
struct_member_name:
storage_class: -1 # NOT APPLICABLE
type_flags: 0x00000108 # VECTOR FLOAT
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 3 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
- &td9
id: 21
op: 23
type_name:
struct_member_name: "gl_Position"
storage_class: 0 # UniformConstant
type_flags: 0x00000108 # VECTOR FLOAT
decoration_flags: 0x00000000 # NONE
traits:
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 4 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
- &td10
id: 12
op: 30
type_name: "gl_PerVertex"
struct_member_name:
storage_class: -1 # NOT APPLICABLE
type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK
decoration_flags: 0x00000001 # BLOCK
traits:
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 1
members:
- *td9
all_block_variables:
- &bv0
name:
offset: 0
absolute_offset: 0
size: 0
padded_size: 0
decorations: 0x00000000 # NONE
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 0
members:
type_description:
- &bv1
name: "data"
offset: 0
absolute_offset: 0
size: 16
padded_size: 16
decorations: 0x00000000 # NONE
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 4 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 0
members:
type_description: *td1
- &bv2
name: "ubo"
offset: 0
absolute_offset: 0
size: 16
padded_size: 16
decorations: 0x00000000 # NONE
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 1
members:
- *bv1
type_description: *td2
- &bv3
name: "val"
offset: 0
absolute_offset: 0
size: 4
padded_size: 4
decorations: 0x00000000 # NONE
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 0
members:
type_description: *td3
- &bv4
name: "push_constant_vert"
offset: 0
absolute_offset: 0
size: 4
padded_size: 4
decorations: 0x00000000 # NONE
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 1
members:
- *bv3
type_description: *td4
- &bv5
name: "val"
offset: 0
absolute_offset: 0
size: 4
padded_size: 4
decorations: 0x00000000 # NONE
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 0
members:
type_description: *td5
- &bv6
name: "push_constant_frag"
offset: 0
absolute_offset: 0
size: 4
padded_size: 4
decorations: 0x00000000 # NONE
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
flags: 0x00000000 # NONE
member_count: 1
members:
- *bv5
type_description: *td6
all_descriptor_bindings:
- &db0
spirv_id: 17
name: "tex"
binding: 0
input_attachment_index: 0
set: 0
decoration_flags: 0x00000000 # NONE
descriptor_type: 1 # VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER
resource_type: 5 # ???
image: { dim: 1, depth: 0, arrayed: 0, ms: 0, sampled: 1, image_format: 0 } # dim=2D image_format=Unknown
block: *bv0 #
array: { dims_count: 0, dims: [] }
accessed: 1
uav_counter_id: 4294967295
uav_counter_binding:
type_description: *td0
word_offset: { binding: 203, set: 199 }
- &db1
spirv_id: 11
name: "ubo"
binding: 1
input_attachment_index: 0
set: 0
decoration_flags: 0x00000000 # NONE
descriptor_type: 6 # VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
resource_type: 2 # CBV
image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown
block: *bv2 # "ubo"
array: { dims_count: 0, dims: [] }
accessed: 1
uav_counter_id: 4294967295
uav_counter_binding:
type_description: *td2
word_offset: { binding: 163, set: 159 }
all_interface_variables:
- &iv0
spirv_id: 4
name: "iUV"
location: 0
storage_class: 1 # Input
semantic:
decoration_flags: 0x00000000 # NONE
built_in: -1 # ??? (-1)
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 2 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
format: 103 # VK_FORMAT_R32G32_SFLOAT
type_description: *td7
word_offset: { location: 171 }
- &iv1
spirv_id: 6
name: "pos"
location: 1
storage_class: 1 # Input
semantic:
decoration_flags: 0x00000000 # NONE
built_in: -1 # ??? (-1)
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 3 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
format: 106 # VK_FORMAT_R32G32B32_SFLOAT
type_description: *td8
word_offset: { location: 183 }
- &iv2
spirv_id: 0
name:
location: 0
storage_class: 3 # Output
semantic:
decoration_flags: 0x00000010 # BUILT_IN
built_in: 0 # Position
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 4 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
format: 109 # VK_FORMAT_R32G32B32A32_SFLOAT
type_description: *td9
word_offset: { location: 0 }
- &iv3
spirv_id: 3
name: ""
location: 4294967295
storage_class: 3 # Output
semantic:
decoration_flags: 0x00000011 # BUILT_IN BLOCK
built_in: 0 # [Position]
numeric:
scalar: { width: 0, signedness: 0 }
vector: { component_count: 0 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 1
members:
- *iv2 #
format: 0 # VK_FORMAT_UNDEFINED
type_description: *td10
word_offset: { location: 0 }
- &iv4
spirv_id: 5
name: "oUV"
location: 0
storage_class: 3 # Output
semantic:
decoration_flags: 0x00000000 # NONE
built_in: -1 # ??? (-1)
numeric:
scalar: { width: 32, signedness: 0 }
vector: { component_count: 2 }
matrix: { column_count: 0, row_count: 0, stride: 0 }
array: { dims_count: 0, dims: [], stride: 0 }
member_count: 0
members:
format: 103 # VK_FORMAT_R32G32_SFLOAT
type_description: *td7
word_offset: { location: 167 }
module:
generator: 7 # Khronos SPIR-V Tools Assembler
entry_point_name: "entry_vert"
entry_point_id: 2
source_language: 2 # GLSL
source_language_version: 450
spirv_execution_model: 0 # Vertex
shader_stage: 0x00000001 # VS
descriptor_binding_count: 2
descriptor_bindings:
- *db0 # "tex"
- *db1 # "ubo"
descriptor_set_count: 1
descriptor_sets:
- set: 0
binding_count: 2
bindings:
- *db0 # "tex"
- *db1 # "ubo"
input_variable_count: 2,
input_variables:
- *iv0 # "iUV"
- *iv1 # "pos"
output_variable_count: 2,
output_variables:
- *iv3 # ""
- *iv4 # "oUV"
push_constant_count: 2,
push_constants:
- *bv4 # "push_constant_vert"
- *bv6 # "push_constant_frag"
specialization_constant_count: 0,
specialization_constants:
...

View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Creates multi_entrypoint.spv from multi_entrypoint.glsl and
# multi_entrypoint.spv.dis.diff
glslc -fshader-stage=vert multi_entrypoint.glsl -o multi_entrypoint.spv
spirv-dis multi_entrypoint.spv > multi_entrypoint.spv.dis
patch multi_entrypoint.spv.dis multi_entrypoint.spv.dis.diff
spirv-as multi_entrypoint.spv.dis -o multi_entrypoint.spv