wip(0.S2): migrate - a var nothing writes becomes a let; a state is keyed by its module, directory or program, so every program's plan agrees; paths normalized; program states named SceneDemoState / scene_demo_st; the LSP reads state, mut and entry/handler parameters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
3eda72e8c2
commit
5ffe50ed02
463 changed files with 72045 additions and 67421 deletions
|
|
@ -29,10 +29,8 @@ program VkTriangle {
|
|||
}
|
||||
return false
|
||||
}
|
||||
state VktriangleState {
|
||||
spv_len: int = 0
|
||||
}
|
||||
unsafe function read_all(vktriangle_st: mut VktriangleState, path: string) -> bytes {
|
||||
var spv_len: int = 0
|
||||
unsafe function read_all(path: string) -> bytes {
|
||||
let f = file_open(path, "rb")
|
||||
if f == null { return null }
|
||||
file_seek(f, 0, 2)
|
||||
|
|
@ -41,7 +39,7 @@ program VkTriangle {
|
|||
let b = bytes(n + 4)
|
||||
file_read(f, b, n)
|
||||
file_close(f)
|
||||
vktriangle_st.spv_len = n
|
||||
spv_len = n
|
||||
return b
|
||||
}
|
||||
# the first memory type the resource allows that has every property wanted
|
||||
|
|
@ -74,13 +72,13 @@ program VkTriangle {
|
|||
color_range(b, VkImageMemoryBarrier_subresourceRange)
|
||||
vk_cmd_pipeline_barrier(cb, src_stage, dst_stage, 0, 0, null, 0, null, 1, b)
|
||||
}
|
||||
unsafe function shader_module(vktriangle_st: mut VktriangleState, dev: pointer, path: string) -> long {
|
||||
let spv = read_all(vktriangle_st, path)
|
||||
unsafe function shader_module(dev: pointer, path: string) -> long {
|
||||
let spv = read_all(path)
|
||||
if spv == null { print(`vulkan: no SPIR-V at {path} (compile vk_triangle.slang with slangc)`); quit() }
|
||||
let smci = bytes(VkShaderModuleCreateInfo_sizeof)
|
||||
vk_zero(smci, VkShaderModuleCreateInfo_sizeof)
|
||||
vk_put_i32(smci, VkShaderModuleCreateInfo_sType, VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO)
|
||||
let code_size: long = vktriangle_st.spv_len
|
||||
let code_size: long = spv_len
|
||||
vk_put_i64(smci, VkShaderModuleCreateInfo_codeSize, code_size)
|
||||
vk_put_ptr(smci, VkShaderModuleCreateInfo_pCode, spv)
|
||||
let out = bytes(8)
|
||||
|
|
@ -89,7 +87,7 @@ program VkTriangle {
|
|||
return handle(out)
|
||||
}
|
||||
|
||||
handler Boot(vktriangle_st: mut VktriangleState) phase Start {
|
||||
handler Boot phase Start {
|
||||
spawn Anchor {}
|
||||
var vs_path = "build/vk_triangle_vs.spv"
|
||||
var fs_path = "build/vk_triangle_fs.spv"
|
||||
|
|
@ -255,8 +253,8 @@ program VkTriangle {
|
|||
if r != VK_SUCCESS { fail("vkBindBufferMemory", r) }
|
||||
|
||||
# ---- the pipeline: two stages, no vertex input, dynamic viewport and scissor, one colour format
|
||||
let vs = shader_module(vktriangle_st, dev, vs_path)
|
||||
let fs = shader_module(vktriangle_st, dev, fs_path)
|
||||
let vs = shader_module(dev, vs_path)
|
||||
let fs = shader_module(dev, fs_path)
|
||||
let plci = bytes(VkPipelineLayoutCreateInfo_sizeof)
|
||||
vk_zero(plci, VkPipelineLayoutCreateInfo_sizeof)
|
||||
vk_put_i32(plci, VkPipelineLayoutCreateInfo_sType, VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue