diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2026-02-18 12:15:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-02-18 12:15:24 +0100 |
| commit | 06a56c5eddd577a4f7d74e3f34beb3f4e72375e8 (patch) | |
| tree | a304837360db4d4ae8951037a3736bb5420e4943 | |
| parent | 53c6c8a556c454f364739fcc8ce98275fefb2556 (diff) | |
| parent | 73a62f672a0683828e82f2cedbaa1fd9b17ffdd1 (diff) | |
Merge pull request #6300 from jakubtomsu/more-import-cleanup
More import cleanup and simplification
| -rw-r--r-- | core/hash/crc32.odin | 2 | ||||
| -rw-r--r-- | core/hash/hash.odin | 9 | ||||
| -rw-r--r-- | core/math/rand/rand_xoshiro256.odin | 12 | ||||
| -rw-r--r-- | core/net/dns.odin | 6 | ||||
| -rw-r--r-- | vendor/directx/d3d11/d3d11.odin | 34 | ||||
| -rw-r--r-- | vendor/directx/d3d12/d3d12.odin | 12 | ||||
| -rw-r--r-- | vendor/directx/d3d_common/d3d_common.odin | 25 | ||||
| -rw-r--r-- | vendor/directx/d3d_compiler/d3d_compiler.odin | 58 | ||||
| -rw-r--r-- | vendor/directx/dxc/dxcapi.odin | 5 | ||||
| -rw-r--r-- | vendor/directx/dxgi/dxgi.odin | 1 | ||||
| -rw-r--r-- | vendor/miniaudio/logging.odin | 6 |
11 files changed, 88 insertions, 82 deletions
diff --git a/core/hash/crc32.odin b/core/hash/crc32.odin index 0a4617f6d..777209bed 100644 --- a/core/hash/crc32.odin +++ b/core/hash/crc32.odin @@ -1,7 +1,5 @@ package hash -import "base:intrinsics" - @(optimization_mode="favor_size") crc32 :: proc "contextless" (data: []byte, seed := u32(0)) -> u32 #no_bounds_check { crc := ~seed diff --git a/core/hash/hash.odin b/core/hash/hash.odin index 6c048c05b..b495fd30d 100644 --- a/core/hash/hash.odin +++ b/core/hash/hash.odin @@ -1,7 +1,6 @@ package hash import "core:mem" -import "base:intrinsics" @(optimization_mode="favor_size") adler32 :: proc "contextless" (data: []byte, seed := u32(1)) -> u32 #no_bounds_check { @@ -57,14 +56,14 @@ djb2 :: proc "contextless" (data: []byte, seed := u32(5381)) -> u32 { djbx33a :: proc "contextless" (data: []byte, seed := u32(5381)) -> (result: [16]byte) #no_bounds_check { state := [4]u32{seed, seed, seed, seed} - + s: u32 = 0 for p in data { state[s] = (state[s] << 5) + state[s] + u32(p) // hash * 33 + u32(b) s = (s + 1) & 3 } - - + + (^u32le)(&result[0])^ = u32le(state[0]) (^u32le)(&result[4])^ = u32le(state[1]) (^u32le)(&result[8])^ = u32le(state[2]) @@ -160,7 +159,7 @@ murmur32 :: proc "contextless" (data: []byte, seed := u32(0x9747b28c)) -> u32 { case 1: k1 ~= u32(tail[0]) k1 *= c1_32 - k1 = (k1 << 15) | (k1 >> 17) + k1 = (k1 << 15) | (k1 >> 17) k1 *= c2_32 h1 ~= k1 } diff --git a/core/math/rand/rand_xoshiro256.odin b/core/math/rand/rand_xoshiro256.odin index 7326ba8d5..6f5dbe545 100644 --- a/core/math/rand/rand_xoshiro256.odin +++ b/core/math/rand/rand_xoshiro256.odin @@ -3,8 +3,6 @@ package rand import "base:intrinsics" import "base:runtime" -import "core:math/bits" - /* The state for a xoshiro256** pseudorandom generator. */ @@ -17,7 +15,7 @@ xoshiro256_random_generator_proc :: proc(data: rawptr, mode: runtime.Random_Gene read_u64 :: proc "contextless" (r: ^Xoshiro256_Random_State) -> u64 { // xoshiro256** output function and state transition - result := bits.rotate_left64(r.s[1] * 5, 7) * 9 + result := rotate_left64(r.s[1] * 5, 7) * 9 t := r.s[1] << 17 r.s[2] = r.s[2] ~ r.s[0] @@ -25,9 +23,15 @@ xoshiro256_random_generator_proc :: proc(data: rawptr, mode: runtime.Random_Gene r.s[1] = r.s[1] ~ r.s[2] r.s[0] = r.s[0] ~ r.s[3] r.s[2] = r.s[2] ~ t - r.s[3] = bits.rotate_left64(r.s[3], 45) + r.s[3] = rotate_left64(r.s[3], 45) return result + + rotate_left64 :: proc "contextless" (x: u64, k: int) -> u64 { + n :: 64 + s := uint(k) & (n-1) + return x << s | x >> (n-s) + } } @(thread_local) diff --git a/core/net/dns.odin b/core/net/dns.odin index 6af18798b..54cc57c38 100644 --- a/core/net/dns.odin +++ b/core/net/dns.odin @@ -25,7 +25,6 @@ package net import "base:runtime" import "core:bufio" import "core:io" -import "core:math/rand" import "core:mem" import "core:strings" import "core:time" @@ -192,7 +191,10 @@ get_dns_records_from_nameservers :: proc(hostname: string, type: DNS_Record_Type init_dns_configuration() context.allocator = allocator - id := u16be(rand.uint32()) + id: u16be + rand_ok := runtime.random_generator_read_ptr(context.random_generator, &id, size_of(id)) + assert(rand_ok, "uninitialized gen/context.random_generator") + dns_packet_buf: [DNS_PACKET_MIN_LEN]byte = --- dns_packet := make_dns_packet(dns_packet_buf[:], id, hostname, type) or_return diff --git a/vendor/directx/d3d11/d3d11.odin b/vendor/directx/d3d11/d3d11.odin index 517146c8a..51e27ba21 100644 --- a/vendor/directx/d3d11/d3d11.odin +++ b/vendor/directx/d3d11/d3d11.odin @@ -4,7 +4,7 @@ package directx_d3d11 foreign import "system:d3d11.lib" import "../dxgi" -import "../d3d_compiler" +import "../d3d_common" import "core:sys/windows" IUnknown :: dxgi.IUnknown @@ -26,9 +26,7 @@ LPCWSTR :: windows.LPCWSTR RECT :: dxgi.RECT SIZE :: dxgi.SIZE -IModuleInstance :: d3d_compiler.ID3D11ModuleInstance -IBlob :: d3d_compiler.ID3DBlob -IModule :: d3d_compiler.ID3D11Module +IBlob :: d3d_common.ID3DBlob @(default_calling_convention="system", link_prefix="D3D11") foreign d3d11 { @@ -3569,6 +3567,34 @@ PARAMETER_DESC :: struct { FirstOutComponent: u32, } +IModule :: struct #raw_union { + #subtype iunknown: IUnknown, + using id3d11module_vtable: ^IModule_VTable, +} +IModule_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + CreateInstance: proc "system" (this: ^IModule, pNamespace: LPCSTR, ppModuleInstance: ^^IModuleInstance) -> HRESULT, +} + +IModuleInstance :: struct #raw_union { + #subtype iunknown: IUnknown, + using id3d11moduleinstance_vtable: ^IModuleInstance_VTable, +} +IModuleInstance_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + BindConstantBuffer: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, cbDstOffset: u32) -> HRESULT, + BindConstantBufferByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, cbDstOffset: u32) -> HRESULT, + BindResource: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, + BindResourceByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, + BindSampler: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, + BindSamplerByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, + BindUnorderedAccessView: proc "system" (this: ^IModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, + BindUnorderedAccessViewByName: proc "system" (this: ^IModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, + BindResourceAsUnorderedAccessView: proc "system" (this: ^IModuleInstance, uSrcSrvSlot: u32, uDstUavSlot: u32, uCount: u32) -> HRESULT, + BindResourceAsUnorderedAccessViewByName: proc "system" (this: ^IModuleInstance, pSrvName: LPCSTR, uDstUavSlot: u32, uCount: u32) -> HRESULT, +} + + ID3D11ShaderReflectionType_UUID_STRING :: "6E6FFA6A-9BAE-4613-A51E-91652D508C21" ID3D11ShaderReflectionType_UUID := &IID{0x6E6FFA6A, 0x9BAE, 0x4613, {0xA5, 0x1E, 0x91, 0x65, 0x2D, 0x50, 0x8C, 0x21}} IShaderReflectionType :: struct { diff --git a/vendor/directx/d3d12/d3d12.odin b/vendor/directx/d3d12/d3d12.odin index fba1c6e26..8611172f8 100644 --- a/vendor/directx/d3d12/d3d12.odin +++ b/vendor/directx/d3d12/d3d12.odin @@ -4,7 +4,7 @@ package directx_d3d12 foreign import "system:d3d12.lib" import "../dxgi" -import "../d3d_compiler" +import "../d3d_common" import win32 "core:sys/windows" IUnknown :: dxgi.IUnknown @@ -26,9 +26,7 @@ RECT :: dxgi.RECT LPCSTR :: win32.LPCSTR LPCWSTR :: win32.LPCWSTR -IModuleInstance :: d3d_compiler.ID3D11ModuleInstance -IBlob :: d3d_compiler.ID3DBlob -IModule :: d3d_compiler.ID3D11Module +IBlob :: d3d_common.ID3DBlob @(default_calling_convention="system", link_prefix="D3D12") foreign d3d12 { @@ -1236,7 +1234,7 @@ TRI_STATE :: enum i32 { UNKNOWN = -1, FALSE = 0, TRUE = 1, -} +} FEATURE_DATA_OPTIONS12 :: struct { MSPrimitivesPipelineStatisticIncludesCulledPrimitives: TRI_STATE, @@ -2597,7 +2595,7 @@ IDescriptorHeap_VTable :: struct { GetDesc: proc "system" (this: ^IDescriptorHeap, desc: ^DESCRIPTOR_HEAP_DESC), GetCPUDescriptorHandleForHeapStart: proc "system" (this: ^IDescriptorHeap, handle: ^CPU_DESCRIPTOR_HANDLE), GetGPUDescriptorHandleForHeapStart: proc "system" (this: ^IDescriptorHeap, handle: ^GPU_DESCRIPTOR_HANDLE), -} +} IQueryHeap_UUID_STRING :: "0d9658ae-ed45-469e-a61d-970ec583cab4" IQueryHeap_UUID := &IID{0x0d9658ae, 0xed45, 0x469e, {0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4}} @@ -5495,7 +5493,7 @@ IGraphicsCommandList7_VTable :: struct { SHADER_VERSION_TYPE :: enum u32 { PIXEL_SHADER = 0, VERTEX_SHADER = 1, - GEOMETRY_SHADER = 2, + GEOMETRY_SHADER = 2, HULL_SHADER = 3, DOMAIN_SHADER = 4, diff --git a/vendor/directx/d3d_common/d3d_common.odin b/vendor/directx/d3d_common/d3d_common.odin new file mode 100644 index 000000000..af3d09ec9 --- /dev/null +++ b/vendor/directx/d3d_common/d3d_common.odin @@ -0,0 +1,25 @@ +// Declarations shared between D3D versions. +// Based on d3dcommon.h +package d3d_common + +import "core:sys/windows" + +IID :: windows.IID +SIZE_T :: windows.SIZE_T +IUnknown :: windows.IUnknown +IUnknown_VTable :: windows.IUnknown_VTable + +ID3D10Blob_UUID_STRING :: "8BA5FB08-5195-40E2-AC58-0D989C3A0102" +ID3D10Blob_UUID := &IID{0x8BA5FB08, 0x5195, 0x40E2, {0xAC, 0x58, 0x0D, 0x98, 0x9C, 0x3A, 0x01, 0x02}} +ID3D10Blob :: struct #raw_union { + #subtype iunknown: IUnknown, + using id3d10blob_vtable: ^ID3D10Blob_VTable, +} +ID3D10Blob_VTable :: struct { + using iunknown_vtable: IUnknown_VTable, + GetBufferPointer: proc "system" (this: ^ID3D10Blob) -> rawptr, + GetBufferSize: proc "system" (this: ^ID3D10Blob) -> SIZE_T, +} + +ID3DBlob :: ID3D10Blob +ID3DBlob_VTable :: ID3D10Blob_VTable diff --git a/vendor/directx/d3d_compiler/d3d_compiler.odin b/vendor/directx/d3d_compiler/d3d_compiler.odin index 17a835f23..85c5cb46c 100644 --- a/vendor/directx/d3d_compiler/d3d_compiler.odin +++ b/vendor/directx/d3d_compiler/d3d_compiler.odin @@ -7,8 +7,9 @@ import win32 "core:sys/windows" D3DCOMPILER_DLL_A :: "d3dcompiler_47.dll" COMPILER_VERSION :: 47 - import "../dxgi" +import "../d3d11" +import "../d3d_common" BOOL :: dxgi.BOOL IID :: dxgi.IID @@ -17,6 +18,8 @@ HRESULT :: dxgi.HRESULT IUnknown :: dxgi.IUnknown IUnknown_VTable :: dxgi.IUnknown_VTable +ID3DBlob :: d3d_common.ID3DBlob + LPCSTR :: win32.LPCSTR LPCWSTR :: win32.LPCWSTR @@ -34,7 +37,7 @@ foreign d3dcompiler { Disassemble :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: LPCSTR, ppDisassembly: ^^ID3DBlob) -> HRESULT --- DisassembleRegion :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, szComments: LPCSTR, StartByteOffset: SIZE_T, NumInsts: SIZE_T, pFinishByteOffset: ^SIZE_T, ppDisassembly: ^^ID3DBlob) -> HRESULT --- CreateLinker :: proc(ppLinker: ^^ID3D11Linker) -> HRESULT --- - LoadModule :: proc(pSrcData: rawptr, cbSrcDataSize: SIZE_T, ppModule: ^^ID3D11Module) -> HRESULT --- + LoadModule :: proc(pSrcData: rawptr, cbSrcDataSize: SIZE_T, ppModule: ^^d3d11.IModule) -> HRESULT --- GetTraceInstructionOffsets :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, Flags: u32, StartInstIndex: SIZE_T, NumInsts: SIZE_T, pOffsets: ^SIZE_T, pTotalInsts: ^SIZE_T) -> HRESULT --- GetInputSignatureBlob :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, ppSignatureBlob: ^^ID3DBlob) -> HRESULT --- GetOutputSignatureBlob :: proc(pSrcData: rawptr, SrcDataSize: SIZE_T, ppSignatureBlob: ^^ID3DBlob) -> HRESULT --- @@ -121,29 +124,11 @@ SHADER_MACRO :: struct { Definition: LPCSTR, } -ID3D10Blob_UUID_STRING :: "8BA5FB08-5195-40E2-AC58-0D989C3A0102" -ID3D10Blob_UUID := &IID{0x8BA5FB08, 0x5195, 0x40E2, {0xAC, 0x58, 0x0D, 0x98, 0x9C, 0x3A, 0x01, 0x02}} -ID3D10Blob :: struct #raw_union { - #subtype iunknown: IUnknown, - using id3d10blob_vtable: ^ID3D10Blob_VTable, -} -ID3D10Blob_VTable :: struct { - using iunknown_vtable: IUnknown_VTable, - GetBufferPointer: proc "system" (this: ^ID3D10Blob) -> rawptr, - GetBufferSize: proc "system" (this: ^ID3D10Blob) -> SIZE_T, -} - - -ID3DBlob :: ID3D10Blob -ID3DBlob_VTable :: ID3D10Blob_VTable - - INCLUDE_TYPE :: enum i32 { INCLUDE_LOCAL = 0, INCLUDE_SYSTEM = 1, _10_INCLUDE_LOCAL = 0, _10_INCLUDE_SYSTEM = 1, - INCLUDE_FORCE_DWORD = 2147483647, } ID3DInclude :: struct { @@ -158,43 +143,14 @@ ID3DInclude_VTable :: struct { D3DCOMPILE_STANDARD_FILE_INCLUDE :: (^ID3DInclude)(uintptr(1)) -ID3D11Module :: struct #raw_union { - #subtype iunknown: IUnknown, - using id3d11module_vtable: ^ID3D11Module_VTable, -} -ID3D11Module_VTable :: struct { - using iunknown_vtable: IUnknown_VTable, - CreateInstance: proc "system" (this: ^ID3D11Module, pNamespace: LPCSTR, ppModuleInstance: ^^ID3D11ModuleInstance) -> HRESULT, -} - - -ID3D11ModuleInstance :: struct #raw_union { - #subtype iunknown: IUnknown, - using id3d11moduleinstance_vtable: ^ID3D11ModuleInstance_VTable, -} -ID3D11ModuleInstance_VTable :: struct { - using iunknown_vtable: IUnknown_VTable, - BindConstantBuffer: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, cbDstOffset: u32) -> HRESULT, - BindConstantBufferByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, cbDstOffset: u32) -> HRESULT, - BindResource: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, - BindResourceByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, - BindSampler: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, - BindSamplerByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, - BindUnorderedAccessView: proc "system" (this: ^ID3D11ModuleInstance, uSrcSlot: u32, uDstSlot: u32, uCount: u32) -> HRESULT, - BindUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pName: LPCSTR, uDstSlot: u32, uCount: u32) -> HRESULT, - BindResourceAsUnorderedAccessView: proc "system" (this: ^ID3D11ModuleInstance, uSrcSrvSlot: u32, uDstUavSlot: u32, uCount: u32) -> HRESULT, - BindResourceAsUnorderedAccessViewByName: proc "system" (this: ^ID3D11ModuleInstance, pSrvName: LPCSTR, uDstUavSlot: u32, uCount: u32) -> HRESULT, -} - - ID3D11Linker :: struct #raw_union { #subtype iunknown: IUnknown, using id3d11linker_vtable: ^ID3D11Linker_VTable, } ID3D11Linker_VTable :: struct { using iunknown_vtable: IUnknown_VTable, - Link: proc "system" (this: ^ID3D11Linker, pEntry: ^ID3D11ModuleInstance, pEntryName: LPCSTR, pTargetName: LPCSTR, uFlags: u32, ppShaderBlob: ^^ID3DBlob, ppErrorBuffer: ^^ID3DBlob) -> HRESULT, - UseLibrary: proc "system" (this: ^ID3D11Linker, pLibraryMI: ^ID3D11ModuleInstance) -> HRESULT, + Link: proc "system" (this: ^ID3D11Linker, pEntry: ^d3d11.IModuleInstance, pEntryName: LPCSTR, pTargetName: LPCSTR, uFlags: u32, ppShaderBlob: ^^ID3DBlob, ppErrorBuffer: ^^ID3DBlob) -> HRESULT, + UseLibrary: proc "system" (this: ^ID3D11Linker, pLibraryMI: ^d3d11.IModuleInstance) -> HRESULT, AddClipPlaneFromCBuffer: proc "system" (this: ^ID3D11Linker, uCBufferSlot: u32, uCBufferEntry: u32) -> HRESULT, } diff --git a/vendor/directx/dxc/dxcapi.odin b/vendor/directx/dxc/dxcapi.odin index 1d3155feb..326d3b3f3 100644 --- a/vendor/directx/dxc/dxcapi.odin +++ b/vendor/directx/dxc/dxcapi.odin @@ -194,7 +194,7 @@ ICompiler :: struct #raw_union { ICompiler_VTable :: struct { using iunknown_vtable: IUnknown_VTable, Compile: proc "system" ( - this: ^ICompiler, + this: ^ICompiler, pSource: ^IBlob, pSourceName: wstring, pEntryPoint: wstring, @@ -206,7 +206,7 @@ ICompiler_VTable :: struct { pIncludeHandler: ^IIncludeHandler, ppResult: ^^IOperationResult) -> HRESULT, Preprocess: proc "system" ( - this: ^ICompiler, + this: ^ICompiler, pSource: ^IBlob, pSourceName: wstring, pArguments: [^]wstring, @@ -303,7 +303,6 @@ DXC_OUT_KIND :: enum u32 { REFLECTION = 8, ROOT_SIGNATURE = 9, EXTRA_OUTPUTS = 10, - FORCE_DWORD = 0xFFFFFFFF, } IResult_UUID_STRING :: "58346CDA-DDE7-4497-9461-6F87AF5E0659" diff --git a/vendor/directx/dxgi/dxgi.odin b/vendor/directx/dxgi/dxgi.odin index 05b3925ff..8865a5f7c 100644 --- a/vendor/directx/dxgi/dxgi.odin +++ b/vendor/directx/dxgi/dxgi.odin @@ -752,7 +752,6 @@ ALPHA_MODE :: enum i32 { PREMULTIPLIED = 1, STRAIGHT = 2, IGNORE = 3, - FORCE_DWORD = -1, } diff --git a/vendor/miniaudio/logging.odin b/vendor/miniaudio/logging.odin index afddf8e68..135c6a9b1 100644 --- a/vendor/miniaudio/logging.odin +++ b/vendor/miniaudio/logging.odin @@ -1,6 +1,6 @@ package miniaudio -import "core:c/libc" +import "core:c" foreign import lib { LIB } @@ -48,12 +48,12 @@ log :: struct { @(default_calling_convention="c", link_prefix="ma_") foreign lib { log_callback_init :: proc(onLog: log_callback_proc, pUserData: rawptr) -> log_callback --- - + log_init :: proc(pAllocationCallbacks: ^allocation_callbacks, pLog: ^log) -> result --- log_uninit :: proc(pLog: ^log) --- log_register_callback :: proc(pLog: ^log, callback: log_callback) -> result --- log_unregister_callback :: proc(pLog: ^log, callback: log_callback) -> result --- log_post :: proc(pLog: ^log, level: u32, pMessage: cstring) -> result --- - log_postv :: proc(pLog: ^log, level: u32, pFormat: cstring, args: libc.va_list) -> result --- + log_postv :: proc(pLog: ^log, level: u32, pFormat: cstring, args: c.va_list) -> result --- log_postf :: proc(pLog: ^log, level: u32, pFormat: cstring, #c_vararg args: ..any) -> result --- } |