aboutsummaryrefslogtreecommitdiff
path: root/src/pipeline.h
diff options
context:
space:
mode:
authorJames Price <jrprice@google.com>2020-03-18 11:19:21 -0400
committerGitHub <noreply@github.com>2020-03-18 11:19:21 -0400
commitc360eb6162d55cc80b33d48c6e03313fb3f5b072 (patch)
tree00a9510ea7d152fe4edbe046faf3562a82421c6e /src/pipeline.h
parent32aa3b89754243dad223508bdb18cc771d927164 (diff)
downloadamber-c360eb6162d55cc80b33d48c6e03313fb3f5b072.tar.gz
Add support for push constants generated by Clspv (#812)
When the -work-dim or -global-offset flags are passed to Clspv, it will generate push constants. The sizes and offsets of the push constant values are provided in the descriptor map. Amber needs to add these to the pipeline layout and create a buffer for them.
Diffstat (limited to 'src/pipeline.h')
-rw-r--r--src/pipeline.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/pipeline.h b/src/pipeline.h
index a25b184..b565eca 100644
--- a/src/pipeline.h
+++ b/src/pipeline.h
@@ -112,6 +112,24 @@ class Pipeline {
return descriptor_map_;
}
+ /// Push constant information for an OpenCL-C shader.
+ struct PushConstant {
+ enum class PushConstantType {
+ kDimensions = 0,
+ kGlobalOffset,
+ };
+ PushConstantType type;
+ uint32_t offset = 0;
+ uint32_t size = 0;
+ };
+
+ void AddPushConstant(PushConstant&& pc) {
+ push_constants_.emplace_back(std::move(pc));
+ }
+ const std::vector<PushConstant>& GetPushConstants() const {
+ return push_constants_;
+ }
+
private:
Shader* shader_ = nullptr;
ShaderType shader_type_;
@@ -121,6 +139,7 @@ class Pipeline {
std::map<uint32_t, uint32_t> specialization_;
std::unordered_map<std::string, std::vector<DescriptorMapEntry>>
descriptor_map_;
+ std::vector<PushConstant> push_constants_;
std::vector<std::string> compile_options_;
};
@@ -157,6 +176,7 @@ class Pipeline {
static const char* kGeneratedColorBuffer;
static const char* kGeneratedDepthBuffer;
+ static const char* kGeneratedPushConstantBuffer;
explicit Pipeline(PipelineType type);
~Pipeline();
@@ -318,6 +338,9 @@ class Pipeline {
/// descriptor map. This should be called after all other samplers are bound.
Result GenerateOpenCLLiteralSamplers();
+ /// Generate the push constant buffers necessary for OpenCL kernels.
+ Result GenerateOpenCLPushConstants();
+
private:
void UpdateFramebufferSizes();
@@ -346,6 +369,7 @@ class Pipeline {
/// Maps (descriptor set, binding) to the buffer for that binding pair.
std::map<std::pair<uint32_t, uint32_t>, Buffer*> opencl_pod_buffer_map_;
std::vector<std::unique_ptr<Sampler>> opencl_literal_samplers_;
+ std::unique_ptr<Buffer> opencl_push_constants_;
};
} // namespace amber