mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-12-29 11:11:06 +00:00
51b0d5ce50
* Represent uniform facts via descriptor set and binding. Previously uniform facts were expressed with resepect to the id of a uniform variable. Describing them with respect to a descriptor set and binding is more convenient from the point of view of expressing facts about a shader without requiring analysis of its SPIR-V. * Fix equality testing for uniform buffer element descriptors. The equality test now checks that the lengths of the index vectors match. Added a test that exposes the previous omission.
54 lines
2.1 KiB
C++
54 lines
2.1 KiB
C++
// Copyright (c) 2019 Google LLC
|
|
//
|
|
// 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.
|
|
|
|
#ifndef SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_
|
|
#define SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_
|
|
|
|
#include <algorithm>
|
|
#include <vector>
|
|
|
|
#include "source/fuzz/protobufs/spirvfuzz_protobufs.h"
|
|
#include "source/opt/instruction.h"
|
|
#include "source/opt/ir_context.h"
|
|
|
|
namespace spvtools {
|
|
namespace fuzz {
|
|
|
|
// Factory method to create a uniform buffer element descriptor message from an
|
|
// id and list of indices.
|
|
protobufs::UniformBufferElementDescriptor MakeUniformBufferElementDescriptor(
|
|
uint32_t descriptor_set, uint32_t binding, std::vector<uint32_t>&& indices);
|
|
|
|
// Equality function for uniform buffer element descriptors.
|
|
struct UniformBufferElementDescriptorEquals {
|
|
bool operator()(
|
|
const protobufs::UniformBufferElementDescriptor* first,
|
|
const protobufs::UniformBufferElementDescriptor* second) const;
|
|
};
|
|
|
|
// Returns a pointer to an OpVariable in |context| that is decorated with the
|
|
// descriptor set and binding associated with |uniform_buffer_element|. Returns
|
|
// nullptr if no such variable exists. If multiple such variables exist, a
|
|
// pointer to an arbitrary one of the associated instructions is returned if
|
|
// |check_unique| is false, and nullptr is returned if |check_unique| is true.
|
|
opt::Instruction* FindUniformVariable(
|
|
const protobufs::UniformBufferElementDescriptor&
|
|
uniform_buffer_element_descriptor,
|
|
opt::IRContext* context, bool check_unique);
|
|
|
|
} // namespace fuzz
|
|
} // namespace spvtools
|
|
|
|
#endif // #define SOURCE_FUZZ_UNIFORM_BUFFER_ELEMENT_DESCRIPTOR_H_
|