Mercurial > games > semicongine
comparison test1.nim @ 1192:90bf0cab1d02 compiletime-tests
did: so many, many things
author | sam <sam@basx.dev> |
---|---|
date | Mon, 08 Jul 2024 16:05:06 +0700 |
parents | 239adab121a3 |
children | 5aa1184fa5eb |
comparison
equal
deleted
inserted
replaced
1191:239adab121a3 | 1192:90bf0cab1d02 |
---|---|
38 uniforms: DescriptorSet[UniformsA, MaterialSet] | 38 uniforms: DescriptorSet[UniformsA, MaterialSet] |
39 # code | 39 # code |
40 vertexCode: string = "void main() {}" | 40 vertexCode: string = "void main() {}" |
41 fragmentCode: string = "void main() {}" | 41 fragmentCode: string = "void main() {}" |
42 | 42 |
43 let w = CreateWindow("test2") | |
44 putEnv("VK_LAYER_ENABLES", "VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_AMD,VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_NVIDIA,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXTVK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT") | 43 putEnv("VK_LAYER_ENABLES", "VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_AMD,VALIDATION_CHECK_ENABLE_VENDOR_SPECIFIC_NVIDIA,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXTVK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT,VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT") |
45 | 44 |
46 # TODO: remove those ugly wrappers | |
47 let theInstance = w.CreateInstance( | |
48 vulkanVersion = VK_MAKE_API_VERSION(0, 1, 3, 0), | |
49 instanceExtensions = @[], | |
50 layers = @["VK_LAYER_KHRONOS_validation"], | |
51 ) | |
52 | |
53 let dev = theInstance.CreateDevice( | |
54 theInstance.GetPhysicalDevices().FilterBestGraphics(), | |
55 enabledExtensions = @[], | |
56 theInstance.GetPhysicalDevices().FilterBestGraphics().FilterForGraphicsPresentationQueues() | |
57 ).vk | |
58 let frameWidth = 100'u32 | 45 let frameWidth = 100'u32 |
59 let frameHeight = 100'u32 | 46 let frameHeight = 100'u32 |
60 | |
61 # TODO: pack this stuff into a setup method and condense everything a bit | |
62 let pDevice = theInstance.vk.GetPhysicalDevice() | |
63 let qfi = pDevice.GetQueueFamily(VK_QUEUE_GRAPHICS_BIT) | |
64 vulkan = VulkanGlobals( | |
65 instance: theInstance.vk, | |
66 device: dev, | |
67 physicalDevice: pDevice, | |
68 queueFamilyIndex: qfi, | |
69 queue: svkGetDeviceQueue(dev, qfi, VK_QUEUE_GRAPHICS_BIT) | |
70 ) | |
71 | 47 |
72 var myMesh1 = MeshA( | 48 var myMesh1 = MeshA( |
73 position: GPUArray[Vec3f, VertexBuffer](data: @[NewVec3f(0, 0, ), NewVec3f(0, 0, ), NewVec3f(0, 0, )]), | 49 position: GPUArray[Vec3f, VertexBuffer](data: @[NewVec3f(0, 0, ), NewVec3f(0, 0, ), NewVec3f(0, 0, )]), |
74 ) | 50 ) |
75 var uniforms1 = DescriptorSet[UniformsA, MaterialSet]( | 51 var uniforms1 = DescriptorSet[UniformsA, MaterialSet]( |
96 fontAtlas: Texture[TVec4[uint8]](width: 1, height: 1, data: @[TVec4[uint8]([0'u8, 0'u8, 0'u8, 1'u8])]), | 72 fontAtlas: Texture[TVec4[uint8]](width: 1, height: 1, data: @[TVec4[uint8]([0'u8, 0'u8, 0'u8, 1'u8])]), |
97 settings: GPUValue[ShaderSettings, UniformBuffer](data: ShaderSettings(gamma: 1.0)) | 73 settings: GPUValue[ShaderSettings, UniformBuffer](data: ShaderSettings(gamma: 1.0)) |
98 ) | 74 ) |
99 ) | 75 ) |
100 | 76 |
101 # setup for rendering (TODO: swapchain & framebuffers) | 77 let renderpass = CreatePresentationRenderPass() |
102 let renderpass = CreateRenderPass(GetSurfaceFormat()) | |
103 | 78 |
104 # shaders | 79 # shaders |
105 const shader = ShaderA() | 80 var pipeline1 = CreatePipeline[ShaderA](renderPass = renderpass) |
106 let shaderObject = CompileShader(shader) | |
107 var pipeline1 = CreatePipeline(renderPass = renderpass, shader = shaderObject) | |
108 | 81 |
109 var renderdata = InitRenderData() | 82 var renderdata = InitRenderData() |
110 | 83 |
111 # buffer assignment | 84 # buffer assignment |
112 echo "Assigning buffers to GPUData fields" | 85 echo "Assigning buffers to GPUData fields" |
128 renderdata.FlushAllMemory() | 101 renderdata.FlushAllMemory() |
129 | 102 |
130 | 103 |
131 # descriptors | 104 # descriptors |
132 echo "Writing descriptors" | 105 echo "Writing descriptors" |
133 InitDescriptorSet(renderdata, pipeline1.descriptorSetLayouts[GlobalSet], myGlobals) | 106 InitDescriptorSet(renderdata, pipeline1.GetLayoutFor(GlobalSet), myGlobals) |
134 InitDescriptorSet(renderdata, pipeline1.descriptorSetLayouts[MaterialSet], uniforms1) | 107 InitDescriptorSet(renderdata, pipeline1.GetLayoutFor(MaterialSet), uniforms1) |
135 | 108 |
136 | 109 |
137 # command buffer | 110 # command buffer |
138 var | 111 var |
139 commandBufferPool: VkCommandPool | 112 commandBufferPool: VkCommandPool |