layers: Split record/validation of Pipeline/Shaders
Disentangle pipeline state initialization from pipeline state
validation. Pipeline state is now const throughout validation, however
additional state is retained within the pipeline, which could better be
cached in the shader module, or instead pruned from the pipeline state
after creation.
Change-Id: I8e71e530fe1edab36ce5c31e6bd7c3ac55cde966
diff --git a/layers/shader_validation.h b/layers/shader_validation.h
index 36f54b0..6c399a4 100644
--- a/layers/shader_validation.h
+++ b/layers/shader_validation.h
@@ -20,6 +20,8 @@
#ifndef VULKAN_SHADER_VALIDATION_H
#define VULKAN_SHADER_VALIDATION_H
+#include <unordered_map>
+
#include <SPIRV/spirv.hpp>
#include <spirv_tools_commit_id.h>
#include "spirv-tools/optimizer.hpp"
@@ -30,7 +32,7 @@
std::vector<uint32_t>::const_iterator zero;
std::vector<uint32_t>::const_iterator it;
- uint32_t len() {
+ uint32_t len() const {
auto result = *it >> 16;
assert(result > 0);
return result;
@@ -38,7 +40,7 @@
uint32_t opcode() { return *it & 0x0ffffu; }
- uint32_t const &word(unsigned n) {
+ uint32_t const &word(unsigned n) const {
assert(n < len());
return it[n];
}
@@ -49,9 +51,9 @@
spirv_inst_iter(std::vector<uint32_t>::const_iterator zero, std::vector<uint32_t>::const_iterator it) : zero(zero), it(it) {}
- bool operator==(spirv_inst_iter const &other) { return it == other.it; }
+ bool operator==(spirv_inst_iter const &other) const { return it == other.it; }
- bool operator!=(spirv_inst_iter const &other) { return it != other.it; }
+ bool operator!=(spirv_inst_iter const &other) const { return it != other.it; }
spirv_inst_iter operator++(int) { // x++
spirv_inst_iter ii = *this;
@@ -75,6 +77,11 @@
// A mapping of <id> to the first word of its def. this is useful because walking type
// trees, constant expressions, etc requires jumping all over the instruction stream.
std::unordered_map<unsigned, unsigned> def_index;
+ struct EntryPoint {
+ uint32_t offset;
+ VkShaderStageFlags stage;
+ };
+ std::unordered_multimap<std::string, EntryPoint> entry_points;
bool has_valid_spirv;
VkShaderModule vk_shader_module;
uint32_t gpu_validation_shader_id;
@@ -244,6 +251,4 @@
}
};
-typedef std::pair<unsigned, unsigned> descriptor_slot_t;
-
#endif // VULKAN_SHADER_VALIDATION_H