From 9a982cc5b5ecc16371f6727f67adc0455ebd7620 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Fri, 21 Apr 2023 08:35:21 +0200 Subject: [PATCH 01/29] Fix #2471 --- core/net/dns.odin | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/net/dns.odin b/core/net/dns.odin index f5bf912bc..a0223e6ee 100644 --- a/core/net/dns.odin +++ b/core/net/dns.odin @@ -373,18 +373,20 @@ load_resolv_conf :: proc(resolv_conf_path: string, allocator := context.allocato defer delete(res) resolv_str := string(res) + id_str := "nameserver" + id_len := len(id_str) + _name_servers := make([dynamic]Endpoint, 0, allocator) for line in strings.split_lines_iterator(&resolv_str) { if len(line) == 0 || line[0] == '#' { continue } - id_str := "nameserver" - if strings.compare(line[:len(id_str)], id_str) != 0 { + if len(line) < id_len || strings.compare(line[:id_len], id_str) != 0 { continue } - server_ip_str := strings.trim_left_space(line[len(id_str):]) + server_ip_str := strings.trim_left_space(line[id_len:]) if len(server_ip_str) == 0 { continue } From a95b064d6d0a2e3dfa8c414be60ae966a099adfd Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 21 Apr 2023 13:29:38 +0100 Subject: [PATCH 02/29] Fix memory leak caused by awful realloc usage on Linux --- src/common_memory.cpp | 37 ++++++++++++++++++++++++++----------- src/ptr_map.cpp | 4 +++- src/string_map.cpp | 4 +++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/src/common_memory.cpp b/src/common_memory.cpp index f33fb0dff..d6a87529f 100644 --- a/src/common_memory.cpp +++ b/src/common_memory.cpp @@ -1,3 +1,4 @@ +#include gb_internal gb_inline void zero_size(void *ptr, isize len) { memset(ptr, 0, len); @@ -121,7 +122,6 @@ struct PlatformMemoryBlock { PlatformMemoryBlock *prev, *next; }; - gb_global std::atomic global_platform_memory_total_usage; gb_global PlatformMemoryBlock global_platform_memory_block_sentinel; @@ -177,12 +177,12 @@ gb_internal void platform_virtual_memory_protect(void *memory, isize size); gb_printf_err("Total Usage: %lld bytes\n", cast(long long)global_platform_memory_total_usage); GB_ASSERT_MSG(pmblock != nullptr, "Out of Virtual Memory, oh no..."); } - global_platform_memory_total_usage += total_size; + global_platform_memory_total_usage.fetch_add(total_size); return pmblock; } gb_internal void platform_virtual_memory_free(PlatformMemoryBlock *block) { isize size = block->total_size; - global_platform_memory_total_usage -= size; + global_platform_memory_total_usage.fetch_sub(size); munmap(block, size); } gb_internal void platform_virtual_memory_protect(void *memory, isize size) { @@ -396,6 +396,8 @@ gb_internal gbAllocator heap_allocator(void) { return a; } +gb_internal std::atomic total_heap_memory_allocated; + gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc) { void *ptr = nullptr; @@ -403,7 +405,6 @@ gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc) { gb_unused(old_size); - // TODO(bill): Throughly test! switch (type) { #if defined(GB_COMPILER_MSVC) @@ -436,28 +437,34 @@ gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc) { #elif defined(GB_SYSTEM_LINUX) // TODO(bill): *nix version that's decent case gbAllocation_Alloc: { - ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1)); + isize total_size = (size + alignment - 1) & ~(alignment - 1); + total_heap_memory_allocated.fetch_add(total_size); + ptr = aligned_alloc(alignment, total_size); gb_zero_size(ptr, size); } break; case gbAllocation_Free: if (old_memory != nullptr) { + total_heap_memory_allocated.fetch_sub(malloc_usable_size(old_memory)); free(old_memory); } break; - case gbAllocation_Resize: + case gbAllocation_Resize: { if (size == 0) { if (old_memory != nullptr) { + total_heap_memory_allocated.fetch_sub(malloc_usable_size(old_memory)); free(old_memory); } break; } - + alignment = gb_max(alignment, gb_align_of(max_align_t)); - + if (old_memory == nullptr) { - ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1)); + isize total_size = (size + alignment - 1) & ~(alignment - 1); + total_heap_memory_allocated.fetch_add(total_size); + ptr = aligned_alloc(alignment, total_size); gb_zero_size(ptr, size); break; } @@ -466,11 +473,19 @@ gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc) { break; } - ptr = aligned_alloc(alignment, (size + alignment - 1) & ~(alignment - 1)); + size_t actual_old_size = malloc_usable_size(old_memory); + if (size <= actual_old_size) { + ptr = old_memory; + break; + } + + isize total_size = (size + alignment - 1) & ~(alignment - 1); + total_heap_memory_allocated.fetch_add(total_size); + ptr = aligned_alloc(alignment, total_size); gb_memmove(ptr, old_memory, old_size); free(old_memory); gb_zero_size(cast(u8 *)ptr + old_size, gb_max(size-old_size, 0)); - break; + } break; #else // TODO(bill): *nix version that's decent case gbAllocation_Alloc: { diff --git a/src/ptr_map.cpp b/src/ptr_map.cpp index e353b2f97..fbde98693 100644 --- a/src/ptr_map.cpp +++ b/src/ptr_map.cpp @@ -114,7 +114,9 @@ gb_internal MapIndex map__add_entry(PtrMap *h, K key) { PtrMapEntry e = {}; e.key = key; e.next = MAP_SENTINEL; - map__reserve_entries(h, h->count+1); + if (h->count+1 >= h->entries_capacity) { + map__reserve_entries(h, gb_max(h->entries_capacity*2, 4)); + } h->entries[h->count++] = e; return cast(MapIndex)(h->count-1); } diff --git a/src/string_map.cpp b/src/string_map.cpp index bf1bbf6ca..f8b86a950 100644 --- a/src/string_map.cpp +++ b/src/string_map.cpp @@ -96,7 +96,9 @@ gb_internal MapIndex string_map__add_entry(StringMap *h, u32 hash, String con e.key = key; e.hash = hash; e.next = MAP_SENTINEL; - string_map__reserve_entries(h, h->count+1); + if (h->count+1 >= h->entries_capacity) { + string_map__reserve_entries(h, gb_max(h->entries_capacity*2, 4)); + } h->entries[h->count++] = e; return cast(MapIndex)(h->count-1); } From f2ec438166333555bb0b9bc9de2c5b85e7ce4386 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 21 Apr 2023 12:50:36 +0100 Subject: [PATCH 03/29] Add ifdef block --- src/common_memory.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/common_memory.cpp b/src/common_memory.cpp index d6a87529f..c6ee88f03 100644 --- a/src/common_memory.cpp +++ b/src/common_memory.cpp @@ -1,4 +1,6 @@ +#if defined(GB_SYSTEM_LINUX) #include +#endif gb_internal gb_inline void zero_size(void *ptr, isize len) { memset(ptr, 0, len); From 3b2864d8a60623a7fc534508474fd6a2ce734d0b Mon Sep 17 00:00:00 2001 From: Matias Fernandez Date: Sat, 22 Apr 2023 17:49:16 -0400 Subject: [PATCH 04/29] Add IsWindow to user32.odin This is useful for checking if window has been closed without going through the WindowProc. --- core/sys/windows/user32.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 05d6837dd..e8499a67b 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -38,6 +38,7 @@ foreign user32 { DestroyWindow :: proc(hWnd: HWND) -> BOOL --- ShowWindow :: proc(hWnd: HWND, nCmdShow: c_int) -> BOOL --- + IsWindow :: proc(hWnd: HWND) -> BOOL --- BringWindowToTop :: proc(hWnd: HWND) -> BOOL --- GetTopWindow :: proc(hWnd: HWND) -> HWND --- SetForegroundWindow :: proc(hWnd: HWND) -> BOOL --- From 65bf7f6653573e4eb92fe81ed4352066593c1191 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Sun, 23 Apr 2023 20:00:25 +0200 Subject: [PATCH 05/29] Remove typo --- core/reflect/types.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/reflect/types.odin b/core/reflect/types.odin index bfe894733..cad9b1f66 100644 --- a/core/reflect/types.odin +++ b/core/reflect/types.odin @@ -563,7 +563,7 @@ write_type_writer :: proc(w: io.Writer, ti: ^Type_Info, n_written: ^int = nil) - case .None: // Ignore case .Fixed: io.write_string(w, "#soa[", &n) or_return - io.write_i64(w, i64(info.soa_len), 10 &n) or_return + io.write_i64(w, i64(info.soa_len), 10) or_return io.write_byte(w, ']', &n) or_return write_type(w, info.soa_base_type, &n) or_return return From dbebe9e92ca163b125034f16220b316767aa769b Mon Sep 17 00:00:00 2001 From: Jan Prukner Date: Mon, 24 Apr 2023 21:43:34 +0200 Subject: [PATCH 06/29] Fix which command check The function have_witch failed because which is an alias in my environment. This change makes the function work even if which command is an alias. --- build_odin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_odin.sh b/build_odin.sh index 62943732f..860cb388f 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -157,7 +157,7 @@ run_demo() { } have_which() { - if ! [ -x "$(command -v which)" ]; then + if ! command -v which 2>&1 ; then panic "Could not find \`which\`" fi } From 19097bc5bc2e5254eb6bae2b03877c9d678a0523 Mon Sep 17 00:00:00 2001 From: Jan Prukner Date: Tue, 25 Apr 2023 07:06:36 +0200 Subject: [PATCH 07/29] add redirect to /dev/null --- build_odin.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_odin.sh b/build_odin.sh index 860cb388f..9f4e7101a 100755 --- a/build_odin.sh +++ b/build_odin.sh @@ -157,7 +157,7 @@ run_demo() { } have_which() { - if ! command -v which 2>&1 ; then + if ! command -v which > /dev/null 2>&1 ; then panic "Could not find \`which\`" fi } From 827f36e2c07ca09d7822a8dc49ca1b34378801fb Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 26 Apr 2023 14:20:09 +0100 Subject: [PATCH 08/29] Update to Metal 3 --- vendor/darwin/Foundation/NSNotification.odin | 30 + vendor/darwin/Metal/MetalClasses.odin | 875 +++++++++++++++++++ vendor/darwin/Metal/MetalEnums.odin | 92 +- vendor/darwin/Metal/MetalErrors.odin | 14 +- vendor/darwin/Metal/MetalProcedures.odin | 7 + vendor/darwin/Metal/MetalTypes.odin | 2 + vendor/darwin/QuartzCore/QuartzCore.odin | 11 + 7 files changed, 1023 insertions(+), 8 deletions(-) diff --git a/vendor/darwin/Foundation/NSNotification.odin b/vendor/darwin/Foundation/NSNotification.odin index ec8dddab7..13718c024 100644 --- a/vendor/darwin/Foundation/NSNotification.odin +++ b/vendor/darwin/Foundation/NSNotification.odin @@ -27,4 +27,34 @@ Notification_object :: proc(self: ^Notification) -> ^Object { @(objc_type=Notification, objc_name="userInfo") Notification_userInfo :: proc(self: ^Notification) -> ^Dictionary { return msgSend(^Dictionary, self, "userInfo") +} + +NotificationName :: ^String + +@(objc_class="NSNotificationCenter") +NotificationCenter :: struct{using _: Object} + + +@(objc_type=NotificationCenter, objc_name="alloc", objc_is_class_method=true) +NotificationCenter_alloc :: proc() -> ^NotificationCenter { + return msgSend(^NotificationCenter, NotificationCenter, "alloc") +} + +@(objc_type=NotificationCenter, objc_name="init") +NotificationCenter_init :: proc(self: ^NotificationCenter) -> ^NotificationCenter { + return msgSend(^NotificationCenter, self, "init") +} + +@(objc_type=NotificationCenter, objc_name="defaultCenter", objc_is_class_method=true) +NotificationCenter_defaultCenter :: proc() -> ^NotificationCenter { + return msgSend(^NotificationCenter, NotificationCenter, "defaultCenter") +} + +@(objc_type=NotificationCenter, objc_name="addObserver") +NotificationCenter_addObserverName :: proc(self: ^NotificationCenter, name: NotificationName, pObj: ^Object, pQueue: rawptr, block: ^Block) -> ^Object { + return msgSend(^Object, self, "addObserverName:object:queue:block:", name, pObj, pQueue, block) +} +@(objc_type=NotificationCenter, objc_name="removeObserver") +NotificationCenter_removeObserver :: proc(self: ^NotificationCenter, pObserver: ^Object) { + msgSend(nil, self, "removeObserver:", pObserver) } \ No newline at end of file diff --git a/vendor/darwin/Metal/MetalClasses.odin b/vendor/darwin/Metal/MetalClasses.odin index 075aae545..66cf68cce 100644 --- a/vendor/darwin/Metal/MetalClasses.odin +++ b/vendor/darwin/Metal/MetalClasses.odin @@ -194,6 +194,32 @@ AccelerationStructureMotionTriangleGeometryDescriptor_setTriangleCount :: #force msgSend(nil, self, "setTriangleCount:", count) } +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="vertexFormat") +AccelerationStructureMotionTriangleGeometryDescriptor_vertexFormat :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> AttributeFormat { + return msgSend(AttributeFormat, self, "vertexFormat") +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setVertexFormat") +AccelerationStructureMotionTriangleGeometryDescriptor_setVertexFormat :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, vertexFormat: AttributeFormat) { + msgSend(nil, self, "setVertexFormat:", vertexFormat) +} + +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="transformationMatrixBuffer") +AccelerationStructureMotionTriangleGeometryDescriptor_transformationMatrixBuffer :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> ^Buffer { + return msgSend(^Buffer, self, "transformationMatrixBuffer") +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setTransformationMatrixBuffer") +AccelerationStructureMotionTriangleGeometryDescriptor_setTransformationMatrixBuffer :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, transformationMatrixBuffer: ^Buffer) { + msgSend(nil, self, "setTransformationMatrixBuffer:", transformationMatrixBuffer) +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="transformationMatrixBufferOffset") +AccelerationStructureMotionTriangleGeometryDescriptor_transformationMatrixBufferOffset :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "transformationMatrixBufferOffset") +} +@(objc_type=AccelerationStructureMotionTriangleGeometryDescriptor, objc_name="setTransformationMatrixBufferOffset") +AccelerationStructureMotionTriangleGeometryDescriptor_setTransformationMatrixBufferOffset :: #force_inline proc(self: ^AccelerationStructureMotionTriangleGeometryDescriptor, transformationMatrixBufferOffset: NS.UInteger) { + msgSend(nil, self, "setTransformationMatrixBufferOffset:", transformationMatrixBufferOffset) +} + //////////////////////////////////////////////////////////////////////////////// /* @@ -298,6 +324,14 @@ Methods: setAllowDuplicateIntersectionFunctionInvocation setIntersectionFunctionTableOffset setOpaque + primitiveDataBuffer + setPrimitiveDataBuffer + primitiveDataBufferOffset + setPrimitiveDataBufferOffset + primitiveDataStride + setPrimitiveDataStride + primitiveDataElementSize + setPrimitiveDataElementSize */ @(objc_class="MTLAccelerationStructureGeometryDescriptor") AccelerationStructureGeometryDescriptor :: struct { using _: NS.Copying(AccelerationStructureGeometryDescriptor) } @@ -334,6 +368,40 @@ AccelerationStructureGeometryDescriptor_setIntersectionFunctionTableOffset :: #f AccelerationStructureGeometryDescriptor_setOpaque :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, opaque: BOOL) { msgSend(nil, self, "setOpaque:", opaque) } +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataBuffer") +AccelerationStructureGeometryDescriptor_primitiveDataBuffer :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> ^Buffer { + return msgSend(^Buffer, self, "primitiveDataBuffer") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataBuffer") +AccelerationStructureGeometryDescriptor_setPrimitiveDataBuffer :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, primitiveDataBuffer: ^Buffer) { + msgSend(nil, self, "setPrimitiveDataBuffer:", primitiveDataBuffer) +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataBufferOffset") +AccelerationStructureGeometryDescriptor_primitiveDataBufferOffset :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "primitiveDataBufferOffset") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataBufferOffset") +AccelerationStructureGeometryDescriptor_setPrimitiveDataBufferOffset :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, offset: NS.UInteger) { + msgSend(nil, self, "setPrimitiveDataBufferOffset:", offset) +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataStride") +AccelerationStructureGeometryDescriptor_primitiveDataStride :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "primitiveDataStride") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataStride") +AccelerationStructureGeometryDescriptor_setPrimitiveDataStride :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, stride: NS.UInteger) { + msgSend(nil, self, "setPrimitiveDataStride:", stride) +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="primitiveDataElementSize") +AccelerationStructureGeometryDescriptor_primitiveDataElementSize :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "primitiveDataElementSize") +} +@(objc_type=AccelerationStructureGeometryDescriptor, objc_name="setPrimitiveDataElementSize") +AccelerationStructureGeometryDescriptor_setPrimitiveDataElementSize :: #force_inline proc(self: ^AccelerationStructureGeometryDescriptor, elementSize: NS.UInteger) { + msgSend(nil, self, "setPrimitiveDataElementSize:", elementSize) +} + + //////////////////////////////////////////////////////////////////////////////// @@ -359,6 +427,12 @@ Methods: vertexBuffer vertexBufferOffset vertexStride + vertexFormat + setVertexFormat + transformationMatrixBuffer + setTransformationMatrixBuffer + transformationMatrixBufferOffset + setTransformationMatrixBufferOffset */ @(objc_class="MTLAccelerationStructureTriangleGeometryDescriptor") AccelerationStructureTriangleGeometryDescriptor :: struct { using _: NS.Copying(AccelerationStructureTriangleGeometryDescriptor), using _: AccelerationStructureDescriptor } @@ -432,6 +506,32 @@ AccelerationStructureTriangleGeometryDescriptor_vertexStride :: #force_inline pr return msgSend(NS.UInteger, self, "vertexStride") } +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="vertexFormat") +AccelerationStructureTriangleGeometryDescriptor_vertexFormat :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> AttributeFormat { + return msgSend(AttributeFormat, self, "vertexFormat") +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setVertexFormat") +AccelerationStructureTriangleGeometryDescriptor_setVertexFormat :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, vertexFormat: AttributeFormat) { + msgSend(nil, self, "setVertexFormat:", vertexFormat) +} + +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="transformationMatrixBuffer") +AccelerationStructureTriangleGeometryDescriptor_transformationMatrixBuffer :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> ^Buffer { + return msgSend(^Buffer, self, "transformationMatrixBuffer") +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setTransformationMatrixBuffer") +AccelerationStructureTriangleGeometryDescriptor_setTransformationMatrixBuffer :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, transformationMatrixBuffer: ^Buffer) { + msgSend(nil, self, "setTransformationMatrixBuffer:", transformationMatrixBuffer) +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="transformationMatrixBufferOffset") +AccelerationStructureTriangleGeometryDescriptor_transformationMatrixBufferOffset :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "transformationMatrixBufferOffset") +} +@(objc_type=AccelerationStructureTriangleGeometryDescriptor, objc_name="setTransformationMatrixBufferOffset") +AccelerationStructureTriangleGeometryDescriptor_setTransformationMatrixBufferOffset :: #force_inline proc(self: ^AccelerationStructureTriangleGeometryDescriptor, transformationMatrixBufferOffset: NS.UInteger) { + msgSend(nil, self, "setTransformationMatrixBufferOffset:", transformationMatrixBufferOffset) +} + //////////////////////////////////////////////////////////////////////////////// /* @@ -1325,6 +1425,15 @@ CompileOptions_setPreprocessorMacros :: #force_inline proc(self: ^CompileOptions CompileOptions_setPreserveInvariance :: #force_inline proc(self: ^CompileOptions, preserveInvariance: BOOL) { msgSend(nil, self, "setPreserveInvariance:", preserveInvariance) } +@(objc_type=CompileOptions, objc_name="optimizationLevel") +CompileOptions_optimizationLevel :: #force_inline proc(self: ^CompileOptions) -> LibraryOptimizationLevel { + return msgSend(LibraryOptimizationLevel, self, "optimizationLevel") +} +@(objc_type=CompileOptions, objc_name="setOptimizationLevel") +CompileOptions_setOptimizationLevel :: #force_inline proc(self: ^CompileOptions, optimizationLevel: LibraryOptimizationLevel) { + msgSend(nil, self, "setOptimizationLevel:", optimizationLevel) +} + //////////////////////////////////////////////////////////////////////////////// @@ -1593,6 +1702,11 @@ ComputePipelineDescriptor_supportIndirectCommandBuffers :: #force_inline proc(se ComputePipelineDescriptor_threadGroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc(self: ^ComputePipelineDescriptor) -> BOOL { return msgSend(BOOL, self, "threadGroupSizeIsMultipleOfThreadExecutionWidth") } +@(objc_type=ComputePipelineDescriptor, objc_name="gpuResourceID") +ComputePipelineDescriptor_gpuResourceID :: #force_inline proc(self: ^ComputePipelineDescriptor) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + //////////////////////////////////////////////////////////////////////////////// @@ -1616,6 +1730,10 @@ ComputePipelineReflection_alloc :: #force_inline proc() -> ^ComputePipelineRefle ComputePipelineReflection_init :: #force_inline proc(self: ^ComputePipelineReflection) -> ^ComputePipelineReflection { return msgSend(^ComputePipelineReflection, self, "init") } +@(objc_type=ComputePipelineReflection, objc_name="bindings") +ComputePipelineReflection_bindings :: #force_inline proc(self: ^ComputePipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "bindings") +} @(objc_type=ComputePipelineReflection, objc_name="arguments") ComputePipelineReflection_arguments :: #force_inline proc(self: ^ComputePipelineReflection) -> ^NS.Array { return msgSend(^NS.Array, self, "arguments") @@ -1977,6 +2095,16 @@ HeapDescriptor_resourceOptions :: #force_inline proc(self: ^HeapDescriptor) -> R HeapDescriptor_setCpuCacheMode :: #force_inline proc(self: ^HeapDescriptor, cpuCacheMode: CPUCacheMode) { msgSend(nil, self, "setCpuCacheMode:", cpuCacheMode) } + +@(objc_type=HeapDescriptor, objc_name="sparsePageSize") +HeapDescriptor_sparsePageSize :: #force_inline proc(self: ^HeapDescriptor) -> SparsePageSize { + return msgSend(SparsePageSize, self, "sparsePageSize") +} +@(objc_type=HeapDescriptor, objc_name="setSparsePageSize") +HeapDescriptor_setSparsePageSize :: #force_inline proc(self: ^HeapDescriptor, sparsePageSize: SparsePageSize) { + msgSend(nil, self, "setSparsePageSize:", sparsePageSize) +} + @(objc_type=HeapDescriptor, objc_name="setHazardTrackingMode") HeapDescriptor_setHazardTrackingMode :: #force_inline proc(self: ^HeapDescriptor, hazardTrackingMode: HazardTrackingMode) { msgSend(nil, self, "setHazardTrackingMode:", hazardTrackingMode) @@ -3664,6 +3792,101 @@ RenderPipelineDescriptor_vertexFunction :: #force_inline proc(self: ^RenderPipel return msgSend(^Function, self, "vertexFunction") } +@(objc_type=RenderPipelineDescriptor, objc_name="objectFunction") +RenderPipelineDescriptor_objectFunction :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^Function { + return msgSend(^Function, self, "objectFunction") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setObjectFunction") +RenderPipelineDescriptor_setObjectFunction :: #force_inline proc(self: ^RenderPipelineDescriptor, objectFunction: ^Function) { + msgSend(nil, self, "setObjectFunction:", objectFunction) +} +@(objc_type=RenderPipelineDescriptor, objc_name="meshFunction") +RenderPipelineDescriptor_meshFunction :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^Function { + return msgSend(^Function, self, "meshFunction") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMeshFunction") +RenderPipelineDescriptor_setMeshFunction :: #force_inline proc(self: ^RenderPipelineDescriptor, meshFunction: ^Function) { + msgSend(nil, self, "setMeshFunction:", meshFunction) +} + +@(objc_type=RenderPipelineDescriptor, objc_name="maxTotalThreadsPerObjectThreadgroup") +RenderPipelineDescriptor_maxTotalThreadsPerObjectThreadgroup :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerObjectThreadgroup") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMaxTotalThreadsPerObjectThreadgroup") +RenderPipelineDescriptor_setMaxTotalThreadsPerObjectThreadgroup :: #force_inline proc(self: ^RenderPipelineDescriptor, maxTotalThreadsPerObjectThreadgroup: NS.UInteger) { + msgSend(nil, self, "setMaxTotalThreadsPerObjectThreadgroup:", maxTotalThreadsPerObjectThreadgroup) +} +@(objc_type=RenderPipelineDescriptor, objc_name="maxTotalThreadsPerMeshThreadgroup") +RenderPipelineDescriptor_maxTotalThreadsPerMeshThreadgroup :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerMeshThreadgroup") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMaxTotalThreadsPerMeshThreadgroup") +RenderPipelineDescriptor_setMaxTotalThreadsPerMeshThreadgroup :: #force_inline proc(self: ^RenderPipelineDescriptor, maxTotalThreadsPerMeshThreadgroup: NS.UInteger) { + msgSend(nil, self, "setMaxTotalThreadsPerMeshThreadgroup:", maxTotalThreadsPerMeshThreadgroup) +} +@(objc_type=RenderPipelineDescriptor, objc_name="objectThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_objectThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectThreadgroupSizeIsMultipleOfThreadExecutionWidth") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc(self: ^RenderPipelineDescriptor, objectThreadgroupSizeIsMultipleOfThreadExecutionWidth: NS.UInteger) { + msgSend(nil, self, "setObjectThreadgroupSizeIsMultipleOfThreadExecutionWidth:", objectThreadgroupSizeIsMultipleOfThreadExecutionWidth) +} + +@(objc_type=RenderPipelineDescriptor, objc_name="meshThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_meshThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "meshThreadgroupSizeIsMultipleOfThreadExecutionWidth") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth") +RenderPipelineDescriptor_setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth :: #force_inline proc(self: ^RenderPipelineDescriptor, meshThreadgroupSizeIsMultipleOfThreadExecutionWidth: BOOL) { + msgSend(nil, self, "setMeshThreadgroupSizeIsMultipleOfThreadExecutionWidth:", meshThreadgroupSizeIsMultipleOfThreadExecutionWidth) +} + + +@(objc_type=RenderPipelineDescriptor, objc_name="payloadMemoryLength") +RenderPipelineDescriptor_payloadMemoryLength :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "payloadMemoryLength") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setPayloadMemoryLength") +RenderPipelineDescriptor_setPayloadMemoryLength :: #force_inline proc(self: ^RenderPipelineDescriptor, payloadMemoryLength: NS.UInteger) { + msgSend(nil, self, "setPayloadMemoryLength:", payloadMemoryLength) +} +@(objc_type=RenderPipelineDescriptor, objc_name="maxTotalThreadgroupsPerMeshGrid") +RenderPipelineDescriptor_maxTotalThreadgroupsPerMeshGrid :: #force_inline proc(self: ^RenderPipelineDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadgroupsPerMeshGrid") +} +@(objc_type=RenderPipelineDescriptor, objc_name="setMaxTotalThreadgroupsPerMeshGrid") +RenderPipelineDescriptor_setMaxTotalThreadgroupsPerMeshGrid :: #force_inline proc(self: ^RenderPipelineDescriptor, maxTotalThreadgroupsPerMeshGrid: NS.UInteger) { + msgSend(nil, self, "setMaxTotalThreadgroupsPerMeshGrid:", maxTotalThreadgroupsPerMeshGrid) +} + +@(objc_type=RenderPipelineDescriptor, objc_name="objectBuffers") +RenderPipelineDescriptor_objectBuffers :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { + return msgSend(^PipelineBufferDescriptorArray, self, "objectBuffers") +} +@(objc_type=RenderPipelineDescriptor, objc_name="meshBuffers") +RenderPipelineDescriptor_meshBuffers :: #force_inline proc(self: ^RenderPipelineDescriptor) -> ^PipelineBufferDescriptorArray { + return msgSend(^PipelineBufferDescriptorArray, self, "meshBuffers") +} + + + +@(objc_type=RenderPipelineDescriptor, objc_name="alphaToCoverageEnabled") +RenderPipelineDescriptor_alphaToCoverageEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "alphaToCoverageEnabled") +} +@(objc_type=RenderPipelineDescriptor, objc_name="alphaToOneEnabled") +RenderPipelineDescriptor_alphaToOneEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "alphaToOneEnabled") +} + +@(objc_type=RenderPipelineDescriptor, objc_name="rasterizationEnabled") +RenderPipelineDescriptor_rasterizationEnabled :: #force_inline proc(self: ^RenderPipelineDescriptor) -> BOOL { + return msgSend(BOOL, self, "rasterizationEnabled") +} + + //////////////////////////////////////////////////////////////////////////////// /* @@ -3701,6 +3924,27 @@ RenderPipelineReflection_vertexArguments :: #force_inline proc(self: ^RenderPipe return msgSend(^NS.Array, self, "vertexArguments") } +@(objc_type=RenderPipelineReflection, objc_name="vertexBindings") +RenderPipelineReflection_vertexBindings :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "vertexBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="fragmentBindings") +RenderPipelineReflection_fragmentBindings :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "fragmentBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="tileBindings") +RenderPipelineReflection_tileBindings :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "tileBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="objectBindings") +RenderPipelineReflection_objectBindings :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "objectBindings") +} +@(objc_type=RenderPipelineReflection, objc_name="meshBindings") +RenderPipelineReflection_meshBindings :: #force_inline proc(self: ^RenderPipelineReflection) -> ^NS.Array { + return msgSend(^NS.Array, self, "meshBindings") +} + //////////////////////////////////////////////////////////////////////////////// /* @@ -4505,6 +4749,15 @@ TextureDescriptor_width :: #force_inline proc(self: ^TextureDescriptor) -> NS.UI return msgSend(NS.UInteger, self, "width") } +@(objc_type=TextureDescriptor, objc_name="compressionType") +TextureDescriptor_compressionType :: #force_inline proc(self: ^TextureDescriptor) -> TextureCompressionType { + return msgSend(TextureCompressionType, self, "compressionType") +} +@(objc_type=TextureDescriptor, objc_name="setCompressionType") +TextureDescriptor_setCompressionType :: #force_inline proc(self: ^TextureDescriptor, compressionType: TextureCompressionType) { + msgSend(nil, self, "setCompressionType:", compressionType) +} + //////////////////////////////////////////////////////////////////////////////// /* @@ -5042,6 +5295,7 @@ Class: Class Methods: Methods: size + getResourceID */ @(objc_class="MTLAccelerationStructure") AccelerationStructure :: struct { using _: Resource } @@ -5051,6 +5305,11 @@ AccelerationStructure_size :: #force_inline proc(self: ^AccelerationStructure) - return msgSend(NS.UInteger, self, "size") } +@(objc_type=AccelerationStructure, objc_name="getResourceID") +AccelerationStructure_getResourceID :: #force_inline proc(self: ^AccelerationStructure) -> ResourceID { + return msgSend(ResourceID, self, "getResourceID") +} + //////////////////////////////////////////////////////////////////////////////// /* @@ -5062,6 +5321,7 @@ Methods: copyAccelerationStructure copyAndCompactAccelerationStructure refitAccelerationStructure + refitAccelerationStructureWithOptions sampleCountersInBuffer updateFence useHeap @@ -5090,6 +5350,10 @@ AccelerationStructureCommandEncoder_copyAndCompactAccelerationStructure :: #forc AccelerationStructureCommandEncoder_refitAccelerationStructure :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure: ^AccelerationStructure, descriptor: ^AccelerationStructureDescriptor, destinationAccelerationStructure: ^AccelerationStructure, scratchBuffer: ^Buffer, scratchBufferOffset: NS.UInteger) { msgSend(nil, self, "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:", sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset) } +@(objc_type=AccelerationStructureCommandEncoder, objc_name="refitAccelerationStructureWithOptions") +AccelerationStructureCommandEncoder_refitAccelerationStructureWithOptions :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, sourceAccelerationStructure: ^AccelerationStructure, descriptor: ^AccelerationStructureDescriptor, destinationAccelerationStructure: ^AccelerationStructure, scratchBuffer: ^Buffer, scratchBufferOffset: NS.UInteger, options: AccelerationStructureRefitOptions) { + msgSend(nil, self, "refitAccelerationStructure:descriptor:destination:scratchBuffer:scratchBufferOffset:options:", sourceAccelerationStructure, descriptor, destinationAccelerationStructure, scratchBuffer, scratchBufferOffset, options) +} @(objc_type=AccelerationStructureCommandEncoder, objc_name="sampleCountersInBuffer") AccelerationStructureCommandEncoder_sampleCountersInBuffer :: #force_inline proc(self: ^AccelerationStructureCommandEncoder, sampleBuffer: ^Buffer, sampleIndex: NS.UInteger, barrier: BOOL) { msgSend(nil, self, "sampleCountersInBuffer:atSampleIndex:withBarrier:", sampleBuffer, sampleIndex, barrier) @@ -5125,6 +5389,207 @@ AccelerationStructureCommandEncoder_writeCompactedAccelerationStructureSize :: # //////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLAccelerationStructurePassSampleBufferAttachmentDescriptor") +AccelerationStructurePassSampleBufferAttachmentDescriptor :: struct { using _: NS.Copying(AccelerationStructurePassSampleBufferAttachmentDescriptor) } + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="alloc", objc_is_class_method=true) +AccelerationStructurePassSampleBufferAttachmentDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructurePassSampleBufferAttachmentDescriptor { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptor, AccelerationStructurePassSampleBufferAttachmentDescriptor, "alloc") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="init") +AccelerationStructurePassSampleBufferAttachmentDescriptor_init :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptor { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptor, self, "init") +} + + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="sampleBuffer") +AccelerationStructurePassSampleBufferAttachmentDescriptor_sampleBuffer :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> ^CounterSampleBuffer { + return msgSend(^CounterSampleBuffer, self, "sampleBuffer") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="setSampleBuffer") +AccelerationStructurePassSampleBufferAttachmentDescriptor_setSampleBuffer :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, sampleBuffer: ^CounterSampleBuffer) { + msgSend(nil, self, "setSampleBuffer:", sampleBuffer) +} + + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="startOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_startOfEncoderSampleIndex :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "startOfEncoderSampleIndex") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="setStartOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_setStartOfEncoderSampleIndex :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, startOfEncoderSampleIndex: NS.UInteger) { + msgSend(nil, self, "setStartOfEncoderSampleIndex:", startOfEncoderSampleIndex) +} + + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="endOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_endOfEncoderSampleIndex :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "endOfEncoderSampleIndex") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptor, objc_name="setEndOfEncoderSampleIndex") +AccelerationStructurePassSampleBufferAttachmentDescriptor_setEndOfEncoderSampleIndex :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, endOfEncoderSampleIndex: NS.UInteger) { + msgSend(nil, self, "setEndOfEncoderSampleIndex:", endOfEncoderSampleIndex) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray :: struct { using _: NS.Object } + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="alloc", objc_is_class_method=true) +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_alloc :: #force_inline proc() -> ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, AccelerationStructurePassSampleBufferAttachmentDescriptorArray, "alloc") +} +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="init") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_init :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, self, "init") +} + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="object") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_object :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, attachmentIndex: NS.UInteger) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptor { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptor, self, "objectAtIndexedSubscript:", attachmentIndex) +} + +@(objc_type=AccelerationStructurePassSampleBufferAttachmentDescriptorArray, objc_name="setObject") +AccelerationStructurePassSampleBufferAttachmentDescriptorArray_setObject :: #force_inline proc(self: ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, attachment: ^AccelerationStructurePassSampleBufferAttachmentDescriptor, attachmentIndex: NS.UInteger) { + msgSend(nil, self, "setObject:atIndexedSubscript:", attachment, attachmentIndex) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLAccelerationStructurePassDescriptor") +AccelerationStructurePassDescriptor :: struct { using _: NS.Copying(AccelerationStructurePassDescriptor) } + + +@(objc_type=AccelerationStructurePassDescriptor, objc_name="alloc", objc_is_class_method=true) +AccelerationStructurePassDescriptor_alloc :: #force_inline proc() -> ^AccelerationStructurePassDescriptor { + return msgSend(^AccelerationStructurePassDescriptor, AccelerationStructurePassDescriptor, "alloc") +} +@(objc_type=AccelerationStructurePassDescriptor, objc_name="init") +AccelerationStructurePassDescriptor_init :: #force_inline proc(self: ^AccelerationStructurePassDescriptor) -> ^AccelerationStructurePassDescriptor { + return msgSend(^AccelerationStructurePassDescriptor, self, "init") +} + + +@(objc_type=AccelerationStructurePassDescriptor, objc_name="accelerationStructurePassDescriptor", objc_is_class_method=true) +AccelerationStructurePassDescriptor_accelerationStructurePassDescriptor :: #force_inline proc() -> ^AccelerationStructurePassDescriptor { + return msgSend(^AccelerationStructurePassDescriptor, AccelerationStructurePassDescriptor, "accelerationStructurePassDescriptor") +} +@(objc_type=AccelerationStructurePassDescriptor, objc_name="sampleBufferAttachments") +AccelerationStructurePassDescriptor_sampleBufferAttachments :: #force_inline proc(self: ^AccelerationStructurePassDescriptor) -> ^AccelerationStructurePassSampleBufferAttachmentDescriptorArray { + return msgSend(^AccelerationStructurePassSampleBufferAttachmentDescriptorArray, self, "sampleBufferAttachments") +} + + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLBinding") +Binding :: struct { using _: NS.Object } + +@(objc_type=Binding, objc_name="name") +Binding_name :: #force_inline proc(self: ^Binding) -> ^NS.String { + return msgSend(^NS.String, self, "name") +} +@(objc_type=Binding, objc_name="type") +Binding_type :: #force_inline proc(self: ^Binding) -> BindingType { + return msgSend(BindingType, self, "type") +} +@(objc_type=Binding, objc_name="access") +Binding_access :: #force_inline proc(self: ^Binding) -> ArgumentAccess { + return msgSend(ArgumentAccess, self, "access") +} +@(objc_type=Binding, objc_name="index") +Binding_index :: #force_inline proc(self: ^Binding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "index") +} +@(objc_type=Binding, objc_name="isUsed") +Binding_isUsed :: #force_inline proc(self: ^Binding) -> BOOL { + return msgSend(BOOL, self, "isUsed") +} +@(objc_type=Binding, objc_name="isArgument") +Binding_isArgument :: #force_inline proc(self: ^Binding) -> BOOL { + return msgSend(BOOL, self, "isArgument") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLBufferBinding") +BufferBinding :: struct { using _: Binding } + +@(objc_type=BufferBinding, objc_name="bufferAlignment") +BufferBinding_bufferAlignment :: #force_inline proc(self: ^BufferBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "bufferAlignment") +} +@(objc_type=BufferBinding, objc_name="bufferDataSize") +BufferBinding_bufferDataSize :: #force_inline proc(self: ^BufferBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "bufferDataSize") +} +@(objc_type=BufferBinding, objc_name="bufferDataType") +BufferBinding_bufferDataType :: #force_inline proc(self: ^BufferBinding) -> DataType { + return msgSend(DataType, self, "bufferDataType") +} +@(objc_type=BufferBinding, objc_name="bufferStructType") +BufferBinding_bufferStructType :: #force_inline proc(self: ^BufferBinding) -> ^StructType { + return msgSend(^StructType, self, "bufferStructType") +} +@(objc_type=BufferBinding, objc_name="bufferPointerType") +BufferBinding_bufferPointerType :: #force_inline proc(self: ^BufferBinding) -> ^PointerType { + return msgSend(^PointerType, self, "bufferPointerType") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLThreadgroupBinding") +ThreadgroupBinding :: struct { using _: Binding } + +@(objc_type=ThreadgroupBinding, objc_name="threadgroupMemoryAlignment") +ThreadgroupBinding_threadgroupMemoryAlignment :: #force_inline proc(self: ^ThreadgroupBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "threadgroupMemoryAlignment") +} +@(objc_type=ThreadgroupBinding, objc_name="threadgroupMemoryDataSize") +ThreadgroupBinding_threadgroupMemoryDataSize :: #force_inline proc(self: ^ThreadgroupBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "threadgroupMemoryDataSize") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLTextureBinding") +TextureBinding :: struct { using _: Binding } + +@(objc_type=TextureBinding, objc_name="textureType") +TextureBinding_textureType :: #force_inline proc(self: ^TextureBinding) -> TextureType { + return msgSend(TextureType, self, "textureType") +} +@(objc_type=TextureBinding, objc_name="textureDataType") +TextureBinding_textureDataType :: #force_inline proc(self: ^TextureBinding) -> DataType { + return msgSend(DataType, self, "textureDataType") +} +@(objc_type=TextureBinding, objc_name="isDepthTexture") +TextureBinding_isDepthTexture :: #force_inline proc(self: ^TextureBinding) -> BOOL { + return msgSend(BOOL, self, "isDepthTexture") +} +@(objc_type=TextureBinding, objc_name="arrayLength") +TextureBinding_arrayLength :: #force_inline proc(self: ^TextureBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "arrayLength") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLObjectPayloadBinding") +ObjectPayloadBinding :: struct { using _: Binding } + +@(objc_type=ObjectPayloadBinding, objc_name="objectPayloadAlignment") +ObjectPayloadBinding_objectPayloadAlignment :: #force_inline proc(self: ^ObjectPayloadBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectPayloadAlignment") +} +@(objc_type=ObjectPayloadBinding, objc_name="objectPayloadDataSize") +ObjectPayloadBinding_objectPayloadDataSize :: #force_inline proc(self: ^ObjectPayloadBinding) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectPayloadDataSize") +} + +//////////////////////////////////////////////////////////////////////////////// + /* Class: ArgumentEncoder @@ -5536,6 +6001,15 @@ Buffer_remoteStorageBuffer :: #force_inline proc(self: ^Buffer) -> ^Buffer { Buffer_removeAllDebugMarkers :: #force_inline proc(self: ^Buffer) { msgSend(nil, self, "removeAllDebugMarkers") } +@(objc_type=Buffer, objc_name="newRemoveBufferViewForDevice") +Buffer_newRemoveBufferViewForDevice :: #force_inline proc(self: ^Buffer, device: ^Device) -> ^Buffer { + return msgSend(^Buffer, self, "newRemoteBufferViewForDevice:", device) +} +@(objc_type=Buffer, objc_name="gpuAddress") +Buffer_gpuAddress :: #force_inline proc(self: ^Buffer) -> u64 { + return msgSend(u64, self, "gpuAddress") +} + //////////////////////////////////////////////////////////////////////////////// @@ -5638,6 +6112,10 @@ CommandBuffer_GPUStartTime :: #force_inline proc(self: ^CommandBuffer) -> CFTime CommandBuffer_accelerationStructureCommandEncoder :: #force_inline proc(self: ^CommandBuffer) -> ^AccelerationStructureCommandEncoder { return msgSend(^AccelerationStructureCommandEncoder, self, "accelerationStructureCommandEncoder") } +@(objc_type=CommandBuffer, objc_name="accelerationStructureCommandEncoderWithDescriptor") +CommandBuffer_accelerationStructureCommandEncoderWithDescriptor :: #force_inline proc(self: ^CommandBuffer, descriptor: ^AccelerationStructurePassDescriptor) -> ^AccelerationStructureCommandEncoder { + return msgSend(^AccelerationStructureCommandEncoder, self, "accelerationStructureCommandEncoderWithDescriptor:", descriptor) +} @(objc_type=CommandBuffer, objc_name="addCompletedHandler") CommandBuffer_addCompletedHandler :: #force_inline proc(self: ^CommandBuffer, block: CommandBufferHandler) { msgSend(nil, self, "addCompletedHandler:", block) @@ -6803,6 +7281,34 @@ Device_supportsVertexAmplificationCount :: #force_inline proc(self: ^Device, cou return msgSend(BOOL, self, "supportsVertexAmplificationCount:", count) } + +@(objc_type=Device, objc_name="newRenderPipelineStateWithMeshDescriptor") +Device_newRenderPipelineStateWithMeshDescriptor :: #force_inline proc(self: ^Device, options: PipelineOption, reflection: ^AutoreleasedRenderPipelineReflection) -> (state: ^RenderPipelineState, error: ^NS.Error) { + state = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithMeshDescriptor:options:reflection:error:", options, reflection, &error) + return +} +@(objc_type=Device, objc_name="newRenderPipelineStateWithMeshDescriptorAndCompletionHandler") +Device_newRenderPipelineStateWithMeshDescriptorAndCompletionHandler :: #force_inline proc(self: ^Device, options: PipelineOption, completionHandler: ^NewRenderPipelineStateWithReflectionCompletionHandler) -> (state: ^RenderPipelineState) { + state = msgSend(^RenderPipelineState, self, "newRenderPipelineStateWithMeshDescriptor:options:completionHandler:", options, completionHandler) + return +} + +@(objc_type=Device, objc_name="newIOHandle") +Device_newIOHandle :: #force_inline proc(self: ^Device, url: ^NS.URL) -> (handle: ^IOFileHandle, err: ^NS.Error) { + handle = msgSend(^IOFileHandle, self, "newIOHandleWithURL:error:", url, &err) + return +} +@(objc_type=Device, objc_name="newIOHandleWithCompressionMethod") +Device_newIOHandleWithCompressionMethod :: #force_inline proc(self: ^Device, url: ^NS.URL, compressionMethod: IOCompressionMethod) -> (handle: ^IOFileHandle, err: ^NS.Error) { + handle = msgSend(^IOFileHandle, self, "newIOHandleWithURL:compressionMethod:error:", url, compressionMethod, &err) + return +} +@(objc_type=Device, objc_name="newIOCommandQueue") +Device_newIOCommandQueue :: #force_inline proc(self: ^Device, descriptor: ^IOCommandQueueDescriptor) -> (handle: ^IOCommandQueue, err: ^NS.Error) { + handle = msgSend(^IOCommandQueue, self, "newIOCommandQueueWithDescriptor:error:", descriptor, &err) + return +} + //////////////////////////////////////////////////////////////////////////////// /* @@ -7195,6 +7701,30 @@ Heap_newTexture :: proc{ Heap_newTextureWithDescriptorAndOffset, } +@(objc_type=Heap, objc_name="newAccelerationStructureWithSize") +Heap_newAccelerationStructureWithSize :: #force_inline proc(self: ^Heap, size: NS.UInteger) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithSize:", size) +} +@(objc_type=Heap, objc_name="newAccelerationStructureWithDescriptor") +Heap_newAccelerationStructureWithDescriptor :: #force_inline proc(self: ^Heap, descriptor: ^AccelerationStructureDescriptor) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithDescriptor:", descriptor) +} +@(objc_type=Heap, objc_name="newAccelerationStructureWithSizeAndOffset") +Heap_newAccelerationStructureWithSizeAndOffset :: #force_inline proc(self: ^Heap, size, offset: NS.UInteger) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithSize:offset:", size, offset) +} +@(objc_type=Heap, objc_name="newAccelerationStructureWithDescriptorAndOffset") +Heap_newAccelerationStructureWithDescriptorAndOffset :: #force_inline proc(self: ^Heap, descriptor: ^AccelerationStructureDescriptor, offset: NS.UInteger) -> ^AccelerationStructure { + return msgSend(^AccelerationStructure, self, "newAccelerationStructureWithDescriptor:offset:", descriptor, offset) +} +@(objc_type=Heap, objc_name="newAccelerationStructure") +Heap_newAccelerationStructure :: proc{ + Heap_newAccelerationStructureWithSize, + Heap_newAccelerationStructureWithDescriptor, + Heap_newAccelerationStructureWithSizeAndOffset, + Heap_newAccelerationStructureWithDescriptorAndOffset, +} + @(objc_type=Heap, objc_name="resourceOptions") Heap_resourceOptions :: #force_inline proc(self: ^Heap) -> ResourceOptions { return msgSend(ResourceOptions, self, "resourceOptions") @@ -7256,6 +7786,21 @@ IndirectCommandBuffer_size :: #force_inline proc(self: ^IndirectCommandBuffer) - return msgSend(NS.UInteger, self, "size") } +@(objc_type=IndirectCommandBuffer, objc_name="supportRayTracing") +IndirectCommandBuffer_supportRayTracing :: #force_inline proc(self: ^IndirectCommandBuffer) -> BOOL { + return msgSend(BOOL, self, "supportRayTracing") +} +@(objc_type=IndirectCommandBuffer, objc_name="setSupportRayTracing") +IndirectCommandBuffer_setSupportRayTracing :: #force_inline proc(self: ^IndirectCommandBuffer, supportRayTracing: BOOL) { + msgSend(nil, self, "setSupportRayTracing:", supportRayTracing) +} + +@(objc_type=IndirectCommandBuffer, objc_name="gpuResourceID") +IndirectCommandBuffer_gpuResourceID :: #force_inline proc(self: ^IndirectCommandBuffer) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + + //////////////////////////////////////////////////////////////////////////////// /* @@ -7422,6 +7967,176 @@ IntersectionFunctionTable_setVisibleFunctionTables :: #force_inline proc(self: ^ msgSend(nil, self, "setVisibleFunctionTables:withBufferRange:", raw_data(visibleFunctionTables), range) } +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOCommandQueue") +IOCommandQueue :: struct { using _: NS.Object } + +@(objc_type=IOCommandQueue, objc_name="enqueueBarrier") +IOCommandQueue_enqueueBarrier :: #force_inline proc(self: ^IOCommandQueue) { + msgSend(nil, self, "enqueueBarrier") +} +@(objc_type=IOCommandQueue, objc_name="commandBuffer") +IOCommandQueue_commandBuffer :: #force_inline proc(self: ^IOCommandQueue) -> ^IOCommandBuffer { + return msgSend(^IOCommandBuffer, self, "commandBuffer") +} +@(objc_type=IOCommandQueue, objc_name="commandBufferWithUnretainedReferences") +IOCommandQueue_commandBufferWithUnretainedReferences :: #force_inline proc(self: ^IOCommandQueue) -> ^IOCommandBuffer { + return msgSend(^IOCommandBuffer, self, "commandBufferWithUnretainedReferences") +} +@(objc_type=IOCommandQueue, objc_name="label") +IOCommandQueue_label :: #force_inline proc(self: ^IOCommandQueue) -> ^NS.String { + return msgSend(^NS.String, self, "label") +} +@(objc_type=IOCommandQueue, objc_name="setLabel") +IOCommandQueue_setLabel :: #force_inline proc(self: ^IOCommandQueue, label: ^NS.String) { + msgSend(nil, self, "setLabel:", label) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOScratchBuffer") +IOScratchBuffer :: struct { using _: NS.Object } + +@(objc_type=IOScratchBuffer, objc_name="buffer") +IOScratchBuffer_buffer :: #force_inline proc(self: ^IOCommandQueue) -> ^Buffer { + return msgSend(^Buffer, self, "buffer") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOScratchBufferAllocator") +IOScratchBufferAllocator :: struct { using _: NS.Object } + +@(objc_type=IOScratchBufferAllocator, objc_name="newScratchBuffer") +IOScratchBufferAllocator_newScratchBuffer :: #force_inline proc(self: ^IOCommandQueue, minimumSize: NS.UInteger) -> ^IOScratchBuffer { + return msgSend(^IOScratchBuffer, self, "newScratchBufferWithMinimumSize:", minimumSize) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOCommandQueueDescriptor") +IOCommandQueueDescriptor :: struct { using _: NS.Copying(IOCommandQueueDescriptor) } + + +@(objc_type=IOCommandQueueDescriptor, objc_name="alloc", objc_is_class_method=true) +IOCommandQueueDescriptor_alloc :: #force_inline proc() -> ^IOCommandQueueDescriptor { + return msgSend(^IOCommandQueueDescriptor, IOCommandQueueDescriptor, "alloc") +} +@(objc_type=IOCommandQueueDescriptor, objc_name="init") +IOCommandQueueDescriptor_init :: #force_inline proc(self: ^IOCommandQueueDescriptor) -> ^IOCommandQueueDescriptor { + return msgSend(^IOCommandQueueDescriptor, self, "init") +} + +@(objc_type=IOCommandQueueDescriptor, objc_name="maxCommandBufferCount") +IOCommandQueueDescriptor_maxCommandBufferCount :: #force_inline proc(self: ^IOCommandQueueDescriptor) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxCommandBufferCount") +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOFileHandle") +IOFileHandle :: struct { using _: NS.Object } + +@(objc_type=IOFileHandle, objc_name="label") +IOFileHandle_label :: #force_inline proc(self: ^IOFileHandle) -> ^NS.String { + return msgSend(^NS.String, self, "label") +} +@(objc_type=IOFileHandle, objc_name="setLabel") +IOFileHandle_setLabel :: #force_inline proc(self: ^IOFileHandle, label: ^NS.String) { + msgSend(nil, self, "setLabel:", label) +} + +//////////////////////////////////////////////////////////////////////////////// + +@(objc_class="MTLIOCommandBuffer") +IOCommandBuffer :: struct { using _: NS.Object } + +@(objc_type=IOCommandBuffer, objc_name="addCompletedHandler") +IOCommandBuffer_addCompletedHandler :: #force_inline proc(self: ^IOCommandBuffer, block: ^NS.Block) { + msgSend(nil, self, "addCompletedHandler:", block) +} +@(objc_type=IOCommandBuffer, objc_name="loadBytes") +IOCommandBuffer_loadBytes :: #force_inline proc(self: ^IOCommandBuffer, pointer: rawptr, size: NS.UInteger, sourceHandle: ^IOFileHandle, sourceHandleOffset: NS.UInteger) { + msgSend(nil, self, "loadBytes:size:sourceHandle:sourceHandleOffset:", pointer, size, sourceHandle, sourceHandleOffset) +} +@(objc_type=IOCommandBuffer, objc_name="loadBuffer") +IOCommandBuffer_loadBuffer :: #force_inline proc(self: ^IOCommandBuffer, buffer: ^Buffer, offset: NS.UInteger, size: NS.UInteger, sourceHandle: ^IOFileHandle, sourceHandleOffset: NS.UInteger) { + msgSend(nil, self, "loadBuffer:offset:sourceHandle:sourceHandleOffset:", buffer, offset, size, sourceHandle, sourceHandleOffset) +} +@(objc_type=IOCommandBuffer, objc_name="loadTexture") +IOCommandBuffer_loadTexture :: #force_inline proc(self: ^IOCommandBuffer, texture: ^Texture, slice: NS.UInteger, level, size, sourceBytesPerRow, sourceBytesPerImage: NS.UInteger, destinationOrigin: Origin, sourceHandle: ^IOFileHandle, sourceHandleOffset: NS.UInteger) { + msgSend(nil, self, "loadTexture:slice:level:size:sourceBytesPerRow:sourceBytesPerImage:destinationOrigin:sourceHandle:sourceHandleOffset:", texture, slice, level, size, sourceBytesPerRow, sourceBytesPerImage, destinationOrigin, sourceHandle, sourceHandleOffset) +} + +@(objc_type=IOCommandBuffer, objc_name="copyStatusToBuffer") +IOCommandBuffer_copyStatusToBuffer :: #force_inline proc(self: ^IOCommandBuffer, buffer: ^Buffer, offset: NS.UInteger) { + msgSend(nil, self, "copyStatusToBuffer:offset:", buffer, offset) +} + +@(objc_type=IOCommandBuffer, objc_name="commit") +IOCommandBuffer_commit :: #force_inline proc(self: ^IOCommandBuffer) { + msgSend(nil, self, "commit") +} +@(objc_type=IOCommandBuffer, objc_name="waitUntilCompleted") +IOCommandBuffer_waitUntilCompleted :: #force_inline proc(self: ^IOCommandBuffer) { + msgSend(nil, self, "waitUntilCompleted") +} +@(objc_type=IOCommandBuffer, objc_name="tryCancel") +IOCommandBuffer_tryCancel :: #force_inline proc(self: ^IOCommandBuffer) { + msgSend(nil, self, "tryCancel") +} +@(objc_type=IOCommandBuffer, objc_name="addBarrier") +IOCommandBuffer_addBarrier :: #force_inline proc(self: ^IOCommandBuffer) { + msgSend(nil, self, "addBarrier") +} +@(objc_type=IOCommandBuffer, objc_name="enqueue") +IOCommandBuffer_enqueue :: #force_inline proc(self: ^IOCommandBuffer) { + msgSend(nil, self, "enqueue") +} +@(objc_type=IOCommandBuffer, objc_name="waitForEvent") +IOCommandBuffer_waitForEvent :: #force_inline proc(self: ^IOCommandBuffer, event: ^SharedEvent, value: u64) { + msgSend(nil, self, "waitForEvent:value", event, value) +} +@(objc_type=IOCommandBuffer, objc_name="signalEvent") +IOCommandBuffer_signalEvent :: #force_inline proc(self: ^IOCommandBuffer, event: ^SharedEvent, value: u64) { + msgSend(nil, self, "signalEvent:value", event, value) +} + + +@(objc_type=IOCommandBuffer, objc_name="pushDebugGroup") +IOCommandBuffer_pushDebugGroup :: #force_inline proc(self: ^IOCommandBuffer, name: ^NS.String) { + msgSend(nil, self, "pushDebugGroup:", name) +} +@(objc_type=IOCommandBuffer, objc_name="popDebugGroup") +IOCommandBuffer_popDebugGroup :: #force_inline proc(self: ^IOCommandBuffer) { + msgSend(nil, self, "popDebugGroup") +} + + +@(objc_type=IOCommandBuffer, objc_name="label") +IOCommandBuffer_label :: #force_inline proc(self: ^IOCommandBuffer) -> ^NS.String { + return msgSend(^NS.String, self, "label") +} +@(objc_type=IOCommandBuffer, objc_name="setLabel") +IOCommandBuffer_setLabel :: #force_inline proc(self: ^IOCommandBuffer, label: ^NS.String) { + msgSend(nil, self, "setLabel:", label) +} + +@(objc_type=IOCommandBuffer, objc_name="status") +IOCommandBuffer_status :: #force_inline proc(self: ^IOCommandBuffer) -> IOStatus { + return msgSend(IOStatus, self, "status") +} +@(objc_type=IOCommandBuffer, objc_name="error") +IOCommandBuffer_error :: #force_inline proc(self: ^IOCommandBuffer) -> ^NS.Error { + return msgSend(^NS.Error, self, "error") +} + +//////////////////////////////////////////////////////////////////////////////// + + + + //////////////////////////////////////////////////////////////////////////////// /* @@ -8063,6 +8778,108 @@ RenderCommandEncoder_waitForFence :: #force_inline proc(self: ^RenderCommandEnco msgSend(nil, self, "waitForFence:beforeStages:", fence, stages) } +@(objc_type=RenderCommandEncoder, objc_name="setObjectBytes") +RenderCommandEncoder_setObjectBytes :: #force_inline proc(self: ^RenderCommandEncoder, bytes: rawptr, length: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectBytes:length:atIndex:", bytes, length, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectBuffer") +RenderCommandEncoder_setObjectBuffer :: #force_inline proc(self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectBuffer:offset:atIndex:", buffer, offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectBufferOffset") +RenderCommandEncoder_setObjectBufferOffset :: #force_inline proc(self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectBufferOffset:atIndex:", offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectBuffers") +RenderCommandEncoder_setObjectBuffers :: #force_inline proc(self: ^RenderCommandEncoder, buffers: [^]^Buffer, offsets: [^]NS.UInteger, range: NS.Range) { + msgSend(nil, self, "setObjectBuffers:offsets:withRange:", buffers, offsets, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectTexture") +RenderCommandEncoder_setObjectTexture :: #force_inline proc(self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { + msgSend(nil, self, "setObjectTexture:atIndex:", texture, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectTextures") +RenderCommandEncoder_setObjectTextures :: #force_inline proc(self: ^RenderCommandEncoder, textures: [^]^Texture, range: NS.Range) { + msgSend(nil, self, "setObjectTextures:withRange:", textures, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerState") +RenderCommandEncoder_setObjectSamplerState :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { + msgSend(nil, self, "setObjectSamplerState:atIndex:", sampler, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerStates") +RenderCommandEncoder_setObjectSamplerStates :: #force_inline proc(self: ^RenderCommandEncoder, samplers: [^]^SamplerState, range: NS.Range) { + msgSend(nil, self, "setObjectSamplerStates:withRange:", samplers, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerStateWithLod") +RenderCommandEncoder_setObjectSamplerStateWithLod :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp, lodMaxClamp: f32, index: NS.UInteger) { + msgSend(nil, self, "setObjectSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setObjectSamplerStatesWithLod") +RenderCommandEncoder_setObjectSamplerStatesWithLod :: #force_inline proc(self: ^RenderCommandEncoder, samplers: [^]^SamplerState, lodMinClamps, lodMaxClamps: [^]f32, range: NS.Range) { + msgSend(nil, self, "setObjectSamplerStates:lodMinClamps:lodMaxClamps:withRange:", samplers, lodMinClamps, lodMaxClamps, range) +} + +@(objc_type=RenderCommandEncoder, objc_name="setObjectThreadgroupMemoryLength") +RenderCommandEncoder_setObjectThreadgroupMemoryLength :: #force_inline proc(self: ^RenderCommandEncoder, length: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setObjectThreadgroupMemoryLength:atIndex:", length, index) +} + +@(objc_type=RenderCommandEncoder, objc_name="setMeshBytes") +RenderCommandEncoder_setMeshBytes :: #force_inline proc(self: ^RenderCommandEncoder, bytes: rawptr, length: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setMeshBytes:atIndex:", bytes, length, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshBuffer") +RenderCommandEncoder_setMeshBuffer :: #force_inline proc(self: ^RenderCommandEncoder, buffer: ^Buffer, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setMeshBuffer:offset:atIndex:", buffer, offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshBufferOffset") +RenderCommandEncoder_setMeshBufferOffset :: #force_inline proc(self: ^RenderCommandEncoder, offset: NS.UInteger, index: NS.UInteger) { + msgSend(nil, self, "setMeshBufferOffset:atIndex:", offset, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshBuffers") +RenderCommandEncoder_setMeshBuffers :: #force_inline proc(self: ^RenderCommandEncoder, buffers: [^]^Buffer, offsets: [^]NS.UInteger, range: NS.Range) { + msgSend(nil, self, "setMeshBuffers:offsets:withRange:", buffers, offsets, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshTexture") +RenderCommandEncoder_setMeshTexture :: #force_inline proc(self: ^RenderCommandEncoder, texture: ^Texture, index: NS.UInteger) { + msgSend(nil, self, "setMeshTexture:atIndex:", texture, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshTextures") +RenderCommandEncoder_setMeshTextures :: #force_inline proc(self: ^RenderCommandEncoder, textures: [^]^Texture, range: NS.Range) { + msgSend(nil, self, "setMeshTextures:withRange:", textures, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerState") +RenderCommandEncoder_setMeshSamplerState :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, index: NS.UInteger) { + msgSend(nil, self, "setMeshSamplerState:atIndex:", sampler, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerStates") +RenderCommandEncoder_setMeshSamplerStates :: #force_inline proc(self: ^RenderCommandEncoder, samplers: [^]^SamplerState, range: NS.Range) { + msgSend(nil, self, "setMeshSamplerStates:withRange:", samplers, range) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerStateWithLod") +RenderCommandEncoder_setMeshSamplerStateWithLod :: #force_inline proc(self: ^RenderCommandEncoder, sampler: ^SamplerState, lodMinClamp, lodMaxClamp: f32, index: NS.UInteger) { + msgSend(nil, self, "setMeshSamplerState:lodMinClamp:lodMaxClamp:atIndex:", sampler, lodMinClamp, lodMaxClamp, index) +} +@(objc_type=RenderCommandEncoder, objc_name="setMeshSamplerStatesWithLod") +RenderCommandEncoder_setMeshSamplerStatesWithLod :: #force_inline proc(self: ^RenderCommandEncoder, samplers: [^]^SamplerState, lodMinClamps, lodMaxClamps: [^]f32, range: NS.Range) { + msgSend(nil, self, "setMeshSamplerStates:lodMinClamps:lodMaxClamps:withRange:", samplers, lodMinClamps, lodMaxClamps, range) +} + +@(objc_type=RenderCommandEncoder, objc_name="drawMeshThreadgroups") +RenderCommandEncoder_drawMeshThreadgroups :: #force_inline proc(self: ^RenderCommandEncoder, threadgroupsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup: Size) { + msgSend(nil, self, "drawMeshThreadgroups:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:", threadgroupsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup) +} +@(objc_type=RenderCommandEncoder, objc_name="drawMeshThreads") +RenderCommandEncoder_drawMeshThreads :: #force_inline proc(self: ^RenderCommandEncoder, threadsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup: Size) { + msgSend(nil, self, "drawMeshThreads:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:", threadsPerGrid, threadPerObjectThreadgroup, threadsPerMeshThreadgroup) +} +@(objc_type=RenderCommandEncoder, objc_name="drawMeshThreadgroupsWithIndirectBuffer") +RenderCommandEncoder_drawMeshThreadgroupsWithIndirectBuffer :: #force_inline proc(self: ^RenderCommandEncoder, indirectBuffer: ^Buffer, indirectBufferOffset, threadPerObjectThreadgroup, threadsPerMeshThreadgroup: Size) { + msgSend(nil, self, "drawMeshThreadgroupsWithIndirectBuffer:indirectBufferOffset:threadsPerObjectThreadgroup:threadsPerMeshThreadgroup:", indirectBuffer, indirectBufferOffset, threadPerObjectThreadgroup, threadsPerMeshThreadgroup) +} + + + //////////////////////////////////////////////////////////////////////////////// /* @@ -8176,6 +8993,34 @@ RenderPipelineState_newRenderPipelineState :: #force_inline proc(self: ^RenderPi return } + +@(objc_type=RenderPipelineState, objc_name="maxTotalThreadsPerObjectThreadgroup") +RenderPipelineState_maxTotalThreadsPerObjectThreadgroup :: #force_inline proc(self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerObjectThreadgroup") +} +@(objc_type=RenderPipelineState, objc_name="maxTotalThreadsPerMeshThreadgroup") +RenderPipelineState_maxTotalThreadsPerMeshThreadgroup :: #force_inline proc(self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadsPerMeshThreadgroup") +} +@(objc_type=RenderPipelineState, objc_name="objectThreadExecutionWidth") +RenderPipelineState_objectThreadExecutionWidth :: #force_inline proc(self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "objectThreadExecutionWidth") +} +@(objc_type=RenderPipelineState, objc_name="meshThreadExecutionWidth") +RenderPipelineState_meshThreadExecutionWidth :: #force_inline proc(self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "meshThreadExecutionWidth") +} +@(objc_type=RenderPipelineState, objc_name="maxTotalThreadgroupsPerMeshGrid") +RenderPipelineState_maxTotalThreadgroupsPerMeshGrid :: #force_inline proc(self: ^RenderPipelineState) -> NS.UInteger { + return msgSend(NS.UInteger, self, "maxTotalThreadgroupsPerMeshGrid") +} +@(objc_type=RenderPipelineState, objc_name="gpuResourceID") +RenderPipelineState_gpuResourceID :: #force_inline proc(self: ^RenderPipelineState) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + + + //////////////////////////////////////////////////////////////////////////////// /* @@ -8290,6 +9135,18 @@ ResourceStateCommandEncoder_waitForFence :: #force_inline proc(self: ^ResourceSt msgSend(nil, self, "waitForFence:", fence) } +@(objc_type=ResourceStateCommandEncoder, objc_name="moveTextureMappingsFromTexture") +ResourceStateCommandEncoder_moveTextureMappingsFromTexture :: #force_inline proc(self: ^ResourceStateCommandEncoder, + sourceTexture: ^Texture, sourceSlice, sourceLevel: NS.UInteger, sourceOrigin: Origin, sourceSize: Size, + destinationTexture: ^Texture, destinationSlice, destinationLevel: NS.UInteger, destinationOrigin: Origin, +) { + msgSend(nil, self, "moveTextureMappingsFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toTexture:destinationSlice:destinationLevel:destinationOrigin:", + sourceTexture, sourceSlice, sourceLevel, sourceOrigin, sourceSize, + destinationTexture, destinationSlice, destinationLevel, destinationOrigin, + ) +} + + //////////////////////////////////////////////////////////////////////////////// /* @@ -8311,6 +9168,10 @@ SamplerState_device :: #force_inline proc(self: ^SamplerState) -> ^Device { SamplerState_label :: #force_inline proc(self: ^SamplerState) -> ^NS.String { return msgSend(^NS.String, self, "label") } +@(objc_type=SamplerState, objc_name="gpuResourceID") +SamplerState_gpuResourceID :: #force_inline proc(self: ^SamplerState) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} //////////////////////////////////////////////////////////////////////////////// @@ -8531,6 +9392,15 @@ Texture_width :: #force_inline proc(self: ^Texture) -> NS.UInteger { return msgSend(NS.UInteger, self, "width") } +@(objc_type=Texture, objc_name="compressionType") +Texture_compressionType :: #force_inline proc(self: ^Texture) -> TextureCompressionType { + return msgSend(TextureCompressionType, self, "compressionType") +} +@(objc_type=Texture, objc_name="gpuResourceID") +Texture_gpuResourceID :: #force_inline proc(self: ^Texture) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + //////////////////////////////////////////////////////////////////////////////// /* @@ -8553,6 +9423,11 @@ VisibleFunctionTable_setFunctions :: #force_inline proc(self: ^VisibleFunctionTa msgSend(nil, self, "setFunctions:withRange:", raw_data(functions), range) } +@(objc_type=VisibleFunctionTable, objc_name="gpuResourceID") +VisibleFunctionTable_gpuResourceID :: #force_inline proc(self: ^VisibleFunctionTable) -> ResourceID { + return msgSend(ResourceID, self, "gpuResourceID") +} + // TODO: Entire FunctionStitching API (which appears not to be in been missed from the generator) diff --git a/vendor/darwin/Metal/MetalEnums.odin b/vendor/darwin/Metal/MetalEnums.odin index 7d72483ff..ab4782da4 100644 --- a/vendor/darwin/Metal/MetalEnums.odin +++ b/vendor/darwin/Metal/MetalEnums.odin @@ -17,6 +17,14 @@ AccelerationStructureInstanceOption :: enum u32 { NonOpaque = 3, } + +AccelerationStructureRefitOptions :: distinct bit_set[AccelerationStructureRefitOption; NS.UInteger] +AccelerationStructureRefitOption :: enum NS.UInteger { + VertexData = 0, + PerPrimitiveData = 1, +} + + MotionBorderMode :: enum u32 { Clamp = 0, Vanish = 1, @@ -148,6 +156,21 @@ BinaryArchiveError :: enum NS.UInteger { InvalidFile = 1, UnexpectedElement = 2, CompilationFailure = 3, + InternalError = 4, +} + +BindingType :: enum NS.Integer { + Buffer = 0, + ThreadgroupMemory = 1, + Texture = 2, + Sampler = 3, + ImageblockData = 16, + Imageblock = 17, + VisibleFunctionTable = 24, + PrimitiveAccelerationStructure = 25, + InstanceAccelerationStructure = 26, + IntersectionFunctionTable = 27, + ObjectPayload = 34, } BlitOptionFlag :: enum NS.UInteger { @@ -171,15 +194,16 @@ CaptureDestination :: enum NS.Integer { CommandBufferStatus :: enum NS.UInteger { NotEnqueued = 0, - Enqueued = 1, - Committed = 2, - Scheduled = 3, - Completed = 4, - Error = 5, + Enqueued = 1, + Committed = 2, + Scheduled = 3, + Completed = 4, + Error = 5, } CommandBufferError :: enum NS.UInteger { None = 0, + Internal = 1, Timeout = 2, PageFault = 3, AccessRevoked = 4, @@ -232,6 +256,7 @@ BarrierScope :: distinct bit_set[BarrierScopeFlag; NS.UInteger] CounterSampleBufferError :: enum NS.Integer { OutOfMemory = 0, Invalid = 1, + Internal = 2, } CompareFunction :: enum NS.UInteger { @@ -312,6 +337,13 @@ GPUFamily :: enum NS.Integer { Common3 = 3003, MacCatalyst1 = 4001, MacCatalyst2 = 4002, + Metal3 = 5001, +} + +SparsePageSize :: enum NS.Integer { + Size16 = 101, + Size64 = 102, + Size256 = 103, } DeviceLocation :: enum NS.UInteger { @@ -409,6 +441,9 @@ FunctionType :: enum NS.UInteger { Kernel = 3, Visible = 5, Intersection = 6, + Mesh = 7, + Object = 8, + } @@ -421,15 +456,22 @@ LanguageVersion :: enum NS.UInteger { Version2_2 = 131074, Version2_3 = 131075, Version2_4 = 131076, + Version3_0 = 196608, } LibraryType :: enum NS.Integer { Executable = 0, - Dynamic = 1, + Dynamic = 1, +} + +LibraryOptimizationLevel :: enum NS.Integer { + Default = 0, + Size = 1, } LibraryError :: enum NS.UInteger { Unsupported = 1, + Internal = 2, CompileFailure = 3, CompileWarning = 4, FunctionNotFound = 5, @@ -624,6 +666,8 @@ RenderStage :: enum NS.UInteger { Vertex = 0, Fragment = 1, Tile = 2, + Object = 3, + Mesh = 4, } RenderStages :: distinct bit_set[RenderStage; NS.UInteger] @@ -861,6 +905,42 @@ IndexType :: enum NS.UInteger { UInt32 = 1, } +IOPriority :: enum NS.Integer { + High = 0, + Normal = 1, + Low = 2, +} + +IOCommandQueueType :: enum NS.Integer { + Concurrent = 0, + Serial = 1, +} + +IOError :: enum NS.Integer { + URLInvalid = 1, + Internal = 2, +} + +IOStatus :: enum NS.Integer { + Pending = 0, + Cancelled = 1, + Error = 2, + Complete = 3, +} + +IOCompressionMethod :: enum NS.Integer { + Zlib = 0, + LZFSE = 1, + LZ4 = 2, + LZMA = 3, + LZBitmap = 4, +} + +IOCompressionStatus :: enum NS.Integer { + Complete = 0, + Error = 1, +} + StepFunction :: enum NS.UInteger { Constant = 0, PerVertex = 1, diff --git a/vendor/darwin/Metal/MetalErrors.odin b/vendor/darwin/Metal/MetalErrors.odin index f214466e5..8bc851e33 100644 --- a/vendor/darwin/Metal/MetalErrors.odin +++ b/vendor/darwin/Metal/MetalErrors.odin @@ -4,9 +4,11 @@ import NS "vendor:darwin/Foundation" foreign import "system:Metal.framework" -CommonCounter :: ^NS.String -CommonCounterSet :: ^NS.String +CommonCounter :: ^NS.String +CommonCounterSet :: ^NS.String DeviceNotificationName :: ^NS.String +ErrorUserInfoKey :: ^NS.ErrorUserInfoKey +ErrorDomain :: ^NS.ErrorDomain foreign Metal { @(linkage="weak") CommonCounterTimestamp: CommonCounter @@ -36,4 +38,12 @@ foreign Metal { @(linkage="weak") DeviceWasAddedNotification: DeviceNotificationName @(linkage="weak") DeviceRemovalRequestedNotification: DeviceNotificationName @(linkage="weak") DeviceWasRemovedNotification: DeviceNotificationName +} + +foreign Metal { + @(linkage="weak") CommandBufferEncoderInfoErrorKey: ErrorUserInfoKey +} + +foreign Metal { + @(linkage="weak") IOErrorDomain: ErrorDomain } \ No newline at end of file diff --git a/vendor/darwin/Metal/MetalProcedures.odin b/vendor/darwin/Metal/MetalProcedures.odin index ca8fb1aea..dd90bd3e9 100644 --- a/vendor/darwin/Metal/MetalProcedures.odin +++ b/vendor/darwin/Metal/MetalProcedures.odin @@ -1,6 +1,7 @@ package objc_Metal import NS "vendor:darwin/Foundation" +import "core:c" @(require) foreign import "system:Metal.framework" @@ -11,6 +12,12 @@ foreign Metal { CopyAllDevicesWithObserver :: proc(observer: ^id, handler: DeviceNotificationHandler) -> ^NS.Array --- CreateSystemDefaultDevice :: proc() -> ^Device --- RemoveDeviceObserver :: proc(observer: id) --- + + + IOCompressionContextDefaultChunkSize :: proc() -> c.size_t --- + IOCreateCompressionContext :: proc(path: cstring, type: IOCompressionMethod, chuckSize: c.size_t) -> rawptr --- + IOCompressionContextAppendData :: proc(ctx: rawptr, data: rawptr, size: c.size_t) --- + IOFlushAndDestroyCompressionContext :: proc(ctx: rawptr) -> IOCompressionStatus --- } diff --git a/vendor/darwin/Metal/MetalTypes.odin b/vendor/darwin/Metal/MetalTypes.odin index cc9d25ca0..b14fe2886 100644 --- a/vendor/darwin/Metal/MetalTypes.odin +++ b/vendor/darwin/Metal/MetalTypes.odin @@ -133,6 +133,8 @@ Region :: struct { SamplePosition :: distinct [2]f32 +ResourceID :: distinct u64 + ScissorRect :: struct { x: NS.Integer, y: NS.Integer, diff --git a/vendor/darwin/QuartzCore/QuartzCore.odin b/vendor/darwin/QuartzCore/QuartzCore.odin index fb6e04b07..2a14fc345 100644 --- a/vendor/darwin/QuartzCore/QuartzCore.odin +++ b/vendor/darwin/QuartzCore/QuartzCore.odin @@ -56,6 +56,17 @@ MetalLayer_setFramebufferOnly :: proc(self: ^MetalLayer, ok: NS.BOOL) { msgSend(nil, self, "setFramebufferOnly:", ok) } + +@(objc_type=MetalLayer, objc_name="drawableSize") +MetalLayer_drawableSize :: proc(self: ^MetalLayer) -> NS.Size { + return msgSend(NS.Size, self, "drawableSize") +} +@(objc_type=MetalLayer, objc_name="setDrawableSize") +MetalLayer_setDrawableSize :: proc(self: ^MetalLayer, drawableSize: NS.Size) { + msgSend(nil, self, "setDrawableSize:", drawableSize) +} + + @(objc_type=MetalLayer, objc_name="frame") MetalLayer_frame :: proc(self: ^MetalLayer) -> NS.Rect { return msgSend(NS.Rect, self, "frame") From 47be46ae605e482fa7f0344b7470572923c5c034 Mon Sep 17 00:00:00 2001 From: Ikko Eltociear Ashimine Date: Thu, 27 Apr 2023 00:03:36 +0900 Subject: [PATCH 09/29] Fix typo in marshal.odin seperation -> separation --- core/encoding/json/marshal.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/encoding/json/marshal.odin b/core/encoding/json/marshal.odin index f5914bc07..4cf9264c5 100644 --- a/core/encoding/json/marshal.odin +++ b/core/encoding/json/marshal.odin @@ -441,7 +441,7 @@ opt_write_start :: proc(w: io.Writer, opt: ^Marshal_Options, c: byte) -> (err: i return } -// insert comma seperation and write indentations +// insert comma separation and write indentations opt_write_iteration :: proc(w: io.Writer, opt: ^Marshal_Options, iteration: int) -> (err: io.Error) { switch opt.spec { case .JSON, .JSON5: @@ -461,7 +461,7 @@ opt_write_iteration :: proc(w: io.Writer, opt: ^Marshal_Options, iteration: int) if opt.pretty { io.write_byte(w, '\n') or_return } else { - // comma seperation necessary for non pretty output! + // comma separation necessary for non pretty output! io.write_string(w, ", ") or_return } } From b7924de5c6026d990c8e2f8b24f72a27c0880082 Mon Sep 17 00:00:00 2001 From: GiveMeFox <74460065+GiveMeFox@users.noreply.github.com> Date: Wed, 26 Apr 2023 22:49:31 +0200 Subject: [PATCH 10/29] Update README.md updated the discord link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f99174c46..4df71015d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@
- + From 023cc9ca541d7462a323147cbc056fe4303f299f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 00:24:00 +0100 Subject: [PATCH 11/29] Partially buffer `fmt.fprint*` related calls using a `bufio.Writer` --- core/bufio/writer.odin | 8 ++++++++ core/fmt/fmt_os.odin | 40 +++++++++++++++++++++++++++++++++++----- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/core/bufio/writer.odin b/core/bufio/writer.odin index 9e38395ee..ed0d557c5 100644 --- a/core/bufio/writer.odin +++ b/core/bufio/writer.odin @@ -227,6 +227,14 @@ writer_to_stream :: proc(b: ^Writer) -> (s: io.Stream) { return } +// writer_to_stream converts a Writer into an io.Stream +writer_to_writer :: proc(b: ^Writer) -> (s: io.Writer) { + s.stream_data = b + s.stream_vtable = &_writer_vtable + return +} + + @(private) diff --git a/core/fmt/fmt_os.odin b/core/fmt/fmt_os.odin index 52280a3f7..861b0c3b9 100644 --- a/core/fmt/fmt_os.odin +++ b/core/fmt/fmt_os.odin @@ -4,29 +4,59 @@ package fmt import "core:runtime" import "core:os" import "core:io" +import "core:bufio" // fprint formats using the default print settings and writes to fd fprint :: proc(fd: os.Handle, args: ..any, sep := " ") -> int { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, {os.stream_from_handle(fd)}, buf[:]) + w := bufio.writer_to_writer(&b) return wprint(w=w, args=args, sep=sep) } // fprintln formats using the default print settings and writes to fd fprintln :: proc(fd: os.Handle, args: ..any, sep := " ") -> int { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, {os.stream_from_handle(fd)}, buf[:]) + + w := bufio.writer_to_writer(&b) return wprintln(w=w, args=args, sep=sep) } // fprintf formats according to the specified format string and writes to fd fprintf :: proc(fd: os.Handle, fmt: string, args: ..any) -> int { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, {os.stream_from_handle(fd)}, buf[:]) + + w := bufio.writer_to_writer(&b) return wprintf(w, fmt, ..args) } fprint_type :: proc(fd: os.Handle, info: ^runtime.Type_Info) -> (n: int, err: io.Error) { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, {os.stream_from_handle(fd)}, buf[:]) + + w := bufio.writer_to_writer(&b) return wprint_type(w, info) } fprint_typeid :: proc(fd: os.Handle, id: typeid) -> (n: int, err: io.Error) { - w := io.to_writer(os.stream_from_handle(fd)) + buf: [1024]byte + b: bufio.Writer + defer bufio.writer_flush(&b) + + bufio.writer_init_with_buf(&b, {os.stream_from_handle(fd)}, buf[:]) + + w := bufio.writer_to_writer(&b) return wprint_typeid(w, id) } From 67fa5df89c70f7da958443b4ec4cbdc3b515cffa Mon Sep 17 00:00:00 2001 From: Jon Lipstate Date: Wed, 26 Apr 2023 18:00:14 -0700 Subject: [PATCH 12/29] fix typo, add builder sample --- core/strings/builder.odin | 28 +++++++++++++++++++++++++++- core/strings/strings.odin | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/core/strings/builder.odin b/core/strings/builder.odin index 90cc4ebdc..6e809c4f6 100644 --- a/core/strings/builder.odin +++ b/core/strings/builder.odin @@ -71,7 +71,33 @@ Returns: builder_make_len_cap :: proc(len, cap: int, allocator := context.allocator) -> (res: Builder, err: mem.Allocator_Error) #optional_allocator_error { return Builder{buf=make([dynamic]byte, len, cap, allocator) or_return }, nil } -// overload simple `builder_make_*` with or without len / cap parameters +/* +Produces a String Builder + +*Allocates Using Provided Allocator* + +Example: + + import "core:fmt" + import "core:strings" + builder_make_example :: proc() { + sb := strings.builder_make() // Can also use the len, len/cap versions here + strings.write_byte(&sb, 'a') + strings.write_rune(&sb, ' ') + strings.write_string(&sb, "slice of ") + strings.write_f64(&sb, 3.14) // Also _float, _f32 etc + strings.write_string(&sb, "is ") + strings.write_int(&sb, 180) // Also _uint, _u64 etc + strings.write_rune(&sb,'°') + the_string :=strings.to_string(sb) + fmt.println(the_string) + } + +Output: + + a slice of +3.14 is 180° + +*/ builder_make :: proc{ builder_make_none, builder_make_len, diff --git a/core/strings/strings.odin b/core/strings/strings.odin index 39cbe3654..d9387c93e 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -263,7 +263,7 @@ compare :: proc(lhs, rhs: string) -> (result: int) { return mem.compare(transmute([]byte)lhs, transmute([]byte)rhs) } /* -Returns the byte offset of the rune `r` in the string `s`, -1 when not found +Checks if rune `r` in the string `s` Inputs: - s: The input string From f9b5f2b7b1d1f83de988b751d184353ce596d295 Mon Sep 17 00:00:00 2001 From: Jon Lipstate Date: Wed, 26 Apr 2023 18:04:24 -0700 Subject: [PATCH 13/29] update builder sample --- core/strings/builder.odin | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/strings/builder.odin b/core/strings/builder.odin index 6e809c4f6..edde4b297 100644 --- a/core/strings/builder.odin +++ b/core/strings/builder.odin @@ -81,13 +81,12 @@ Example: import "core:fmt" import "core:strings" builder_make_example :: proc() { - sb := strings.builder_make() // Can also use the len, len/cap versions here + sb := strings.builder_make() strings.write_byte(&sb, 'a') - strings.write_rune(&sb, ' ') - strings.write_string(&sb, "slice of ") - strings.write_f64(&sb, 3.14) // Also _float, _f32 etc - strings.write_string(&sb, "is ") - strings.write_int(&sb, 180) // Also _uint, _u64 etc + strings.write_string(&sb, " slice of ") + strings.write_f64(&sb, 3.14,'g',true) // See `fmt.fmt_float` byte codes + strings.write_string(&sb, " is ") + strings.write_int(&sb, 180) strings.write_rune(&sb,'°') the_string :=strings.to_string(sb) fmt.println(the_string) From acd8a4bc951eb00beae96914ae677935ad295363 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 10:58:17 +0100 Subject: [PATCH 14/29] Unify `check_constant_parameter_value` logic --- src/check_type.cpp | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index b687e838e..dfe774f6b 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -378,6 +378,17 @@ gb_internal void add_polymorphic_record_entity(CheckerContext *ctx, Ast *node, T rw_mutex_unlock(&ctx->info->gen_types_mutex); } + +bool check_constant_parameter_value(Type *type, Ast *expr) { + if (!is_type_constant_type(type)) { + gbString str = type_to_string(type); + defer (gb_string_free(str)); + error(expr, "A parameter must be a valid constant type, got %s", str); + return true; + } + return false; +} + gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *polymorphic_params, bool *is_polymorphic_, Ast *node, Array *poly_operands) { @@ -477,10 +488,8 @@ gb_internal Type *check_record_polymorphic_params(CheckerContext *ctx, Ast *poly type = t_invalid; } - if (!is_type_param && !is_type_constant_type(type)) { - gbString str = type_to_string(type); - error(params[i], "A parameter must be a valid constant type, got %s", str); - gb_string_free(str); + if (!is_type_param && check_constant_parameter_value(type, params[i])) { + // failed } Scope *scope = ctx->scope; @@ -1757,10 +1766,8 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para p->flags &= ~FieldFlag_by_ptr; } - if (!is_type_constant_type(type) && !is_type_polymorphic(type)) { - gbString str = type_to_string(type); - error(params[i], "A parameter must be a valid constant type, got %s", str); - gb_string_free(str); + if (!is_type_polymorphic(type) && check_constant_parameter_value(type, params[i])) { + // failed } param = alloc_entity_const_param(scope, name->Ident.token, type, poly_const, is_type_polymorphic(type)); From 68dde07d5d78d879f7edba9c09297661212d6b11 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 11:13:05 +0100 Subject: [PATCH 15/29] Require parentheses around certain uses of `or_return` expressions --- src/error.cpp | 34 ++++++++++++++++++++++++++++++++++ src/parser.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/error.cpp b/src/error.cpp index e3e1381f4..6314c43bb 100644 --- a/src/error.cpp +++ b/src/error.cpp @@ -436,6 +436,32 @@ gb_internal void syntax_error_va(TokenPos const &pos, TokenPos end, char const * } } +gb_internal void syntax_error_with_verbose_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { + global_error_collector.count.fetch_add(1); + + mutex_lock(&global_error_collector.mutex); + // NOTE(bill): Duplicate error, skip it + if (pos.line == 0) { + error_out_coloured("Syntax_Error: ", TerminalStyle_Normal, TerminalColour_Red); + error_out_va(fmt, va); + error_out("\n"); + } else if (global_error_collector.prev != pos) { + global_error_collector.prev = pos; + error_out_pos(pos); + if (has_ansi_terminal_colours()) { + error_out_coloured("Syntax_Error: ", TerminalStyle_Normal, TerminalColour_Red); + } + error_out_va(fmt, va); + error_out("\n"); + show_error_on_line(pos, end); + } + mutex_unlock(&global_error_collector.mutex); + if (global_error_collector.count > MAX_ERROR_COLLECTOR_COUNT()) { + gb_exit(1); + } +} + + gb_internal void syntax_warning_va(TokenPos const &pos, TokenPos end, char const *fmt, va_list va) { if (global_warnings_as_errors()) { syntax_error_va(pos, end, fmt, va); @@ -515,6 +541,14 @@ gb_internal void syntax_warning(Token const &token, char const *fmt, ...) { va_end(va); } +gb_internal void syntax_error_with_verbose(TokenPos pos, TokenPos end, char const *fmt, ...) { + va_list va; + va_start(va, fmt); + syntax_error_with_verbose_va(pos, end, fmt, va); + va_end(va); +} + + gb_internal void compiler_error(char const *fmt, ...) { va_list va; diff --git a/src/parser.cpp b/src/parser.cpp index 790e67db6..b7c097502 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -418,6 +418,25 @@ gb_internal void error(Ast *node, char const *fmt, ...) { } } +gb_internal void syntax_error_with_verbose(Ast *node, char const *fmt, ...) { + Token token = {}; + TokenPos end_pos = {}; + if (node != nullptr) { + token = ast_token(node); + end_pos = ast_end_pos(node); + } + + va_list va; + va_start(va, fmt); + syntax_error_with_verbose_va(token.pos, end_pos, fmt, va); + va_end(va); + if (node != nullptr && node->file_id != 0) { + AstFile *f = node->thread_safe_file(); + f->error_count += 1; + } +} + + gb_internal void error_no_newline(Ast *node, char const *fmt, ...) { Token token = {}; if (node != nullptr) { @@ -496,11 +515,17 @@ gb_internal Ast *ast_tag_expr(AstFile *f, Token token, Token name, Ast *expr) { gb_internal Ast *ast_unary_expr(AstFile *f, Token op, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_UnaryExpr); + + if (expr->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(expr, "'or_return' within an unary expression not wrapped in parentheses (...)"); + } + result->UnaryExpr.op = op; result->UnaryExpr.expr = expr; return result; } + gb_internal Ast *ast_binary_expr(AstFile *f, Token op, Ast *left, Ast *right) { Ast *result = alloc_ast_node(f, Ast_BinaryExpr); @@ -513,6 +538,13 @@ gb_internal Ast *ast_binary_expr(AstFile *f, Token op, Ast *left, Ast *right) { right = ast_bad_expr(f, op, op); } + if (left->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(left, "'or_return' within a binary expression not wrapped in parentheses (...)"); + } + if (right->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(right, "'or_return' within a binary expression not wrapped in parentheses (...)"); + } + result->BinaryExpr.op = op; result->BinaryExpr.left = left; result->BinaryExpr.right = right; @@ -2765,6 +2797,12 @@ gb_internal Ast *parse_call_expr(AstFile *f, Ast *operand) { return call; } +gb_internal void parse_check_or_return(Ast *operand, char const *msg) { + if (operand && operand->kind == Ast_OrReturnExpr) { + syntax_error_with_verbose(operand, "'or_return' use within %s is not wrapped in parentheses (...)", msg); + } +} + gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { if (operand == nullptr) { if (f->allow_type) return nullptr; @@ -2778,6 +2816,7 @@ gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { while (loop) { switch (f->curr_token.kind) { case Token_OpenParen: + parse_check_or_return(operand, "call expression"); operand = parse_call_expr(f, operand); break; @@ -2785,12 +2824,11 @@ gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { Token token = advance_token(f); switch (f->curr_token.kind) { case Token_Ident: + parse_check_or_return(operand, "selector expression"); operand = ast_selector_expr(f, token, operand, parse_ident(f)); break; - // case Token_Integer: - // operand = ast_selector_expr(f, token, operand, parse_expr(f, lhs)); - // break; case Token_OpenParen: { + parse_check_or_return(operand, "type assertion"); Token open = expect_token(f, Token_OpenParen); Ast *type = parse_type(f); Token close = expect_token(f, Token_CloseParen); @@ -2798,6 +2836,7 @@ gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { } break; case Token_Question: { + parse_check_or_return(operand, ".? based type assertion"); Token question = expect_token(f, Token_Question); Ast *type = ast_unary_expr(f, question, nullptr); operand = ast_type_assertion(f, operand, token, type); @@ -2813,6 +2852,7 @@ gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { } break; case Token_ArrowRight: { + parse_check_or_return(operand, "-> based call expression"); Token token = advance_token(f); operand = ast_selector_expr(f, token, operand, parse_ident(f)); @@ -2870,11 +2910,14 @@ gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { if (indices[0] == nullptr || indices[1] == nullptr) { syntax_error(open, "Matrix index expressions require both row and column indices"); } + parse_check_or_return(operand, "matrix index expression"); operand = ast_matrix_index_expr(f, operand, open, close, interval, indices[0], indices[1]); } else { + parse_check_or_return(operand, "slice expression"); operand = ast_slice_expr(f, operand, open, close, interval, indices[0], indices[1]); } } else { + parse_check_or_return(operand, "index expression"); operand = ast_index_expr(f, operand, indices[0], open, close); } @@ -2882,6 +2925,7 @@ gb_internal Ast *parse_atom_expr(AstFile *f, Ast *operand, bool lhs) { } break; case Token_Pointer: // Deference + parse_check_or_return(operand, "dereference"); operand = ast_deref_expr(f, operand, expect_token(f, Token_Pointer)); break; From d6d34bd62f816d1ebb6e04d516520be1f47acd85 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 11:16:02 +0100 Subject: [PATCH 16/29] Add extra nullptr check --- src/parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.cpp b/src/parser.cpp index b7c097502..f33a44f31 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -516,7 +516,7 @@ gb_internal Ast *ast_tag_expr(AstFile *f, Token token, Token name, Ast *expr) { gb_internal Ast *ast_unary_expr(AstFile *f, Token op, Ast *expr) { Ast *result = alloc_ast_node(f, Ast_UnaryExpr); - if (expr->kind == Ast_OrReturnExpr) { + if (expr && expr->kind == Ast_OrReturnExpr) { syntax_error_with_verbose(expr, "'or_return' within an unary expression not wrapped in parentheses (...)"); } From 7cda64e52db8a5596063ec7050a630f87e925067 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 11:17:23 +0100 Subject: [PATCH 17/29] Add parentheses around `or_return` uses in an unary expression --- core/math/big/prime.odin | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/core/math/big/prime.odin b/core/math/big/prime.odin index 6f972937a..2f8b81af2 100644 --- a/core/math/big/prime.odin +++ b/core/math/big/prime.odin @@ -353,14 +353,14 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra // Run the Miller-Rabin test with base 2 for the BPSW test. internal_set(b, 2) or_return - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } // Rumours have it that Mathematica does a second M-R test with base 3. // Other rumours have it that their strong L-S test is slightly different. // It does not hurt, though, beside a bit of extra runtime. b.digit[0] += 1 - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } // Both, the Frobenius-Underwood test and the the Lucas-Selfridge test are quite // slow so if speed is an issue, set `USE_MILLER_RABIN_ONLY` to use M-R tests with @@ -369,9 +369,9 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra if !miller_rabin_only { if miller_rabin_trials >= 0 { when MATH_BIG_USE_FROBENIUS_TEST { - if !internal_int_prime_frobenius_underwood(a) or_return { return } + if !(internal_int_prime_frobenius_underwood(a) or_return) { return } } else { - if !internal_int_prime_strong_lucas_selfridge(a) or_return { return } + if !(internal_int_prime_strong_lucas_selfridge(a) or_return) { return } } } } @@ -410,7 +410,7 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra // We did bases 2 and 3 already, skip them for ix := 2; ix < p_max; ix += 1 { internal_set(b, _private_prime_table[ix]) - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } } } else if miller_rabin_trials > 0 { // Perform `miller_rabin_trials` M-R tests with random bases between 3 and "a". @@ -490,7 +490,7 @@ internal_int_is_prime :: proc(a: ^Int, miller_rabin_trials := int(-1), miller_ra ix -= 1 continue } - if !internal_int_prime_miller_rabin(a, b) or_return { return } + if !(internal_int_prime_miller_rabin(a, b) or_return) { return } } } From b0f0a02d3c897c91350501fcf3d8c2f03886a82f Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 11:26:15 +0100 Subject: [PATCH 18/29] Make `!x` be an untyped boolean --- src/check_expr.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 42306489b..6eb517251 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -1688,6 +1688,8 @@ gb_internal bool check_unary_op(CheckerContext *c, Operand *o, Token op) { if (is_type_integer(type)) { error_line("\tSuggestion: Did you mean to use the bitwise not operator '~'?\n"); } + } else { + o->type = t_untyped_bool; } break; From 7df1cc075c11cc1e946045a61333b5432219849a Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 11:31:05 +0100 Subject: [PATCH 19/29] Fix #2487 --- src/llvm_backend_expr.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 028e90f51..72c8faf07 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -514,6 +514,9 @@ gb_internal bool lb_is_matrix_simdable(Type *t) { // it's not aligned well enough to use the vector instructions return false; } + if ((mt->Matrix.row_count & 1) ^ (mt->Matrix.column_count & 1)) { + return false; + } if (elem->kind == Type_Basic) { switch (elem->Basic.kind) { From 716fe2f4277059102564d09c9390dd6f0f98bded Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 11:32:19 +0100 Subject: [PATCH 20/29] Fix typo #2485 --- core/bufio/lookahead_reader.odin | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/bufio/lookahead_reader.odin b/core/bufio/lookahead_reader.odin index 7d6d7832c..f51c167b9 100644 --- a/core/bufio/lookahead_reader.odin +++ b/core/bufio/lookahead_reader.odin @@ -2,25 +2,25 @@ package bufio import "core:io" -// Loadahead_Reader provides io lookahead. +// Lookahead_Reader provides io lookahead. // This is useful for tokenizers/parsers. -// Loadahead_Reader is similar to bufio.Reader, but unlike bufio.Reader, Loadahead_Reader's buffer size +// Lookahead_Reader is similar to bufio.Reader, but unlike bufio.Reader, Lookahead_Reader's buffer size // will EXACTLY match the specified size, whereas bufio.Reader's buffer size may differ from the specified size. // This makes sure that the buffer will not be accidentally read beyond the expected size. -Loadahead_Reader :: struct { +Lookahead_Reader :: struct { r: io.Reader, buf: []byte, n: int, } -lookahead_reader_init :: proc(lr: ^Loadahead_Reader, r: io.Reader, buf: []byte) -> ^Loadahead_Reader { +lookahead_reader_init :: proc(lr: ^Lookahead_Reader, r: io.Reader, buf: []byte) -> ^Lookahead_Reader { lr.r = r lr.buf = buf lr.n = 0 return lr } -lookahead_reader_buffer :: proc(lr: ^Loadahead_Reader) -> []byte { +lookahead_reader_buffer :: proc(lr: ^Lookahead_Reader) -> []byte { return lr.buf[:lr.n] } @@ -28,7 +28,7 @@ lookahead_reader_buffer :: proc(lr: ^Loadahead_Reader) -> []byte { // lookahead_reader_peek returns a slice of the Lookahead_Reader which holds n bytes // If the Lookahead_Reader cannot hold enough bytes, it will read from the underlying reader to populate the rest. // NOTE: The returned buffer is not a copy of the underlying buffer -lookahead_reader_peek :: proc(lr: ^Loadahead_Reader, n: int) -> ([]byte, io.Error) { +lookahead_reader_peek :: proc(lr: ^Lookahead_Reader, n: int) -> ([]byte, io.Error) { switch { case n < 0: return nil, .Negative_Read @@ -58,13 +58,13 @@ lookahead_reader_peek :: proc(lr: ^Loadahead_Reader, n: int) -> ([]byte, io.Erro // lookahead_reader_peek_all returns a slice of the Lookahead_Reader populating the full buffer // If the Lookahead_Reader cannot hold enough bytes, it will read from the underlying reader to populate the rest. // NOTE: The returned buffer is not a copy of the underlying buffer -lookahead_reader_peek_all :: proc(lr: ^Loadahead_Reader) -> ([]byte, io.Error) { +lookahead_reader_peek_all :: proc(lr: ^Lookahead_Reader) -> ([]byte, io.Error) { return lookahead_reader_peek(lr, len(lr.buf)) } // lookahead_reader_consume drops the first n populated bytes from the Lookahead_Reader. -lookahead_reader_consume :: proc(lr: ^Loadahead_Reader, n: int) -> io.Error { +lookahead_reader_consume :: proc(lr: ^Lookahead_Reader, n: int) -> io.Error { switch { case n == 0: return nil @@ -78,6 +78,6 @@ lookahead_reader_consume :: proc(lr: ^Loadahead_Reader, n: int) -> io.Error { return nil } -lookahead_reader_consume_all :: proc(lr: ^Loadahead_Reader) -> io.Error { +lookahead_reader_consume_all :: proc(lr: ^Lookahead_Reader) -> io.Error { return lookahead_reader_consume(lr, lr.n) } From b3aa6afba98544cbdedfbf5c232ef1af614d2d93 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 27 Apr 2023 11:35:14 +0100 Subject: [PATCH 21/29] Fix #2481 --- src/llvm_backend_expr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 72c8faf07..1b43aac86 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -2836,7 +2836,7 @@ gb_internal lbValue lb_make_soa_pointer(lbProcedure *p, Type *type, lbValue cons lbValue ptr = lb_emit_struct_ep(p, v.addr, 0); lbValue idx = lb_emit_struct_ep(p, v.addr, 1); lb_emit_store(p, ptr, addr); - lb_emit_store(p, idx, index); + lb_emit_store(p, idx, lb_emit_conv(p, index, t_int)); return lb_addr_load(p, v); } From 952832577722b8700df30a63e25b7ae6971c8997 Mon Sep 17 00:00:00 2001 From: Jesse Stiller Date: Thu, 27 Apr 2023 20:49:59 +1000 Subject: [PATCH 22/29] linalg/extended radians and degrees fixed Renamed them to `to_degrees` and `to_radians` to match the same scalar functions in math--plus it helps clarify exactly what they do. And fixed a bug where the array overloads weren't being indexed. --- core/math/linalg/extended.odin | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/math/linalg/extended.odin b/core/math/linalg/extended.odin index 9dee12eb9..22368b70c 100644 --- a/core/math/linalg/extended.odin +++ b/core/math/linalg/extended.odin @@ -3,20 +3,21 @@ package linalg import "core:builtin" import "core:math" -radians :: proc(degrees: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { +to_radians :: proc(degrees: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { + +to_degrees :: proc(radians: $T) -> (out: T) where IS_NUMERIC(ELEM_TYPE(T)) { when IS_ARRAY(T) { for i in 0.. Date: Sun, 30 Apr 2023 16:56:05 -0700 Subject: [PATCH 23/29] update docs, add unsafe_get/set, add round up to create --- core/container/bit_array/bit_array.odin | 192 ++++++++++++++++-------- 1 file changed, 129 insertions(+), 63 deletions(-) diff --git a/core/container/bit_array/bit_array.odin b/core/container/bit_array/bit_array.odin index 763a19f8b..2ff670429 100644 --- a/core/container/bit_array/bit_array.odin +++ b/core/container/bit_array/bit_array.odin @@ -27,27 +27,28 @@ Bit_Array_Iterator :: struct { word_idx: int, bit_idx: uint, } - /* - In: - - ba: ^Bit_Array - the array to iterate over +Wraps a `Bit_Array` into an Iterator - Out: - - it: ^Bit_Array_Iterator - the iterator that holds iteration state +Inputs: +- ba: Pointer to the Bit_Array + +Returns: +- it: Iterator struct */ make_iterator :: proc (ba: ^Bit_Array) -> (it: Bit_Array_Iterator) { return Bit_Array_Iterator { array = ba } } - /* - In: - - it: ^Bit_Array_Iterator - the iterator struct that holds the state. +Returns the next bit,including its set-state. ok=false once exhausted - Out: - - set: bool - the state of the bit at `index` - - index: int - the next bit of the Bit_Array referenced by `it`. - - ok: bool - `true` if the iterator returned a valid index, - `false` if there were no more bits +Inputs: +- it: The iterator that holds the state. + +Returns: +- set: `true` if the bit at `index` is set. +- index: The next bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done */ iterate_by_all :: proc (it: ^Bit_Array_Iterator) -> (set: bool, index: int, ok: bool) { index = it.word_idx * NUM_BITS + int(it.bit_idx) + it.array.bias @@ -64,39 +65,51 @@ iterate_by_all :: proc (it: ^Bit_Array_Iterator) -> (set: bool, index: int, ok: return set, index, true } - /* - In: - - it: ^Bit_Array_Iterator - the iterator struct that holds the state. +Returns the next Set Bit, for example if `0b1010`, then the iterator will return index={1,3} over two calls. - Out: - - index: int - the next set bit of the Bit_Array referenced by `it`. - - ok: bool - `true` if the iterator returned a valid index, - `false` if there were no more bits set +Inputs: +- it: The iterator that holds the state. + +Returns: +- index: The next *set* bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done */ iterate_by_set :: proc (it: ^Bit_Array_Iterator) -> (index: int, ok: bool) { return iterate_internal_(it, true) } - /* - In: - - it: ^Bit_Array_Iterator - the iterator struct that holds the state. +Returns the next Unset Bit, for example if `0b1010`, then the iterator will return index={0,2} over two calls. - Out: - - index: int - the next unset bit of the Bit_Array referenced by `it`. - - ok: bool - `true` if the iterator returned a valid index, - `false` if there were no more unset bits +Inputs: +- it: The iterator that holds the state. + +Returns: +- index: The next *unset* bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done */ iterate_by_unset:: proc (it: ^Bit_Array_Iterator) -> (index: int, ok: bool) { return iterate_internal_(it, false) } +/* +Iterates through set/unset bits +*Private* + +Inputs: +- it: The iterator that holds the state. +- ITERATE_SET_BITS: `true` for returning only set bits, false for returning only unset bits + +Returns: +- index: The next *unset* bit of the Bit_Array referenced by `it`. +- ok: `true` if the iterator can continue, `false` if the iterator is done +*/ @(private="file") iterate_internal_ :: proc (it: ^Bit_Array_Iterator, $ITERATE_SET_BITS: bool) -> (index: int, ok: bool) { word := it.array.bits[it.word_idx] if len(it.array.bits) > it.word_idx else 0 when ! ITERATE_SET_BITS { word = ~word } - // if the word is empty or we have already gone over all the bits in it, + // If the word is empty or we have already gone over all the bits in it, // b.bit_idx is greater than the index of any set bit in the word, // meaning that word >> b.bit_idx == 0. for it.word_idx < len(it.array.bits) && word >> it.bit_idx == 0 { @@ -106,14 +119,14 @@ iterate_internal_ :: proc (it: ^Bit_Array_Iterator, $ITERATE_SET_BITS: bool) -> when ! ITERATE_SET_BITS { word = ~word } } - // if we are iterating the set bits, reaching the end of the array means we have no more bits to check + // If we are iterating the set bits, reaching the end of the array means we have no more bits to check when ITERATE_SET_BITS { if it.word_idx >= len(it.array.bits) { return 0, false } } - // reaching here means that the word has some set bits + // Reaching here means that the word has some set bits it.bit_idx += uint(intrinsics.count_trailing_zeros(word >> it.bit_idx)) index = it.word_idx * NUM_BITS + int(it.bit_idx) + it.array.bias @@ -124,24 +137,21 @@ iterate_internal_ :: proc (it: ^Bit_Array_Iterator, $ITERATE_SET_BITS: bool) -> } return index, index <= it.array.max_index } - - /* - In: - - ba: ^Bit_Array - a pointer to the Bit Array - - index: The bit index. Can be an enum member. +Gets the state of a bit in the bit-array - Out: - - res: The bit you're interested in. - - ok: Whether the index was valid. Returns `false` if the index is smaller than the bias. +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array - The `ok` return value may be ignored. +Returns: +- res: `true` if the bit at `index` is set. +- ok: Whether the index was valid. Returns `false` if the index is smaller than the bias. */ -get :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (res: bool, ok: bool) { +get :: proc(ba: ^Bit_Array, #any_int index: uint) -> (res: bool, ok: bool) #optional_ok { idx := int(index) - ba.bias if ba == nil || int(index) < ba.bias { return false, false } - context.allocator = allocator leg_index := idx >> INDEX_SHIFT bit_index := idx & INDEX_MASK @@ -157,16 +167,33 @@ get :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator return res, true } - /* - In: - - ba: ^Bit_Array - a pointer to the Bit Array - - index: The bit index. Can be an enum member. +Gets the state of a bit in the bit-array - Out: - - ok: Whether or not we managed to set requested bit. +*Bypasses all Checks* - `set` automatically resizes the Bit Array to accommodate the requested index if needed. +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array + +Returns: +- `true` if bit is set +*/ +unsafe_get :: #force_inline proc(ba: ^Bit_Array, #any_int index: uint) -> bool #no_bounds_check { + return bool((ba.bits[index >> INDEX_SHIFT] >> uint(index & INDEX_MASK)) & 1) +} +/* +Sets the state of a bit in the bit-array + +*Conditionally Allocates (Resizes backing data when `index > len(ba.bits)`)* + +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array +- allocator: (default is context.allocator) + +Returns: +- ok: Whether the set was successful, `false` on allocation failure or bad index */ set :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { @@ -184,16 +211,30 @@ set :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator ba.bits[leg_index] |= 1 << uint(bit_index) return true } - /* - In: - - ba: ^Bit_Array - a pointer to the Bit Array - - index: The bit index. Can be an enum member. +Sets the state of a bit in the bit-array - Out: - - ok: Whether or not we managed to unset requested bit. +*Bypasses all checks* - `unset` automatically resizes the Bit Array to accommodate the requested index if needed. +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array +*/ +unsafe_set :: proc(ba: ^Bit_Array, bit: int) #no_bounds_check { + ba.bits[bit >> INDEX_SHIFT] |= 1 << uint(bit & INDEX_MASK) +} +/* +Unsets the state of a bit in the bit-array + +*Conditionally Allocates (Resizes backing data when `index > len(ba.bits)`)* + +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array +- allocator: (default is context.allocator) + +Returns: +- ok: Whether the unset was successful, `false` on allocation failure or bad index */ unset :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { @@ -211,17 +252,39 @@ unset :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocat ba.bits[leg_index] &= ~(1 << uint(bit_index)) return true } - /* - A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative). +Unsets the state of a bit in the bit-array + +*Bypasses all Checks* + +Inputs: +- ba: Pointer to the Bit_Array +- index: Which bit in the array */ -create :: proc(max_index: int, min_index := 0, allocator := context.allocator) -> (res: ^Bit_Array, ok: bool) #optional_ok { +unsafe_unset :: proc(b: ^Bit_Array, bit: int) #no_bounds_check { + b.bits[bit >> INDEX_SHIFT] &= ~(1 << uint(bit & INDEX_MASK)) +} +/* +A helper function to create a Bit Array with optional bias, in case your smallest index is non-zero (including negative). + +*Allocates (`new(Bit_Array) & make(ba.bits)`)* + +Inputs: +- max_index: maximum starting index +- min_index: minimum starting index (used as a bias) +- allocator: (default is context.allocator) + +Returns: +- ba: Allocates a bit_Array, backing data is set to `max-min / 64` indices, rounded up (eg 65 - 0 allocates for [2]u64). +*/ +create :: proc(max_index: int, min_index: int = 0, allocator := context.allocator) -> (res: ^Bit_Array, ok: bool) #optional_ok { context.allocator = allocator size_in_bits := max_index - min_index if size_in_bits < 1 { return {}, false } legs := size_in_bits >> INDEX_SHIFT + if size_in_bits & INDEX_MASK > 0 {legs+=1} res = new(Bit_Array) res.bias = min_index @@ -229,17 +292,21 @@ create :: proc(max_index: int, min_index := 0, allocator := context.allocator) - res.free_pointer = true return res, resize_if_needed(res, legs) } - /* - Sets all bits to `false`. +Sets all values in the Bit_Array to zero. + +Inputs: +- ba: The target Bit_Array */ clear :: proc(ba: ^Bit_Array) { if ba == nil { return } mem.zero_slice(ba.bits[:]) } - /* - Releases the memory used by the Bit Array. +Deallocates the Bit_Array and its backing storage + +Inputs: +- ba: The target Bit_Array */ destroy :: proc(ba: ^Bit_Array) { if ba == nil { return } @@ -248,7 +315,6 @@ destroy :: proc(ba: ^Bit_Array) { free(ba) } } - /* Resizes the Bit Array. For internal use. If you want to reserve the memory for a given-sized Bit Array up front, you can use `create`. From f8bdd42027835b26ed648aa5932faa131fe6da9d Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 2 May 2023 12:06:41 +0100 Subject: [PATCH 24/29] Revert "Unify `foreign import` for `vendor:sdl2`" This reverts commit b2b88f1d99c497f152485869b3f155b965e813bc. --- vendor/sdl2/sdl2.odin | 7 +++---- vendor/sdl2/sdl_audio.odin | 6 ++++++ vendor/sdl2/sdl_blendmode.odin | 6 ++++++ vendor/sdl2/sdl_cpuinfo.odin | 6 ++++++ vendor/sdl2/sdl_events.odin | 6 ++++++ vendor/sdl2/sdl_gamecontroller.odin | 6 ++++++ vendor/sdl2/sdl_gesture_haptic.odin | 6 ++++++ vendor/sdl2/sdl_hints.odin | 6 ++++++ vendor/sdl2/sdl_joystick.odin | 6 ++++++ vendor/sdl2/sdl_keyboard.odin | 6 ++++++ vendor/sdl2/sdl_keycode.odin | 1 + vendor/sdl2/sdl_log.odin | 6 ++++++ vendor/sdl2/sdl_messagebox.odin | 6 ++++++ vendor/sdl2/sdl_metal.odin | 6 ++++++ vendor/sdl2/sdl_mouse.odin | 6 ++++++ vendor/sdl2/sdl_mutex.odin | 6 ++++++ vendor/sdl2/sdl_pixels.odin | 6 ++++++ vendor/sdl2/sdl_rect.odin | 6 ++++++ vendor/sdl2/sdl_render.odin | 6 ++++++ vendor/sdl2/sdl_rwops.odin | 6 ++++++ vendor/sdl2/sdl_stdinc.odin | 6 ++++++ vendor/sdl2/sdl_surface.odin | 6 ++++++ vendor/sdl2/sdl_system.odin | 6 ++++++ vendor/sdl2/sdl_syswm.odin | 6 ++++++ vendor/sdl2/sdl_thread.odin | 6 ++++++ vendor/sdl2/sdl_timer.odin | 6 ++++++ vendor/sdl2/sdl_touch.odin | 6 ++++++ vendor/sdl2/sdl_video.odin | 6 ++++++ vendor/sdl2/sdl_vulkan.odin | 6 ++++++ 29 files changed, 166 insertions(+), 4 deletions(-) diff --git a/vendor/sdl2/sdl2.odin b/vendor/sdl2/sdl2.odin index b3abce483..adf6dbd49 100644 --- a/vendor/sdl2/sdl2.odin +++ b/vendor/sdl2/sdl2.odin @@ -26,13 +26,11 @@ import "core:c" import "core:intrinsics" when ODIN_OS == .Windows { - foreign import _lib "SDL2.lib" + foreign import lib "SDL2.lib" } else { - foreign import _lib "system:SDL2" + foreign import lib "system:SDL2" } -lib :: _lib - version :: struct { major: u8, /**< major version */ minor: u8, /**< minor version */ @@ -47,6 +45,7 @@ PATCHLEVEL :: 16 foreign lib { GetVersion :: proc(ver: ^version) --- GetRevision :: proc() -> cstring --- + } InitFlag :: enum u32 { diff --git a/vendor/sdl2/sdl_audio.odin b/vendor/sdl2/sdl_audio.odin index 914adc0df..28a59d947 100644 --- a/vendor/sdl2/sdl_audio.odin +++ b/vendor/sdl2/sdl_audio.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + /** * \brief Audio format flags. * diff --git a/vendor/sdl2/sdl_blendmode.odin b/vendor/sdl2/sdl_blendmode.odin index 07aab1dec..4fde5111b 100644 --- a/vendor/sdl2/sdl_blendmode.odin +++ b/vendor/sdl2/sdl_blendmode.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + /** * \brief The blend mode used in SDL_RenderCopy() and drawing operations. */ diff --git a/vendor/sdl2/sdl_cpuinfo.odin b/vendor/sdl2/sdl_cpuinfo.odin index 4987bd092..c5175e4d5 100644 --- a/vendor/sdl2/sdl_cpuinfo.odin +++ b/vendor/sdl2/sdl_cpuinfo.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + /* This is a guess for the cacheline size used for padding. * Most x86 processors have a 64 byte cache line. * The 64-bit PowerPC processors have a 128 byte cache line. diff --git a/vendor/sdl2/sdl_events.odin b/vendor/sdl2/sdl_events.odin index 8710c4765..60daaea56 100644 --- a/vendor/sdl2/sdl_events.odin +++ b/vendor/sdl2/sdl_events.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + RELEASED :: 0 PRESSED :: 1 diff --git a/vendor/sdl2/sdl_gamecontroller.odin b/vendor/sdl2/sdl_gamecontroller.odin index 497da0836..8772faa26 100644 --- a/vendor/sdl2/sdl_gamecontroller.odin +++ b/vendor/sdl2/sdl_gamecontroller.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + GameController :: struct {} GameControllerType :: enum c.int { diff --git a/vendor/sdl2/sdl_gesture_haptic.odin b/vendor/sdl2/sdl_gesture_haptic.odin index 92b9d83d4..a21e0df06 100644 --- a/vendor/sdl2/sdl_gesture_haptic.odin +++ b/vendor/sdl2/sdl_gesture_haptic.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + // Gesture GestureID :: distinct i64 diff --git a/vendor/sdl2/sdl_hints.odin b/vendor/sdl2/sdl_hints.odin index 57b264c00..913d4ea12 100644 --- a/vendor/sdl2/sdl_hints.odin +++ b/vendor/sdl2/sdl_hints.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + HINT_ACCELEROMETER_AS_JOYSTICK :: "SDL_ACCELEROMETER_AS_JOYSTICK" HINT_ALLOW_ALT_TAB_WHILE_GRABBED :: "SDL_ALLOW_ALT_TAB_WHILE_GRABBED" HINT_ALLOW_TOPMOST :: "SDL_ALLOW_TOPMOST" diff --git a/vendor/sdl2/sdl_joystick.odin b/vendor/sdl2/sdl_joystick.odin index d0d1d62a3..35ca5cdcc 100644 --- a/vendor/sdl2/sdl_joystick.odin +++ b/vendor/sdl2/sdl_joystick.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + Joystick :: struct {} JoystickGUID :: struct { diff --git a/vendor/sdl2/sdl_keyboard.odin b/vendor/sdl2/sdl_keyboard.odin index 077d5f102..f880286aa 100644 --- a/vendor/sdl2/sdl_keyboard.odin +++ b/vendor/sdl2/sdl_keyboard.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + Keysym :: struct { scancode: Scancode, /**< SDL physical key code - see ::SDL_Scancode for details */ sym: Keycode, /**< SDL virtual key code - see ::SDL_Keycode for details */ diff --git a/vendor/sdl2/sdl_keycode.odin b/vendor/sdl2/sdl_keycode.odin index 466d8c2a6..c03fdc2a9 100644 --- a/vendor/sdl2/sdl_keycode.odin +++ b/vendor/sdl2/sdl_keycode.odin @@ -1,5 +1,6 @@ package sdl2 + SCANCODE_MASK :: 1<<30 SCANCODE_TO_KEYCODE :: #force_inline proc "c" (X: Scancode) -> Keycode { return Keycode(i32(X) | SCANCODE_MASK) diff --git a/vendor/sdl2/sdl_log.odin b/vendor/sdl2/sdl_log.odin index a1db184c9..09b7eaef0 100644 --- a/vendor/sdl2/sdl_log.odin +++ b/vendor/sdl2/sdl_log.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + MAX_LOG_MESSAGE :: 4096 LogCategory :: enum c.int { diff --git a/vendor/sdl2/sdl_messagebox.odin b/vendor/sdl2/sdl_messagebox.odin index 2c8e8da48..6228704ac 100644 --- a/vendor/sdl2/sdl_messagebox.odin +++ b/vendor/sdl2/sdl_messagebox.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + MessageBoxFlag :: enum u32 { _ = 0, ERROR = 4, /**< error dialog */ diff --git a/vendor/sdl2/sdl_metal.odin b/vendor/sdl2/sdl_metal.odin index ca7bd91d2..1eccf7f5a 100644 --- a/vendor/sdl2/sdl_metal.odin +++ b/vendor/sdl2/sdl_metal.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + MetalView :: distinct rawptr @(default_calling_convention="c", link_prefix="SDL_") diff --git a/vendor/sdl2/sdl_mouse.odin b/vendor/sdl2/sdl_mouse.odin index a612a15a1..0243b6623 100644 --- a/vendor/sdl2/sdl_mouse.odin +++ b/vendor/sdl2/sdl_mouse.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + Cursor :: struct {} BUTTON :: #force_inline proc "c" (X: c.int) -> c.int { return 1 << u32(X-1) } diff --git a/vendor/sdl2/sdl_mutex.odin b/vendor/sdl2/sdl_mutex.odin index 54d8fc671..1fd5849e0 100644 --- a/vendor/sdl2/sdl_mutex.odin +++ b/vendor/sdl2/sdl_mutex.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + MUTEX_TIMEDOUT :: 1 MUTEX_MAXWAIT :: ~u32(0) diff --git a/vendor/sdl2/sdl_pixels.odin b/vendor/sdl2/sdl_pixels.odin index d526e86ba..8ee06aa1a 100644 --- a/vendor/sdl2/sdl_pixels.odin +++ b/vendor/sdl2/sdl_pixels.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + ALPHA_OPAQUE :: 255 ALPHA_TRANSPARENT :: 0 diff --git a/vendor/sdl2/sdl_rect.odin b/vendor/sdl2/sdl_rect.odin index de6a0848f..852309cd2 100644 --- a/vendor/sdl2/sdl_rect.odin +++ b/vendor/sdl2/sdl_rect.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + Point :: struct { x: c.int, y: c.int, diff --git a/vendor/sdl2/sdl_render.odin b/vendor/sdl2/sdl_render.odin index a7b90e61a..f948b39b0 100644 --- a/vendor/sdl2/sdl_render.odin +++ b/vendor/sdl2/sdl_render.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + RendererFlag :: enum u32 { SOFTWARE = 0, /**< The renderer is a software fallback */ ACCELERATED = 1, /**< The renderer uses hardware acceleration */ diff --git a/vendor/sdl2/sdl_rwops.odin b/vendor/sdl2/sdl_rwops.odin index 7add9b2f0..86fb23c75 100644 --- a/vendor/sdl2/sdl_rwops.odin +++ b/vendor/sdl2/sdl_rwops.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + /* RWops Types */ RWOPS_UNKNOWN :: 0 /**< Unknown stream type */ RWOPS_WINFILE :: 1 /**< Win32 file */ diff --git a/vendor/sdl2/sdl_stdinc.odin b/vendor/sdl2/sdl_stdinc.odin index 178007919..97722f4fe 100644 --- a/vendor/sdl2/sdl_stdinc.odin +++ b/vendor/sdl2/sdl_stdinc.odin @@ -5,6 +5,12 @@ import "core:intrinsics" import "core:runtime" _, _ :: intrinsics, runtime +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + bool :: distinct b32 #assert(size_of(bool) == size_of(c.int)) diff --git a/vendor/sdl2/sdl_surface.odin b/vendor/sdl2/sdl_surface.odin index a36131a42..f50de35f7 100644 --- a/vendor/sdl2/sdl_surface.odin +++ b/vendor/sdl2/sdl_surface.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + SWSURFACE :: 0 /**< Just here for compatibility */ PREALLOC :: 0x00000001 /**< Surface uses preallocated memory */ RLEACCEL :: 0x00000002 /**< Surface is RLE encoded */ diff --git a/vendor/sdl2/sdl_system.odin b/vendor/sdl2/sdl_system.odin index b8787624e..d9b6b98df 100644 --- a/vendor/sdl2/sdl_system.odin +++ b/vendor/sdl2/sdl_system.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + // General @(default_calling_convention="c", link_prefix="SDL_") foreign lib { diff --git a/vendor/sdl2/sdl_syswm.odin b/vendor/sdl2/sdl_syswm.odin index 5dc50c394..62ca9d628 100644 --- a/vendor/sdl2/sdl_syswm.odin +++ b/vendor/sdl2/sdl_syswm.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + SYSWM_TYPE :: enum c.int { UNKNOWN, WINDOWS, diff --git a/vendor/sdl2/sdl_thread.odin b/vendor/sdl2/sdl_thread.odin index 8acc71849..5d1c0bd37 100644 --- a/vendor/sdl2/sdl_thread.odin +++ b/vendor/sdl2/sdl_thread.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + Thread :: struct {} threadID :: distinct c.ulong diff --git a/vendor/sdl2/sdl_timer.odin b/vendor/sdl2/sdl_timer.odin index 6b19a6c13..d71ed2da5 100644 --- a/vendor/sdl2/sdl_timer.odin +++ b/vendor/sdl2/sdl_timer.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + TimerCallback :: proc "c" (interval: u32, param: rawptr) -> u32 TimerID :: distinct c.int diff --git a/vendor/sdl2/sdl_touch.odin b/vendor/sdl2/sdl_touch.odin index 3ba59b651..f2a8cc695 100644 --- a/vendor/sdl2/sdl_touch.odin +++ b/vendor/sdl2/sdl_touch.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + TouchID :: distinct i64 FingerID :: distinct i64 diff --git a/vendor/sdl2/sdl_video.odin b/vendor/sdl2/sdl_video.odin index 6f4deaf3f..86b564541 100644 --- a/vendor/sdl2/sdl_video.odin +++ b/vendor/sdl2/sdl_video.odin @@ -2,6 +2,12 @@ package sdl2 import "core:c" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + DisplayMode :: struct { format: u32, /**< pixel format */ w: c.int, /**< width, in screen coordinates */ diff --git a/vendor/sdl2/sdl_vulkan.odin b/vendor/sdl2/sdl_vulkan.odin index 2258682c0..33bb8e51c 100644 --- a/vendor/sdl2/sdl_vulkan.odin +++ b/vendor/sdl2/sdl_vulkan.odin @@ -3,6 +3,12 @@ package sdl2 import "core:c" import vk "vendor:vulkan" +when ODIN_OS == .Windows { + foreign import lib "SDL2.lib" +} else { + foreign import lib "system:SDL2" +} + VkInstance :: vk.Instance VkSurfaceKHR :: vk.SurfaceKHR From e1654e9dd39f9003b2c06e51fd502857f9d20514 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Tue, 2 May 2023 14:16:07 +0200 Subject: [PATCH 25/29] Don't test Botan on MacOS for now Homebrew decided to update the formula for Botan to support version 3.0 of the package only. Until we update the bindings and the Windows library to match, we can't test on Mac. --- .github/workflows/ci.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5fb98fca4..1a6fa65bb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,9 +56,9 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v1 - - name: Download LLVM, botan and setup PATH + - name: Download LLVM and setup PATH run: | - brew install llvm@11 botan + brew install llvm@11 echo "/usr/local/opt/llvm@11/bin" >> $GITHUB_PATH TMP_PATH=$(xcrun --show-sdk-path)/user/include echo "CPATH=$TMP_PATH" >> $GITHUB_ENV @@ -87,11 +87,6 @@ jobs: cd tests/core make timeout-minutes: 10 - - name: Vendor library tests - run: | - cd tests/vendor - make - timeout-minutes: 10 - name: Odin internals tests run: | cd tests/internal From fda1e4409c0e2ce5311bd37888171b948df985fd Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 2 May 2023 14:44:56 +0100 Subject: [PATCH 26/29] When using `-debug`, default to `-o:none` unless explicitly specified --- src/build_settings.cpp | 10 +++++++--- src/main.cpp | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/build_settings.cpp b/src/build_settings.cpp index ac033df71..78b1bd6c4 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -262,6 +262,7 @@ struct BuildContext { String microarch; BuildModeKind build_mode; bool generate_docs; + bool custom_optimization_level; i32 optimization_level; bool show_timings; TimingsExportFormat export_timings_format; @@ -1272,6 +1273,12 @@ gb_internal void init_build_context(TargetMetrics *cross_target) { gb_exit(1); } + if (bc->ODIN_DEBUG && !bc->custom_optimization_level) { + // NOTE(bill): when building with `-debug` but not specifying an optimization level + // default to `-o:none` to improve the debug symbol generation by default + bc->optimization_level = -1; // -o:none + } + bc->optimization_level = gb_clamp(bc->optimization_level, -1, 2); // ENFORCE DYNAMIC MAP CALLS @@ -1285,9 +1292,6 @@ gb_internal void init_build_context(TargetMetrics *cross_target) { break; } } - - #undef LINK_FLAG_X64 - #undef LINK_FLAG_386 } #if defined(GB_SYSTEM_WINDOWS) diff --git a/src/main.cpp b/src/main.cpp index 33ee65c6b..162cd309e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1035,12 +1035,16 @@ gb_internal bool parse_build_flags(Array args) { case BuildFlag_OptimizationMode: { GB_ASSERT(value.kind == ExactValue_String); if (value.value_string == "none") { + build_context.custom_optimization_level = true; build_context.optimization_level = -1; } else if (value.value_string == "minimal") { + build_context.custom_optimization_level = true; build_context.optimization_level = 0; } else if (value.value_string == "size") { + build_context.custom_optimization_level = true; build_context.optimization_level = 1; } else if (value.value_string == "speed") { + build_context.custom_optimization_level = true; build_context.optimization_level = 2; } else { gb_printf_err("Invalid optimization mode for -o:, got %.*s\n", LIT(value.value_string)); From 02eab95dd126b873385c112b4946848f17befcd9 Mon Sep 17 00:00:00 2001 From: Clay Murray Date: Tue, 2 May 2023 14:14:24 -0600 Subject: [PATCH 27/29] Fix check for continuation byte in core/text/text_edit --- core/text/edit/text_edit.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/text/edit/text_edit.odin b/core/text/edit/text_edit.odin index b53e2f8bc..c49a5d0d1 100644 --- a/core/text/edit/text_edit.odin +++ b/core/text/edit/text_edit.odin @@ -219,7 +219,7 @@ selection_delete :: proc(s: ^State) { translate_position :: proc(s: ^State, pos: int, t: Translation) -> int { is_continuation_byte :: proc(b: byte) -> bool { - return b <= 0x80 && b < 0xc0 + return b >= 0x80 && b < 0xc0 } is_space :: proc(b: byte) -> bool { return b == ' ' || b == '\t' || b == '\n' @@ -410,4 +410,4 @@ perform_command :: proc(s: ^State, cmd: Command) { case .Select_Line_Start: select_to(s, .Soft_Line_Start) case .Select_Line_End: select_to(s, .Soft_Line_End) } -} \ No newline at end of file +} From bcb01bdc520c366c8f961c9b4707fa0533264a95 Mon Sep 17 00:00:00 2001 From: Jon Lipstate Date: Tue, 2 May 2023 18:21:52 -0700 Subject: [PATCH 28/29] added set overload, made make explicit --- core/container/bit_array/bit_array.odin | 41 ++++++++++--------------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/core/container/bit_array/bit_array.odin b/core/container/bit_array/bit_array.odin index 2ff670429..d649d039f 100644 --- a/core/container/bit_array/bit_array.odin +++ b/core/container/bit_array/bit_array.odin @@ -40,7 +40,7 @@ make_iterator :: proc (ba: ^Bit_Array) -> (it: Bit_Array_Iterator) { return Bit_Array_Iterator { array = ba } } /* -Returns the next bit,including its set-state. ok=false once exhausted +Returns the next bit, including its set-state. ok=false once exhausted Inputs: - it: The iterator that holds the state. @@ -66,7 +66,7 @@ iterate_by_all :: proc (it: ^Bit_Array_Iterator) -> (set: bool, index: int, ok: return set, index, true } /* -Returns the next Set Bit, for example if `0b1010`, then the iterator will return index={1,3} over two calls. +Returns the next Set Bit, for example if `0b1010`, then the iterator will return index={1, 3} over two calls. Inputs: - it: The iterator that holds the state. @@ -79,7 +79,7 @@ iterate_by_set :: proc (it: ^Bit_Array_Iterator) -> (index: int, ok: bool) { return iterate_internal_(it, true) } /* -Returns the next Unset Bit, for example if `0b1010`, then the iterator will return index={0,2} over two calls. +Returns the next Unset Bit, for example if `0b1010`, then the iterator will return index={0, 2} over two calls. Inputs: - it: The iterator that holds the state. @@ -190,12 +190,13 @@ Sets the state of a bit in the bit-array Inputs: - ba: Pointer to the Bit_Array - index: Which bit in the array +- set_to: `true` sets the bit on, `false` to turn it off - allocator: (default is context.allocator) Returns: - ok: Whether the set was successful, `false` on allocation failure or bad index */ -set :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { +set :: proc(ba: ^Bit_Array, #any_int index: uint, set_to: bool = true, allocator := context.allocator) -> (ok: bool) { idx := int(index) - ba.bias @@ -208,7 +209,10 @@ set :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator resize_if_needed(ba, leg_index) or_return ba.max_index = max(idx, ba.max_index) - ba.bits[leg_index] |= 1 << uint(bit_index) + + if set_to{ ba.bits[leg_index] |= 1 << uint(bit_index) } + else { ba.bits[leg_index] &= ~(1 << uint(bit_index)) } + return true } /* @@ -224,7 +228,7 @@ unsafe_set :: proc(ba: ^Bit_Array, bit: int) #no_bounds_check { ba.bits[bit >> INDEX_SHIFT] |= 1 << uint(bit & INDEX_MASK) } /* -Unsets the state of a bit in the bit-array +Unsets the state of a bit in the bit-array. (Convienence wrapper for `set`) *Conditionally Allocates (Resizes backing data when `index > len(ba.bits)`)* @@ -236,21 +240,8 @@ Inputs: Returns: - ok: Whether the unset was successful, `false` on allocation failure or bad index */ -unset :: proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { - - idx := int(index) - ba.bias - - if ba == nil || int(index) < ba.bias { return false } - context.allocator = allocator - - leg_index := idx >> INDEX_SHIFT - bit_index := idx & INDEX_MASK - - resize_if_needed(ba, leg_index) or_return - - ba.max_index = max(idx, ba.max_index) - ba.bits[leg_index] &= ~(1 << uint(bit_index)) - return true +unset :: #force_inline proc(ba: ^Bit_Array, #any_int index: uint, allocator := context.allocator) -> (ok: bool) { + return set(ba, index, false, allocator) } /* Unsets the state of a bit in the bit-array @@ -285,12 +276,14 @@ create :: proc(max_index: int, min_index: int = 0, allocator := context.allocato legs := size_in_bits >> INDEX_SHIFT if size_in_bits & INDEX_MASK > 0 {legs+=1} - + bits, err := make([dynamic]u64, legs) + ok = err == mem.Allocator_Error.None res = new(Bit_Array) + res.bits = bits res.bias = min_index res.max_index = max_index res.free_pointer = true - return res, resize_if_needed(res, legs) + return } /* Sets all values in the Bit_Array to zero. @@ -316,7 +309,7 @@ destroy :: proc(ba: ^Bit_Array) { } } /* - Resizes the Bit Array. For internal use. + Resizes the Bit Array. For internal use. Provisions needed capacity+1 If you want to reserve the memory for a given-sized Bit Array up front, you can use `create`. */ @(private="file") From 0c3522133d60870e123b7d0e2aacb15c38e377f8 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 3 May 2023 14:22:38 +0100 Subject: [PATCH 29/29] Fix indentation --- core/strings/strings.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/strings/strings.odin b/core/strings/strings.odin index d9387c93e..6daa5f9c9 100644 --- a/core/strings/strings.odin +++ b/core/strings/strings.odin @@ -41,7 +41,7 @@ Returns: */ @(deprecated="Prefer clone. It now returns an optional allocator error") clone_safe :: proc(s: string, allocator := context.allocator, loc := #caller_location) -> (res: string, err: mem.Allocator_Error) { - return clone(s, allocator, loc) + return clone(s, allocator, loc) } /* Clones a string and appends a null-byte to make it a cstring @@ -629,7 +629,7 @@ Returns: */ @(deprecated="Prefer join. It now returns an optional allocator error") join_safe :: proc(a: []string, sep: string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) { - return join(a, sep, allocator) + return join(a, sep, allocator) } /* Returns a combined string from the slice of strings `a` without a separator @@ -689,7 +689,7 @@ The concatenated string, and an error if allocation fails */ @(deprecated="Prefer concatenate. It now returns an optional allocator error") concatenate_safe :: proc(a: []string, allocator := context.allocator) -> (res: string, err: mem.Allocator_Error) { - return concatenate(a, allocator) + return concatenate(a, allocator) } /* Returns a substring of the input string `s` with the specified rune offset and length