comparison tests/test_vulkan_wrapper.nim @ 321:30117d8f0052

did next step in renderpipeline-refactoring, using shaderconfiguration objects instead for less ambigious shader-pipeline configuration
author Sam <sam@basx.dev>
date Tue, 15 Aug 2023 23:51:37 +0700
parents b145a05c2459
children 6dab370d1758
comparison
equal deleted inserted replaced
320:89800309ab09 321:30117d8f0052
83 proc main() = 83 proc main() =
84 var engine = initEngine("Test") 84 var engine = initEngine("Test")
85 85
86 # INIT RENDERER: 86 # INIT RENDERER:
87 const 87 const
88 vertexInput = @[ 88 shaderConfiguration = createShaderConfiguration(
89 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead), 89 inputs=[
90 attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite), 90 attr[Vec3f]("position", memoryPerformanceHint=PreferFastRead),
91 attr[Vec3f]("translate", perInstance=true) 91 attr[Vec4f]("color", memoryPerformanceHint=PreferFastWrite),
92 ] 92 attr[Vec3f]("translate", perInstance=true)
93 intermediate = @[attr[Vec4f]("outcolor")] 93 ],
94 fragOutput = @[attr[Vec4f]("color")] 94 intermediates=[attr[Vec4f]("outcolor")],
95 samplers = @[attr[Sampler2DType]("my_little_texture")] 95 outputs=[attr[Vec4f]("color")],
96 uniforms = @[attr[float32]("time")] 96 uniforms=[attr[float32]("time")],
97 (vertexCode, fragmentCode) = compileVertexFragmentShaderSet( 97 samplers=[attr[Sampler2DType]("my_little_texture")],
98 inputs=vertexInput,
99 intermediate=intermediate,
100 outputs=fragOutput,
101 samplers=samplers,
102 uniforms=uniforms,
103 vertexCode="""gl_Position = vec4(position + translate, 1.0); outcolor = color;""", 98 vertexCode="""gl_Position = vec4(position + translate, 1.0); outcolor = color;""",
104 fragmentCode="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;", 99 fragmentCode="color = texture(my_little_texture, outcolor.xy) * 0.5 + outcolor * 0.5;",
105 ) 100 )
106 var renderPass = engine.gpuDevice.simpleForwardRenderPass(vertexCode, fragmentCode) 101 var renderPass = engine.gpuDevice.simpleForwardRenderPass(shaderConfiguration)
107 engine.setRenderer(renderPass) 102 engine.setRenderer(renderPass)
108 103
109 # INIT SCENES 104 # INIT SCENES
110 var scenes = [ 105 var scenes = [
111 newScene("simple", scene_simple()), 106 newScene("simple", scene_simple()),