Skip to content

Commit

Permalink
Add basic support for multisampled textures.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-clayton committed Oct 11, 2017
1 parent 1661249 commit 71a8a9b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
14 changes: 10 additions & 4 deletions gapic/src/main/com/google/gapid/views/TextureView.java
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,12 @@ private static class AdditionalInfo {
new AdditionalInfo("1D Array", Image.Info.getDefaultInstance(), 0, 0);
public static final AdditionalInfo NULL_2D =
new AdditionalInfo("2D", Image.Info.getDefaultInstance(), 0, 0);
public static final AdditionalInfo NULL_2D_MS =
new AdditionalInfo("2D Multisampled", Image.Info.getDefaultInstance(), 0, 0);
public static final AdditionalInfo NULL_2D_ARRAY =
new AdditionalInfo("2D Array", Image.Info.getDefaultInstance(), 0, 0);
public static final AdditionalInfo NULL_2D_MS_ARRAY =
new AdditionalInfo("2D Multisampled Array", Image.Info.getDefaultInstance(), 0, 0);
public static final AdditionalInfo NULL_3D =
new AdditionalInfo("3D", Image.Info.getDefaultInstance(), 0, 0);
public static final AdditionalInfo NULL_CUBEMAP =
Expand Down Expand Up @@ -455,13 +459,15 @@ public static AdditionalInfo from(Service.Value value) {
}
case TEXTURE_2D: {
API.Texture2D t = texture.getTexture2D();
return (t.getLevelsCount() == 0) ? NULL_2D :
new AdditionalInfo("2D", t.getLevels(0), 1, t.getLevelsCount());
AdditionalInfo nullInfo = t.getMultisampled() ? NULL_2D_MS : NULL_2D;
return (t.getLevelsCount() == 0) ? nullInfo :
new AdditionalInfo(nullInfo.typeLabel, t.getLevels(0), 1, t.getLevelsCount());
}
case TEXTURE_2D_ARRAY: {
API.Texture2DArray t = texture.getTexture2DArray();
return (t.getLayersCount() == 0 || t.getLayers(0).getLevelsCount() == 0) ? NULL_2D_ARRAY :
new AdditionalInfo("2D Array", t.getLayers(0).getLevels(0), t.getLayersCount(),
AdditionalInfo nullInfo = t.getMultisampled() ? NULL_2D_MS_ARRAY : NULL_2D_ARRAY;
return (t.getLayersCount() == 0 || t.getLayers(0).getLevelsCount() == 0) ? nullInfo :
new AdditionalInfo(nullInfo.typeLabel, t.getLayers(0).getLevels(0), t.getLayersCount(),
t.getLayers(0).getLevelsCount());
}
case TEXTURE_3D: {
Expand Down
15 changes: 12 additions & 3 deletions gapis/api/gles/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (t *Texture) ResourceType(ctx context.Context) api.ResourceType {
func (t *Texture) ResourceData(ctx context.Context, s *api.GlobalState) (*api.ResourceData, error) {
ctx = log.Enter(ctx, "Texture.ResourceData()")
switch t.Kind {
case GLenum_GL_TEXTURE_1D, GLenum_GL_TEXTURE_2D:
case GLenum_GL_TEXTURE_1D, GLenum_GL_TEXTURE_2D, GLenum_GL_TEXTURE_2D_MULTISAMPLE:
levels := make([]*image.Info, len(t.Levels))
for i, level := range t.Levels {
img, err := level.Layers[0].ImageInfo(ctx, s)
Expand All @@ -73,6 +73,8 @@ func (t *Texture) ResourceData(ctx context.Context, s *api.GlobalState) (*api.Re
return api.NewResourceData(api.NewTexture(&api.Texture1D{Levels: levels})), nil
case GLenum_GL_TEXTURE_2D:
return api.NewResourceData(api.NewTexture(&api.Texture2D{Levels: levels})), nil
case GLenum_GL_TEXTURE_2D_MULTISAMPLE:
return api.NewResourceData(api.NewTexture(&api.Texture2D{Levels: levels, Multisampled: true})), nil
default:
panic(fmt.Errorf("Unhandled texture kind %v", t.Kind))
}
Expand Down Expand Up @@ -104,7 +106,7 @@ func (t *Texture) ResourceData(ctx context.Context, s *api.GlobalState) (*api.Re
}
return api.NewResourceData(api.NewTexture(&api.Texture1DArray{Layers: layers})), nil

case GLenum_GL_TEXTURE_2D_ARRAY:
case GLenum_GL_TEXTURE_2D_ARRAY, GLenum_GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
numLayers := t.LayerCount()
layers := make([]*api.Texture2D, numLayers)
for layer := range layers {
Expand All @@ -118,7 +120,14 @@ func (t *Texture) ResourceData(ctx context.Context, s *api.GlobalState) (*api.Re
}
layers[layer] = &api.Texture2D{Levels: levels}
}
return api.NewResourceData(api.NewTexture(&api.Texture2DArray{Layers: layers})), nil
switch t.Kind {
case GLenum_GL_TEXTURE_2D_ARRAY:
return api.NewResourceData(api.NewTexture(&api.Texture2DArray{Layers: layers})), nil
case GLenum_GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
return api.NewResourceData(api.NewTexture(&api.Texture2DArray{Layers: layers, Multisampled: true})), nil
default:
panic(fmt.Errorf("Unhandled texture kind %v", t.Kind))
}

case GLenum_GL_TEXTURE_3D:
levels := make([]*image.Info, len(t.Levels))
Expand Down
2 changes: 2 additions & 0 deletions gapis/api/service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,13 @@ message Texture1DArray {
message Texture2D {
// The mip-map levels.
repeated image.Info levels = 1;
bool multisampled = 2;
}

// Texture2DArray represents a two-dimensional texture array resource.
message Texture2DArray {
repeated Texture2D layers = 1;
bool multisampled = 2;
}

// Texture3D represents a three-dimensional texture resource.
Expand Down

0 comments on commit 71a8a9b

Please sign in to comment.