-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathd3d11_utils.odin
More file actions
43 lines (37 loc) · 1.35 KB
/
d3d11_utils.odin
File metadata and controls
43 lines (37 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#+build windows
package gpu
// Vendor
import "vendor:directx/d3d11"
d3d11_encode_basic_filter :: #force_inline proc(
min, mag, mip: d3d11.FILTER_TYPE,
reduction: d3d11.FILTER_REDUCTION_TYPE,
) -> d3d11.FILTER {
return d3d11.FILTER(
((u32(min) & d3d11.FILTER_TYPE_MASK) << d3d11.MIN_FILTER_SHIFT) |
((u32(mag) & d3d11.FILTER_TYPE_MASK) << d3d11.MAG_FILTER_SHIFT) |
((u32(mip) & d3d11.FILTER_TYPE_MASK) << d3d11.MIP_FILTER_SHIFT) |
((u32(reduction) & d3d11.FILTER_REDUCTION_TYPE_MASK) << d3d11.FILTER_REDUCTION_TYPE_SHIFT))
}
d3d11_encode_anisotropic_filter :: #force_inline proc(
reduction: d3d11.FILTER_REDUCTION_TYPE = .STANDARD,
) -> d3d11.FILTER {
return d3d11.FILTER(
u32(d3d11.ANISOTROPIC_FILTERING_BIT) |
u32(d3d11_encode_basic_filter(
.LINEAR,
.LINEAR,
.LINEAR,
reduction)))
}
d3d11_buffer_size_alignment :: proc(usage: Buffer_Usages) -> u32 {
if .Uniform in usage {
// Each number of constants must be a multiple of 16 shader constants
return size_of(f32) * 4 * 16 // 256 bytes
}
if .Storage in usage || .Copy_Src in usage || .Copy_Dst in usage {
// Unordered access buffers must be 4-byte aligned
// Also for Copy_Dst/Copy_Src buffers used in compute shaders
return size_of(u32)
}
return 1
}