@@ -44,6 +44,11 @@ local pipelines = setmetatable({}, {
4444 __mode = " k" ,
4545})
4646
47+ --- @type table<gfx.gl.ComputePipeline , gfx.gl.RawComputePipeline>
48+ local computePipelines = setmetatable ({}, {
49+ __mode = " k" ,
50+ })
51+
4752--- @type table<gfx.IndexFormat , number>
4853local indexFormatToGL = {
4954 [gfx .IndexType .u16 ] = gl .UNSIGNED_SHORT ,
@@ -62,7 +67,17 @@ local compareFnsMap = {
6267 [gfx .CompareFunction .ALWAYS ] = gl .ALWAYS ,
6368}
6469
70+ --- @type table<gfx.StorageAccess , number>
71+ local accessMap = {
72+ [" READ_ONLY" ] = gl .READ_ONLY ,
73+ [" WRITE_ONLY" ] = gl .WRITE_ONLY ,
74+ [" READ_WRITE" ] = gl .READ_WRITE ,
75+ }
76+
6577function GLCommandBuffer :execute ()
78+ --- @type gfx.gl.ComputePipeline ?
79+ local computePipeline
80+
6681 --- @type gfx.gl.Pipeline ?
6782 local pipeline
6883
@@ -164,10 +179,26 @@ function GLCommandBuffer:execute()
164179 elseif entry .type == " sampler" then
165180 local sampler = entry .sampler --[[ @as gfx.gl.Sampler]]
166181 gl .bindSampler (entry .binding , sampler .id )
182+ elseif entry .type == " storageTexture" then
183+ -- TODO: Look into the format here
184+ local texture = entry .texture --[[ @as gfx.gl.Texture]]
185+ gl .bindImageTexture (entry .binding , texture .id , 0 , 1 , 0 , accessMap [entry .access ], gl .RGBA8 )
167186 end
168187 end
169188 elseif command .type == " drawIndexed" then
170189 gl .drawElements (gl .TRIANGLES , command .indexCount , indexType , nil )
190+ elseif command .type == " beginComputePass" then
191+ elseif command .type == " setComputePipeline" then
192+ computePipeline = command .pipeline
193+
194+ local rawComputePipeline = computePipelines [computePipeline ]
195+ if not rawComputePipeline then
196+ rawComputePipeline = computePipeline :genForCurrentContext ()
197+ computePipelines [computePipeline ] = rawComputePipeline
198+ end
199+ rawComputePipeline :bind ()
200+ elseif command .type == " dispatchWorkgroups" then
201+ gl .dispatchCompute (command .x , command .y , command .z )
171202 else
172203 print (" Unknown command type: " .. tostring (command .type ))
173204 end
0 commit comments