Skip to content

Commit

Permalink
internal/graphicsdriver/metal: refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hajimehoshi committed May 5, 2024
1 parent aace620 commit caab1ee
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions internal/graphicsdriver/metal/shader_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit caab1ee

Please sign in to comment.