mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 21:47:47 +00:00
Add texture_external parsing and intrinsic overloads
Adds texture_external to ParserImpl. Adds texture_external overloads to TextureSample, TextureLoad, and TextureDimensions to the intrisic table. Adds corresponding tests. Bug: dawn:728 Change-Id: I5e5557a10327f8c3d3044319decd748f812ecf3e Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48722 Reviewed-by: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
add325bb61
commit
145f865fb1
@@ -650,6 +650,9 @@ Token Lexer::check_keyword(const Source& source, const std::string& str) {
|
||||
return {Token::Type::kTextureDepthCubeArray, source,
|
||||
"texture_depth_cube_array"};
|
||||
}
|
||||
if (str == "texture_external") {
|
||||
return {Token::Type::kTextureExternal, source, "texture_external"};
|
||||
}
|
||||
if (str == "texture_multisampled_2d") {
|
||||
return {Token::Type::kTextureMultisampled2d, source,
|
||||
"texture_multisampled_2d"};
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "src/reader/wgsl/lexer.h"
|
||||
#include "src/sem/access_control_type.h"
|
||||
#include "src/sem/depth_texture_type.h"
|
||||
#include "src/sem/external_texture_type.h"
|
||||
#include "src/sem/multisampled_texture_type.h"
|
||||
#include "src/sem/sampled_texture_type.h"
|
||||
|
||||
@@ -516,6 +517,10 @@ Maybe<sem::Type*> ParserImpl::texture_sampler_types() {
|
||||
if (type.matched)
|
||||
return type.value;
|
||||
|
||||
type = external_texture_type();
|
||||
if (type.matched)
|
||||
return type.value;
|
||||
|
||||
auto dim = sampled_texture_type();
|
||||
if (dim.matched) {
|
||||
const char* use = "sampled texture type";
|
||||
@@ -600,6 +605,16 @@ Maybe<ast::TextureDimension> ParserImpl::sampled_texture_type() {
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
|
||||
// external_texture_type
|
||||
// : TEXTURE_EXTERNAL
|
||||
Maybe<sem::Type*> ParserImpl::external_texture_type() {
|
||||
if (match(Token::Type::kTextureExternal)) {
|
||||
return builder_.create<sem::ExternalTexture>();
|
||||
}
|
||||
|
||||
return Failure::kNoMatch;
|
||||
}
|
||||
|
||||
// multisampled_texture_type
|
||||
// : TEXTURE_MULTISAMPLED_2D
|
||||
Maybe<ast::TextureDimension> ParserImpl::multisampled_texture_type() {
|
||||
|
||||
@@ -414,6 +414,9 @@ class ParserImpl {
|
||||
/// Parses a `depth_texture_type` grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched.
|
||||
Maybe<sem::Type*> depth_texture_type();
|
||||
/// Parses a 'texture_external_type' grammar element
|
||||
/// @returns the parsed Type or nullptr if none matched
|
||||
Maybe<sem::Type*> external_texture_type();
|
||||
/// Parses a `image_storage_type` grammar element
|
||||
/// @param use a description of what was being parsed if an error was raised
|
||||
/// @returns returns the image format or kNone if none matched.
|
||||
|
||||
40
src/reader/wgsl/parser_impl_external_texture_type_test.cc
Normal file
40
src/reader/wgsl/parser_impl_external_texture_type_test.cc
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2021 The Tint Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "src/reader/wgsl/parser_impl_test_helper.h"
|
||||
|
||||
namespace tint {
|
||||
namespace reader {
|
||||
namespace wgsl {
|
||||
namespace {
|
||||
|
||||
TEST_F(ParserImplTest, ExternalTextureType_Invalid) {
|
||||
auto p = parser("1234");
|
||||
auto t = p->external_texture_type();
|
||||
EXPECT_FALSE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
EXPECT_FALSE(p->has_error());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, ExternalTextureType) {
|
||||
auto p = parser("texture_external");
|
||||
auto t = p->external_texture_type();
|
||||
EXPECT_TRUE(t.matched);
|
||||
EXPECT_FALSE(t.errored);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace wgsl
|
||||
} // namespace reader
|
||||
} // namespace tint
|
||||
@@ -269,6 +269,8 @@ std::string Token::TypeToName(Type type) {
|
||||
return "texture_depth_cube";
|
||||
case Token::Type::kTextureDepthCubeArray:
|
||||
return "texture_depth_cube_array";
|
||||
case Token::Type::kTextureExternal:
|
||||
return "texture_external";
|
||||
case Token::Type::kTextureMultisampled2d:
|
||||
return "texture_multisampled_2d";
|
||||
case Token::Type::kTextureSampled1d:
|
||||
|
||||
@@ -277,6 +277,8 @@ class Token {
|
||||
kTextureDepthCube,
|
||||
/// A 'texture_depth_cube_array'
|
||||
kTextureDepthCubeArray,
|
||||
/// A 'texture_external'
|
||||
kTextureExternal,
|
||||
/// A 'texture_multisampled_2d'
|
||||
kTextureMultisampled2d,
|
||||
/// A 'texture_1d'
|
||||
|
||||
Reference in New Issue
Block a user