internal/graphicsdriver/metal: refactoring

This commit is contained in:
Hajime Hoshi 2024-05-05 17:18:06 +09:00
parent aace620b7e
commit caab1ee29f

View File

@ -42,12 +42,11 @@ func (c *precompiledLibraries) put(hash shaderir.SourceHash, bin []byte) {
c.binaries[hash] = bin
}
func (c *precompiledLibraries) get(hash shaderir.SourceHash) ([]byte, bool) {
func (c *precompiledLibraries) get(hash shaderir.SourceHash) []byte {
c.m.Lock()
defer c.m.Unlock()
bin, ok := c.binaries[hash]
return bin, ok
return c.binaries[hash]
}
var thePrecompiledLibraries precompiledLibraries
@ -104,7 +103,7 @@ func (s *Shader) Dispose() {
func (s *Shader) init(device mtl.Device) error {
var src string
if libBin, ok := thePrecompiledLibraries.get(s.ir.SourceHash); ok {
if libBin := thePrecompiledLibraries.get(s.ir.SourceHash); len(libBin) > 0 {
lib, err := device.MakeLibraryWithData(libBin)
if err != nil {
return err