-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgl_rendermisc.go
More file actions
90 lines (73 loc) · 1.83 KB
/
gl_rendermisc.go
File metadata and controls
90 lines (73 loc) · 1.83 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"log"
"github.com/vkngwrapper/core/v3/core1_0"
)
var CVarRLodBias = &CVar{
Name: "r_lodbias",
StringVal: "1",
Flags: CVarFlagArchive,
}
var CVarGLLodBias = &CVar{
Name: "gl_lodbias",
StringVal: "0",
Flags: CVarFlagArchive,
}
const (
NumStagingBuffers int = 2
)
type StagingBuffer struct {
Buffer core1_0.Buffer
CommandBuffer core1_0.CommandBuffer
Fence core1_0.Fence
CurrentOffset int
Submitted bool
Data []byte
}
type DynamicBuffer struct {
Buffer core1_0.Buffer
CurrentOffset int
Data []byte
DeviceAddress uint64
}
type RenderResourceData struct {
stagingBuffers [NumStagingBuffers]StagingBuffer
}
func (r *RenderResourceData) CreateStagingBuffers() {
bufferCreate := core1_0.BufferCreateInfo{
Size: Vulkan.StagingBufferSize,
Usage: core1_0.BufferUsageTransferSrc,
}
var err error
for i := 0; i < NumStagingBuffers; i++ {
r.stagingBuffers[i].CurrentOffset = 0
r.stagingBuffers[i].Submitted = false
r.stagingBuffers[i].Buffer, _, err = Vulkan.Driver.CreateBuffer(nil, bufferCreate)
if err != nil {
log.Fatalln("CreateBuffer failed")
}
}
}
var RenderResources = &RenderResourceData{}
func (v *VulkanGlobals) SetClearColor() {
if CVarRFastClear.Value != 0 {
Vulkan.ColorClearValue = core1_0.ClearValueFloat{0, 0, 0, 0}
} else {
s := int(CVarRClearColor.Value) & 0xff
rgb := D8To24Table[s]
r := float32(rgb&0xff) / 255.0
g := float32((rgb>>8)&0xff) / 255.0
b := float32((rgb>>16)&0xff) / 255.0
Vulkan.ColorClearValue = core1_0.ClearValueFloat{r, g, b, 0}
}
}
func (v *VulkanGlobals) CVarSetClearColor(cvar *CVar) {
if CVarRFastClear.Value != 0.0 {
log.Println("Black clear color forced by r_fastclear")
}
v.SetClearColor()
}
func (v *VulkanGlobals) CVarSetFastClear(cvar *CVar) {
v.SetClearColor()
}
// TODO: SIMD