Skip to content

Commit

Permalink
Guess pos / norm streams when name matching fails.
Browse files Browse the repository at this point in the history
Issue: google#960
  • Loading branch information
ben-clayton committed Aug 22, 2017
1 parent 0be3e3d commit fe822a0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions gapis/api/gles/guess_semantics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package gles
import (
"strings"

"github.com/google/gapid/core/stream"
"github.com/google/gapid/core/stream/fmts"
"github.com/google/gapid/gapis/vertex"
)

Expand All @@ -36,6 +38,18 @@ var semanticPatterns = []struct {
{"vertex", vertex.Semantic_Position},
}

var semanticFormats = []struct {
format *stream.Format
semantic vertex.Semantic_Type
}{
// Ordered from highest priority to lowest
{fmts.XYZ_F32, vertex.Semantic_Position},
{fmts.XYZ_S8_NORM, vertex.Semantic_Normal},
}

// guessSemantics uses string and format matching to try and guess the semantic
// usage of a vertex stream.
// This is a big fat hack. See: https://github.com/google/gapid/issues/960
func guessSemantics(vb *vertex.Buffer) {
taken := map[vertex.Semantic_Type]bool{}
for _, p := range semanticPatterns {
Expand All @@ -50,4 +64,16 @@ func guessSemantics(vb *vertex.Buffer) {
}
}
}
for _, p := range semanticFormats {
if taken[p.semantic] {
continue
}
for _, s := range vb.Streams {
if s.Format.String() == p.format.String() {
s.Semantic.Type = p.semantic
taken[p.semantic] = true
break
}
}
}
}

0 comments on commit fe822a0

Please sign in to comment.