56 lines
1.5 KiB
Go
56 lines
1.5 KiB
Go
package cache
|
|
|
|
import (
|
|
"zworld/engine/renderapi/buffer"
|
|
"zworld/engine/renderapi/command"
|
|
|
|
"github.com/vkngwrapper/core/v2/core1_0"
|
|
)
|
|
|
|
/*
|
|
VUID-vkDestroyDevice-device-00378(ERROR / SPEC): msgNum: 1901072314 - Validation Error: [ VUID-vkDestroyDevice-device-00378 ] Object 0: handle = 0x45d6d1000000004c, name = Storage[Object]:1, type = VK_OBJECT_TYPE_DEVICE_MEMOR
|
|
Y; | MessageID = 0x71500fba | OBJ ERROR : For VkDevice 0x1aefe8c0600[], VkDeviceMemory 0x45d6d1000000004c[Storage[Object]:1] has not been destroyed. The Vulkan spec states: All child objects created on device must have been d
|
|
estroyed prior to destroying device (https://vulkan.lunarg.com/doc/view/1.3.261.1/windows/1.3-extensions/vkspec.html#VUID-vkDestroyDevice-device-00378)
|
|
*/
|
|
type Mesh interface {
|
|
Draw(command.Buffer, int)
|
|
DrawInstanced(buf command.Buffer, startIndex, coount int)
|
|
Destroy()
|
|
}
|
|
|
|
type vkMesh struct {
|
|
key string
|
|
elements int
|
|
idxType core1_0.IndexType
|
|
vertices buffer.T
|
|
indices buffer.T
|
|
}
|
|
|
|
func (m *vkMesh) Draw(cmd command.Buffer, index int) {
|
|
m.DrawInstanced(cmd, index, 1)
|
|
}
|
|
|
|
func (m *vkMesh) DrawInstanced(cmd command.Buffer, startIndex, count int) {
|
|
if m.elements <= 0 {
|
|
// nothing to draw
|
|
return
|
|
}
|
|
|
|
cmd.CmdBindVertexBuffer(m.vertices, 0)
|
|
cmd.CmdBindIndexBuffers(m.indices, 0, m.idxType)
|
|
|
|
// index of the object properties in the ssbo
|
|
cmd.CmdDrawIndexed(m.elements, count, 0, 0, startIndex)
|
|
}
|
|
|
|
func (m *vkMesh) Destroy() {
|
|
if m.vertices != nil {
|
|
m.vertices.Destroy()
|
|
m.vertices = nil
|
|
}
|
|
if m.indices != nil {
|
|
m.indices.Destroy()
|
|
m.indices = nil
|
|
}
|
|
}
|