Skip to content

Commit 4feb1a2

Browse files
committed
dds_loader.zig does not contain bindings...
move it out of bindings folder and fix imports and delete duplicate win32 defs
1 parent 796ca4e commit 4feb1a2

File tree

3 files changed

+24
-95
lines changed

3 files changed

+24
-95
lines changed
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// https://github.com/microsoft/DirectXTK12/blob/main/Src/DDSTextureLoader.cpp
33
const std = @import("std");
44
const assert = std.debug.assert;
5-
const windows = @import("windows.zig");
6-
const dxgi = @import("dxgi.zig");
7-
const d3d12 = @import("d3d12.zig");
5+
6+
const zwindows = @import("zwindows");
7+
const windows = zwindows.windows;
8+
const dxgi = zwindows.dxgi;
9+
const d3d12 = zwindows.d3d12;
810

911
const DDS_HEADER_FLAGS_TEXTURE: u32 = 0x00001007; // DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
1012
const DDS_HEADER_FLAGS_MIPMAP: u32 = 0x00020000; // DDSD_MIPMAPCOUNT
@@ -135,7 +137,7 @@ pub fn loadTextureFromFile(
135137
}
136138

137139
// Read all file
138-
const file_data = try arena.alloc(u8, file_size);
140+
const file_data = try arena.alloc(u8, @intCast(file_size));
139141
const read_bytes = try file.readAll(file_data);
140142
if (read_bytes != file_size) {
141143
return DdsError.InvalidDDSData;

src/zd3d12.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ const d3d12d = zwindows.d3d12d;
1111
const d3d = zwindows.d3d;
1212
const d2d1 = zwindows.d2d1;
1313
const d3d11on12 = zwindows.d3d11on12;
14-
const dds_loader = zwindows.dds_loader;
1514
const wic = zwindows.wic;
1615
const HResultError = zwindows.HResultError;
1716
const hrPanic = zwindows.hrPanic;
1817
const hrPanicOnFail = zwindows.hrPanicOnFail;
1918
const hrErrorOnFail = zwindows.hrErrorOnFail;
2019

20+
const dds_loader = @import("dds_loader.zig");
21+
2122
const options = @import("options");
2223
const enable_debug_layer = options.zd3d12_debug_layer;
2324
const enable_gbv = options.zd3d12_gbv;

src/zwindows.zig

Lines changed: 16 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -16,86 +16,12 @@ pub const xaudio2 = @import("bindings/xaudio2.zig");
1616
pub const xaudio2fx = @import("bindings/xaudio2fx.zig");
1717
pub const xapo = @import("bindings/xapo.zig");
1818
pub const xinput = @import("bindings/xinput.zig");
19-
pub const dds_loader = @import("bindings/dds_loader.zig");
2019
pub const d3dcompiler = @import("bindings/d3dcompiler.zig");
2120

2221
const std = @import("std");
2322
const panic = std.debug.panic;
2423
const assert = std.debug.assert;
2524

26-
const WINAPI = std.os.windows.WINAPI;
27-
const S_OK = std.os.windows.S_OK;
28-
const S_FALSE = std.os.windows.S_FALSE;
29-
const E_NOTIMPL = std.os.windows.E_NOTIMPL;
30-
const E_NOINTERFACE = std.os.windows.E_NOINTERFACE;
31-
const E_POINTER = std.os.windows.E_POINTER;
32-
const E_ABORT = std.os.windows.E_ABORT;
33-
const E_FAIL = std.os.windows.E_FAIL;
34-
const E_UNEXPECTED = std.os.windows.E_UNEXPECTED;
35-
const E_ACCESSDENIED = std.os.windows.E_ACCESSDENIED;
36-
const E_HANDLE = std.os.windows.E_HANDLE;
37-
const E_OUTOFMEMORY = std.os.windows.E_OUTOFMEMORY;
38-
const E_INVALIDARG = std.os.windows.E_INVALIDARG;
39-
const GENERIC_READ = std.os.windows.GENERIC_READ;
40-
const GENERIC_WRITE = std.os.windows.GENERIC_WRITE;
41-
const GENERIC_EXECUTE = std.os.windows.GENERIC_EXECUTE;
42-
const GENERIC_ALL = std.os.windows.GENERIC_ALL;
43-
const EVENT_ALL_ACCESS = std.os.windows.EVENT_ALL_ACCESS;
44-
const TRUE = std.os.windows.TRUE;
45-
const FALSE = std.os.windows.FALSE;
46-
const BOOL = std.os.windows.BOOL;
47-
const BOOLEAN = std.os.windows.BOOLEAN;
48-
const BYTE = std.os.windows.BYTE;
49-
const CHAR = std.os.windows.CHAR;
50-
const UCHAR = std.os.windows.UCHAR;
51-
const WCHAR = std.os.windows.WCHAR;
52-
const FLOAT = std.os.windows.FLOAT;
53-
const HCRYPTPROV = std.os.windows.HCRYPTPROV;
54-
const ATOM = std.os.windows.ATOM;
55-
const WPARAM = std.os.windows.WPARAM;
56-
const LPARAM = std.os.windows.LPARAM;
57-
const LRESULT = std.os.windows.LRESULT;
58-
const HRESULT = std.os.windows.HRESULT;
59-
const HBRUSH = std.os.windows.HBRUSH;
60-
const HCURSOR = std.os.windows.HCURSOR;
61-
const HICON = std.os.windows.HICON;
62-
const HINSTANCE = std.os.windows.HINSTANCE;
63-
const HMENU = std.os.windows.HMENU;
64-
const HMODULE = std.os.windows.HMODULE;
65-
const HWND = std.os.windows.HWND;
66-
const HDC = std.os.windows.HDC;
67-
const HGLRC = std.os.windows.HGLRC;
68-
const FARPROC = std.os.windows.FARPROC;
69-
const INT = std.os.windows.INT;
70-
const SIZE_T = std.os.windows.SIZE_T;
71-
const UINT = std.os.windows.UINT;
72-
const USHORT = std.os.windows.USHORT;
73-
const SHORT = std.os.windows.SHORT;
74-
const ULONG = std.os.windows.ULONG;
75-
const LONG = std.os.windows.LONG;
76-
const WORD = std.os.windows.WORD;
77-
const DWORD = std.os.windows.DWORD;
78-
const ULONGLONG = std.os.windows.ULONGLONG;
79-
const LONGLONG = std.os.windows.LONGLONG;
80-
const LARGE_INTEGER = std.os.windows.LARGE_INTEGER;
81-
const ULARGE_INTEGER = std.os.windows.ULARGE_INTEGER;
82-
const LPCSTR = std.os.windows.LPCSTR;
83-
const LPCVOID = std.os.windows.LPCVOID;
84-
const LPSTR = std.os.windows.LPSTR;
85-
const LPVOID = std.os.windows.LPVOID;
86-
const LPWSTR = std.os.windows.LPWSTR;
87-
const LPCWSTR = std.os.windows.LPCSWTR;
88-
const PVOID = std.os.windows.PVOID;
89-
const PWSTR = std.os.windows.PWSTR;
90-
const PCWSTR = std.os.windows.PCWSTR;
91-
const HANDLE = std.os.windows.HANDLE;
92-
const GUID = std.os.windows.GUID;
93-
const NTSTATUS = std.os.windows.NTSTATUS;
94-
const CRITICAL_SECTION = std.os.windows.CRITICAL_SECTION;
95-
const SECURITY_ATTRIBUTES = std.os.windows.SECURITY_ATTRIBUTES;
96-
const RECT = std.os.windows.RECT;
97-
const POINT = std.os.windows.POINT;
98-
9925
/// https://docs.microsoft.com/en-us/windows/win32/com/com-error-codes-10
10026
///
10127
/// [DEPRECATED]: Use proc specific errors as in std.os.windows
@@ -110,22 +36,22 @@ pub fn hrPanic(err: HResultError) noreturn {
11036
);
11137
}
11238

113-
pub inline fn hrPanicOnFail(hr: HRESULT) void {
114-
if (hr != S_OK) {
39+
pub inline fn hrPanicOnFail(hr: windows.HRESULT) void {
40+
if (hr != windows.S_OK) {
11541
hrPanic(hrToError(hr));
11642
}
11743
}
11844

11945
/// [DEPRECATED]: Use proc specific errors as in std.os.windows
120-
pub inline fn hrErrorOnFail(hr: HRESULT) HResultError!void {
121-
if (hr != S_OK) {
46+
pub inline fn hrErrorOnFail(hr: windows.HRESULT) HResultError!void {
47+
if (hr != windows.S_OK) {
12248
return hrToError(hr);
12349
}
12450
}
12551

12652
/// [DEPRECATED]: Use proc specific errors as in std.os.windows
127-
pub fn hrToError(hr: HRESULT) HResultError {
128-
assert(hr != S_OK);
53+
pub fn hrToError(hr: windows.HRESULT) HResultError {
54+
assert(hr != windows.S_OK);
12955
return switch (hr) {
13056
//
13157
windows.E_UNEXPECTED => windows.Error.UNEXPECTED,
@@ -214,17 +140,17 @@ pub fn hrToError(hr: HRESULT) HResultError {
214140
};
215141
}
216142

217-
pub fn errorToHRESULT(err: HResultError) HRESULT {
143+
pub fn errorToHRESULT(err: HResultError) windows.HRESULT {
218144
return switch (err) {
219-
windows.Error.UNEXPECTED => E_UNEXPECTED,
220-
windows.Error.NOTIMPL => E_NOTIMPL,
221-
windows.Error.OUTOFMEMORY => E_OUTOFMEMORY,
222-
windows.Error.INVALIDARG => E_INVALIDARG,
223-
windows.Error.POINTER => E_POINTER,
224-
windows.Error.HANDLE => E_HANDLE,
225-
windows.Error.ABORT => E_ABORT,
226-
windows.Error.FAIL => E_FAIL,
227-
windows.Error.ACCESSDENIED => E_ACCESSDENIED,
145+
windows.Error.UNEXPECTED => windows.E_UNEXPECTED,
146+
windows.Error.NOTIMPL => windows.E_NOTIMPL,
147+
windows.Error.OUTOFMEMORY => windows.E_OUTOFMEMORY,
148+
windows.Error.INVALIDARG => windows.E_INVALIDARG,
149+
windows.Error.POINTER => windows.E_POINTER,
150+
windows.Error.HANDLE => windows.E_HANDLE,
151+
windows.Error.ABORT => windows.E_ABORT,
152+
windows.Error.FAIL => windows.E_FAIL,
153+
windows.Error.ACCESSDENIED => windows.E_ACCESSDENIED,
228154
//
229155
dxgi.Error.ACCESS_DENIED => dxgi.ERROR_ACCESS_DENIED,
230156
dxgi.Error.ACCESS_LOST => dxgi.ERROR_ACCESS_LOST,

0 commit comments

Comments
 (0)