Skip to content

Commit

Permalink
Allow the user to override the vertex semantics.
Browse files Browse the repository at this point in the history
Adds a new settings-gear button to the geo view, that when clicked, shows
a dialog where the user can assign the sementic type to each vertex stream
of the current model.
  • Loading branch information
pmuetschard committed May 2, 2018
1 parent 5c97b96 commit 156ee84
Show file tree
Hide file tree
Showing 8 changed files with 304 additions and 21 deletions.
Binary file added gapic/res/icons/settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gapic/res/icons/settings@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions gapic/src/main/com/google/gapid/util/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ public interface Messages {
"Extra details from the logs and the trace file would be extra helpful.\n\n";
public static final String NO_OPENGL =
"Failed to create an OpenGL context. OpenGL is required to use this application.";
public static final String GEO_SEMANTICS_TITLE = "Vertex Semantics";
public static final String GEO_SEMANTICS_HINT = "Manually configure the vertex stream semantics:";
}
23 changes: 19 additions & 4 deletions gapic/src/main/com/google/gapid/util/Paths.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,26 @@ public static Path.Any resourceAfter(AtomIndex atom, Path.ID id) {
.build();
}

public static Path.Any meshAfter(AtomIndex atom, Path.MeshOptions options,
Vertex.BufferFormat format) {
public static final Path.MeshOptions NODATA_MESH_OPTIONS = Path.MeshOptions.newBuilder()
.setExcludeData(true)
.build();

public static Path.Any meshAfter(AtomIndex atom, Path.MeshOptions options) {
return Path.Any.newBuilder()
.setMesh(Path.Mesh.newBuilder()
.setCommandTreeNode(atom.getNode())
.setOptions(options))
.build();
}

public static Path.Any meshAfter(
AtomIndex atom, Path.MeshOptions options, Vertex.BufferFormat format) {
return Path.Any.newBuilder()
.setAs(Path.As.newBuilder().setVertexBufferFormat(format)
.setMesh(Path.Mesh.newBuilder().setCommandTreeNode(atom.getNode()).setOptions(options)))
.setAs(Path.As.newBuilder()
.setMesh(Path.Mesh.newBuilder()
.setCommandTreeNode(atom.getNode())
.setOptions(options))
.setVertexBufferFormat(format))
.build();
}

Expand Down
70 changes: 70 additions & 0 deletions gapic/src/main/com/google/gapid/util/Streams.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,28 @@
*/
package com.google.gapid.util;

import com.google.common.collect.ImmutableMap;
import com.google.gapid.proto.stream.Stream;

import java.util.Map;

/**
* Data {@link Stream} utilities.
*/
public class Streams {
// U8 represents a 8-bit unsigned, integer.
public static final Stream.DataType U8 = newInt(false, 8);

// F10 represents a 10-bit unsigned floating-point number.
public static final Stream.DataType F10 = newFloat(false, 5, 5);
// F11 represents a 11-bit unsigned floating-point number.
public static final Stream.DataType F11 = newFloat(false, 5, 6);
// F16 represents a 16-bit signed, floating-point number.
public static final Stream.DataType F16 = newFloat(true, 5, 10);
// F32 represents a 32-bit signed, floating-point number.
public static final Stream.DataType F32 = newFloat(true, 7, 24);
// F64 represents a 64-bit signed, floating-point number.
public static final Stream.DataType F64 = newFloat(true, 10, 53);

// LINEAR is a Sampling state using a linear curve.
public static final Stream.Sampling LINEAR = Stream.Sampling.newBuilder()
Expand Down Expand Up @@ -129,6 +140,65 @@ public static Stream.DataType newFloat(boolean signed, int exponentBits, int man
).build();
}

private static final Map<Stream.DataType, String> FIXED_DATATYPE_NAMES =
ImmutableMap.<Stream.DataType, String>builder()
.put(F10, "float10")
.put(F11, "float11")
.put(F16, "float16")
.put(F32, "float32")
.put(F64, "float64")
.build();

private Streams() {
}

public static String toString(Stream.Format format) {
StringBuilder sb = new StringBuilder();
int count = 0;
String lastType = null;
for (Stream.Component c : format.getComponentsList()) {
String type = toString(c.getDataType());
if (lastType == null || type.equals(lastType)) {
lastType = type;
count++;
} else {
append(sb, lastType, count).append(", ");
lastType = type;
count = 1;
}
}
if (lastType != null) {
append(sb, lastType, count);
}
return sb.toString();
}

private static StringBuilder append(StringBuilder sb, String type, int count) {
sb.append(type);
if (count > 1) {
sb.append(" vec").append(count);
}
return sb;
}

public static String toString(Stream.DataType type) {
String name = FIXED_DATATYPE_NAMES.get(type);
if (name != null) {
return name;
}

switch (type.getKindCase()) {
case FLOAT:
Stream.Float f = type.getFloat();
return "float" + (type.getSigned() ? "S" : "U") + f.getMantissaBits() + "E" + f.getExponentBits();
case FIXED:
Stream.Fixed x = type.getFixed();
return "fixed" + (type.getSigned() ? "S" : "U") + x.getIntegerBits() + "." + x.getFractionalBits();
case INTEGER:
Stream.Integer i = type.getInteger();
return (type.getSigned() ? "s" : "u") + "int" + i.getBits();
default:
return "unknown";
}
}
}
Loading

0 comments on commit 156ee84

Please sign in to comment.