[graphite] Rename SkUniformBlock to SkPipelineData
and: UniformCache -> PipelineDataCache UniformCacheTest -> PipelineDataCacheTest Bug: skia:12701 Change-Id: Ia28c223edb8d741d15fa9fa83695ac6b99284d5e Reviewed-on: https://skia-review.googlesource.com/c/skia/+/514156 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
60c5837632
commit
b61366b54f
@ -25,7 +25,7 @@ class Recording;
|
|||||||
class ResourceProvider;
|
class ResourceProvider;
|
||||||
class Task;
|
class Task;
|
||||||
class TaskGraph;
|
class TaskGraph;
|
||||||
class UniformCache;
|
class PipelineDataCache;
|
||||||
|
|
||||||
class Recorder final {
|
class Recorder final {
|
||||||
public:
|
public:
|
||||||
@ -79,7 +79,7 @@ private:
|
|||||||
std::unique_ptr<ResourceProvider> fResourceProvider;
|
std::unique_ptr<ResourceProvider> fResourceProvider;
|
||||||
|
|
||||||
std::unique_ptr<TaskGraph> fGraph;
|
std::unique_ptr<TaskGraph> fGraph;
|
||||||
std::unique_ptr<UniformCache> fUniformCache;
|
std::unique_ptr<PipelineDataCache> fPipelineDataCache;
|
||||||
std::unique_ptr<DrawBufferManager> fDrawBufferManager;
|
std::unique_ptr<DrawBufferManager> fDrawBufferManager;
|
||||||
std::vector<Device*> fTrackedDevices;
|
std::vector<Device*> fTrackedDevices;
|
||||||
|
|
||||||
|
@ -21,22 +21,22 @@
|
|||||||
|
|
||||||
namespace skgpu {
|
namespace skgpu {
|
||||||
|
|
||||||
std::tuple<SkUniquePaintParamsID, std::unique_ptr<SkUniformBlock>> ExtractPaintData(
|
std::tuple<SkUniquePaintParamsID, std::unique_ptr<SkPipelineData>> ExtractPaintData(
|
||||||
SkShaderCodeDictionary* dict,
|
SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
const PaintParams& p) {
|
const PaintParams& p) {
|
||||||
|
|
||||||
SkDEBUGCODE(builder->checkReset());
|
SkDEBUGCODE(builder->checkReset());
|
||||||
|
|
||||||
std::unique_ptr<SkUniformBlock> block = std::make_unique<SkUniformBlock>();
|
std::unique_ptr<SkPipelineData> pipelineData = std::make_unique<SkPipelineData>();
|
||||||
|
|
||||||
p.toKey(dict, builder, block.get());
|
p.toKey(dict, builder, pipelineData.get());
|
||||||
|
|
||||||
SkPaintParamsKey key = builder->lockAsKey();
|
SkPaintParamsKey key = builder->lockAsKey();
|
||||||
|
|
||||||
auto entry = dict->findOrCreate(key);
|
auto entry = dict->findOrCreate(key);
|
||||||
|
|
||||||
return { entry->uniqueID(), std::move(block) };
|
return { entry->uniqueID(), std::move(pipelineData) };
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace skgpu
|
} // namespace skgpu
|
||||||
|
@ -15,16 +15,16 @@
|
|||||||
|
|
||||||
enum class CodeSnippetID : uint8_t;
|
enum class CodeSnippetID : uint8_t;
|
||||||
class SkPaintParamsKeyBuilder;
|
class SkPaintParamsKeyBuilder;
|
||||||
|
class SkPipelineData;
|
||||||
class SkShaderCodeDictionary;
|
class SkShaderCodeDictionary;
|
||||||
class SkUniform;
|
class SkUniform;
|
||||||
class SkUniformBlock;
|
|
||||||
class SkUniquePaintParamsID;
|
class SkUniquePaintParamsID;
|
||||||
|
|
||||||
namespace skgpu {
|
namespace skgpu {
|
||||||
|
|
||||||
class PaintParams;
|
class PaintParams;
|
||||||
|
|
||||||
std::tuple<SkUniquePaintParamsID, std::unique_ptr<SkUniformBlock>> ExtractPaintData(
|
std::tuple<SkUniquePaintParamsID, std::unique_ptr<SkPipelineData>> ExtractPaintData(
|
||||||
SkShaderCodeDictionary*,
|
SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
const PaintParams&);
|
const PaintParams&);
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
#include "experimental/graphite/src/GlobalCache.h"
|
#include "experimental/graphite/src/GlobalCache.h"
|
||||||
#include "experimental/graphite/src/GraphicsPipeline.h"
|
#include "experimental/graphite/src/GraphicsPipeline.h"
|
||||||
#include "experimental/graphite/src/GraphicsPipelineDesc.h"
|
#include "experimental/graphite/src/GraphicsPipelineDesc.h"
|
||||||
|
#include "experimental/graphite/src/PipelineDataCache.h"
|
||||||
#include "experimental/graphite/src/RecorderPriv.h"
|
#include "experimental/graphite/src/RecorderPriv.h"
|
||||||
#include "experimental/graphite/src/Renderer.h"
|
#include "experimental/graphite/src/Renderer.h"
|
||||||
#include "experimental/graphite/src/ResourceProvider.h"
|
#include "experimental/graphite/src/ResourceProvider.h"
|
||||||
#include "experimental/graphite/src/TextureProxy.h"
|
#include "experimental/graphite/src/TextureProxy.h"
|
||||||
#include "experimental/graphite/src/UniformCache.h"
|
|
||||||
#include "experimental/graphite/src/UniformManager.h"
|
#include "experimental/graphite/src/UniformManager.h"
|
||||||
#include "experimental/graphite/src/geom/BoundsManager.h"
|
#include "experimental/graphite/src/geom/BoundsManager.h"
|
||||||
|
|
||||||
@ -173,19 +173,22 @@ private:
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
// For now, we're treating the uniforms, samplers, and textures as a unit. That means that, in
|
||||||
|
// this cache, two pipelineData objects that have the same uniforms but different samplers or
|
||||||
|
// textures will be treated as distinct objects (and the uniforms will be uploaded twice).
|
||||||
class UniformBindingCache {
|
class UniformBindingCache {
|
||||||
public:
|
public:
|
||||||
UniformBindingCache(DrawBufferManager* bufferMgr, UniformCache* cache)
|
UniformBindingCache(DrawBufferManager* bufferMgr, PipelineDataCache* cache)
|
||||||
: fBufferMgr(bufferMgr), fCache(cache) {}
|
: fBufferMgr(bufferMgr), fCache(cache) {}
|
||||||
|
|
||||||
uint32_t addUniforms(std::unique_ptr<SkUniformBlock> uniformBlock) {
|
uint32_t addUniforms(std::unique_ptr<SkPipelineData> pipelineData) {
|
||||||
if (!uniformBlock || uniformBlock->empty()) {
|
if (!pipelineData || pipelineData->empty()) {
|
||||||
return UniformCache::kInvalidUniformID;
|
return PipelineDataCache::kInvalidUniformID;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t index = fCache->insert(std::move(uniformBlock));
|
uint32_t index = fCache->insert(std::move(pipelineData));
|
||||||
if (fBindings.find(index) == fBindings.end()) {
|
if (fBindings.find(index) == fBindings.end()) {
|
||||||
SkUniformBlock* tmp = fCache->lookup(index);
|
SkPipelineData* tmp = fCache->lookup(index);
|
||||||
// First time encountering this data, so upload to the GPU
|
// First time encountering this data, so upload to the GPU
|
||||||
size_t totalDataSize = tmp->totalSize();
|
size_t totalDataSize = tmp->totalSize();
|
||||||
auto [writer, bufferInfo] = fBufferMgr->getUniformWriter(totalDataSize);
|
auto [writer, bufferInfo] = fBufferMgr->getUniformWriter(totalDataSize);
|
||||||
@ -207,7 +210,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
DrawBufferManager* fBufferMgr;
|
DrawBufferManager* fBufferMgr;
|
||||||
UniformCache* fCache;
|
PipelineDataCache* fCache;
|
||||||
|
|
||||||
std::unordered_map<uint32_t, BindBufferInfo> fBindings;
|
std::unordered_map<uint32_t, BindBufferInfo> fBindings;
|
||||||
};
|
};
|
||||||
@ -275,9 +278,9 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
|||||||
Rect passBounds = Rect::InfiniteInverted();
|
Rect passBounds = Rect::InfiniteInverted();
|
||||||
|
|
||||||
DrawBufferManager* bufferMgr = recorder->priv().drawBufferManager();
|
DrawBufferManager* bufferMgr = recorder->priv().drawBufferManager();
|
||||||
UniformCache geometryUniforms;
|
PipelineDataCache geometryUniforms;
|
||||||
UniformBindingCache geometryUniformBindings(bufferMgr, &geometryUniforms);
|
UniformBindingCache geometryUniformBindings(bufferMgr, &geometryUniforms);
|
||||||
UniformBindingCache shadingUniformBindings(bufferMgr, recorder->priv().uniformCache());
|
UniformBindingCache shadingUniformBindings(bufferMgr, recorder->priv().pipelineDataCache());
|
||||||
|
|
||||||
std::unordered_map<const GraphicsPipelineDesc*, uint32_t, Hash, Eq> pipelineDescToIndex;
|
std::unordered_map<const GraphicsPipelineDesc*, uint32_t, Hash, Eq> pipelineDescToIndex;
|
||||||
|
|
||||||
@ -297,12 +300,12 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
|||||||
// bound independently of those used by the rest of the RenderStep, then we can upload now
|
// bound independently of those used by the rest of the RenderStep, then we can upload now
|
||||||
// and remember the location for re-use on any RenderStep that does shading.
|
// and remember the location for re-use on any RenderStep that does shading.
|
||||||
SkUniquePaintParamsID shaderID;
|
SkUniquePaintParamsID shaderID;
|
||||||
std::unique_ptr<SkUniformBlock> shadingUniforms;
|
std::unique_ptr<SkPipelineData> pipelineData;
|
||||||
uint32_t shadingIndex = UniformCache::kInvalidUniformID;
|
uint32_t shadingIndex = PipelineDataCache::kInvalidUniformID;
|
||||||
if (draw.fPaintParams.has_value()) {
|
if (draw.fPaintParams.has_value()) {
|
||||||
std::tie(shaderID, shadingUniforms) = ExtractPaintData(dict, &builder,
|
std::tie(shaderID, pipelineData) = ExtractPaintData(dict, &builder,
|
||||||
draw.fPaintParams.value());
|
draw.fPaintParams.value());
|
||||||
shadingIndex = shadingUniformBindings.addUniforms(std::move(shadingUniforms));
|
shadingIndex = shadingUniformBindings.addUniforms(std::move(pipelineData));
|
||||||
} // else depth-only
|
} // else depth-only
|
||||||
|
|
||||||
for (int stepIndex = 0; stepIndex < draw.fRenderer.numRenderSteps(); ++stepIndex) {
|
for (int stepIndex = 0; stepIndex < draw.fRenderer.numRenderSteps(); ++stepIndex) {
|
||||||
@ -310,13 +313,13 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
|||||||
const bool performsShading = draw.fPaintParams.has_value() && step->performsShading();
|
const bool performsShading = draw.fPaintParams.has_value() && step->performsShading();
|
||||||
|
|
||||||
SkUniquePaintParamsID stepShaderID;
|
SkUniquePaintParamsID stepShaderID;
|
||||||
uint32_t stepShadingIndex = UniformCache::kInvalidUniformID;
|
uint32_t stepShadingIndex = PipelineDataCache::kInvalidUniformID;
|
||||||
if (performsShading) {
|
if (performsShading) {
|
||||||
stepShaderID = shaderID;
|
stepShaderID = shaderID;
|
||||||
stepShadingIndex = shadingIndex;
|
stepShadingIndex = shadingIndex;
|
||||||
} // else depth-only draw or stencil-only step of renderer so no shading is needed
|
} // else depth-only draw or stencil-only step of renderer so no shading is needed
|
||||||
|
|
||||||
uint32_t geometryIndex = UniformCache::kInvalidUniformID;
|
uint32_t geometryIndex = PipelineDataCache::kInvalidUniformID;
|
||||||
if (step->numUniforms() > 0) {
|
if (step->numUniforms() > 0) {
|
||||||
// TODO: Get layout from the GPU
|
// TODO: Get layout from the GPU
|
||||||
auto uniforms = step->writeUniforms(Layout::kMetal,
|
auto uniforms = step->writeUniforms(Layout::kMetal,
|
||||||
@ -325,7 +328,7 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
|||||||
draw.fShape);
|
draw.fShape);
|
||||||
|
|
||||||
geometryIndex = geometryUniformBindings.addUniforms(
|
geometryIndex = geometryUniformBindings.addUniforms(
|
||||||
std::make_unique<SkUniformBlock>(std::move(uniforms)));
|
std::make_unique<SkPipelineData>(std::move(uniforms)));
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsPipelineDesc desc;
|
GraphicsPipelineDesc desc;
|
||||||
@ -366,8 +369,8 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
|||||||
// Used to track when a new pipeline or dynamic state needs recording between draw steps.
|
// Used to track when a new pipeline or dynamic state needs recording between draw steps.
|
||||||
// Setting to # render steps ensures the very first time through the loop will bind a pipeline.
|
// Setting to # render steps ensures the very first time through the loop will bind a pipeline.
|
||||||
uint32_t lastPipeline = draws->renderStepCount();
|
uint32_t lastPipeline = draws->renderStepCount();
|
||||||
uint32_t lastShadingUniforms = UniformCache::kInvalidUniformID;
|
uint32_t lastShadingUniforms = PipelineDataCache::kInvalidUniformID;
|
||||||
uint32_t lastGeometryUniforms = UniformCache::kInvalidUniformID;
|
uint32_t lastGeometryUniforms = PipelineDataCache::kInvalidUniformID;
|
||||||
SkIRect lastScissor = SkIRect::MakeSize(drawPass->fTarget->dimensions());
|
SkIRect lastScissor = SkIRect::MakeSize(drawPass->fTarget->dimensions());
|
||||||
|
|
||||||
for (const SortKey& key : keys) {
|
for (const SortKey& key : keys) {
|
||||||
@ -393,12 +396,12 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
|||||||
if (pipelineChange) {
|
if (pipelineChange) {
|
||||||
drawPass->fCommands.emplace_back(BindGraphicsPipeline{key.pipeline()});
|
drawPass->fCommands.emplace_back(BindGraphicsPipeline{key.pipeline()});
|
||||||
lastPipeline = key.pipeline();
|
lastPipeline = key.pipeline();
|
||||||
lastShadingUniforms = UniformCache::kInvalidUniformID;
|
lastShadingUniforms = PipelineDataCache::kInvalidUniformID;
|
||||||
lastGeometryUniforms = UniformCache::kInvalidUniformID;
|
lastGeometryUniforms = PipelineDataCache::kInvalidUniformID;
|
||||||
}
|
}
|
||||||
if (stateChange) {
|
if (stateChange) {
|
||||||
if (key.geometryUniforms() != lastGeometryUniforms) {
|
if (key.geometryUniforms() != lastGeometryUniforms) {
|
||||||
if (key.geometryUniforms() != UniformCache::kInvalidUniformID) {
|
if (key.geometryUniforms() != PipelineDataCache::kInvalidUniformID) {
|
||||||
auto binding = geometryUniformBindings.getBinding(key.geometryUniforms());
|
auto binding = geometryUniformBindings.getBinding(key.geometryUniforms());
|
||||||
drawPass->fCommands.emplace_back(
|
drawPass->fCommands.emplace_back(
|
||||||
BindUniformBuffer{binding, UniformSlot::kRenderStep});
|
BindUniformBuffer{binding, UniformSlot::kRenderStep});
|
||||||
@ -406,7 +409,7 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
|||||||
lastGeometryUniforms = key.geometryUniforms();
|
lastGeometryUniforms = key.geometryUniforms();
|
||||||
}
|
}
|
||||||
if (key.shadingUniforms() != lastShadingUniforms) {
|
if (key.shadingUniforms() != lastShadingUniforms) {
|
||||||
if (key.shadingUniforms() != UniformCache::kInvalidUniformID) {
|
if (key.shadingUniforms() != PipelineDataCache::kInvalidUniformID) {
|
||||||
auto binding = shadingUniformBindings.getBinding(key.shadingUniforms());
|
auto binding = shadingUniformBindings.getBinding(key.shadingUniforms());
|
||||||
drawPass->fCommands.emplace_back(
|
drawPass->fCommands.emplace_back(
|
||||||
BindUniformBuffer{binding, UniformSlot::kPaint});
|
BindUniformBuffer{binding, UniformSlot::kPaint});
|
||||||
|
@ -42,18 +42,18 @@ sk_sp<SkShader> PaintParams::refShader() const { return fShader; }
|
|||||||
|
|
||||||
void PaintParams::toKey(SkShaderCodeDictionary* dict,
|
void PaintParams::toKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
|
|
||||||
if (fShader) {
|
if (fShader) {
|
||||||
as_SB(fShader)->addToKey(dict, builder, uniformBlock);
|
as_SB(fShader)->addToKey(dict, builder, pipelineData);
|
||||||
} else {
|
} else {
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, fColor);
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData, fColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fBlender) {
|
if (fBlender) {
|
||||||
as_BB(fBlender)->addToKey(dict, builder, uniformBlock);
|
as_BB(fBlender)->addToKey(dict, builder, pipelineData);
|
||||||
} else {
|
} else {
|
||||||
BlendModeBlock::AddToKey(dict, builder, uniformBlock, SkBlendMode::kSrcOver);
|
BlendModeBlock::AddToKey(dict, builder, pipelineData, SkBlendMode::kSrcOver);
|
||||||
}
|
}
|
||||||
|
|
||||||
SkASSERT(builder->sizeInBytes() > 0);
|
SkASSERT(builder->sizeInBytes() > 0);
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
|
|
||||||
enum class SkBackend : uint8_t;
|
enum class SkBackend : uint8_t;
|
||||||
class SkPaintParamsKeyBuilder;
|
class SkPaintParamsKeyBuilder;
|
||||||
|
class SkPipelineData;
|
||||||
class SkShader;
|
class SkShader;
|
||||||
class SkShaderCodeDictionary;
|
class SkShaderCodeDictionary;
|
||||||
class SkUniformBlock;
|
|
||||||
|
|
||||||
namespace skgpu {
|
namespace skgpu {
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public:
|
|||||||
|
|
||||||
void toKey(SkShaderCodeDictionary*,
|
void toKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const;
|
SkPipelineData*) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SkColor4f fColor;
|
SkColor4f fColor;
|
||||||
|
@ -5,22 +5,22 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "experimental/graphite/src/UniformCache.h"
|
#include "experimental/graphite/src/PipelineDataCache.h"
|
||||||
|
|
||||||
#include "src/core/SkOpts.h"
|
#include "src/core/SkOpts.h"
|
||||||
#include "src/core/SkUniformData.h"
|
#include "src/core/SkUniformData.h"
|
||||||
|
|
||||||
namespace skgpu {
|
namespace skgpu {
|
||||||
|
|
||||||
size_t UniformCache::Hash::operator()(SkUniformBlock* ub) const {
|
size_t PipelineDataCache::Hash::operator()(SkPipelineData* pd) const {
|
||||||
if (!ub) {
|
if (!pd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ub->hash();
|
return pd->hash();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UniformCache::Eq::operator()(SkUniformBlock* a, SkUniformBlock* b) const {
|
bool PipelineDataCache::Eq::operator()(SkPipelineData* a, SkPipelineData* b) const {
|
||||||
if (!a || !b) {
|
if (!a || !b) {
|
||||||
return !a && !b;
|
return !a && !b;
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ bool UniformCache::Eq::operator()(SkUniformBlock* a, SkUniformBlock* b) const {
|
|||||||
return *a == *b;
|
return *a == *b;
|
||||||
};
|
};
|
||||||
|
|
||||||
UniformCache::UniformCache() {
|
PipelineDataCache::PipelineDataCache() {
|
||||||
// kInvalidUniformID is reserved
|
// kInvalidUniformID is reserved
|
||||||
static_assert(kInvalidUniformID == 0);
|
static_assert(kInvalidUniformID == 0);
|
||||||
fUniformBlock.push_back(nullptr);
|
fUniformBlock.push_back(nullptr);
|
||||||
@ -36,7 +36,7 @@ UniformCache::UniformCache() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
#ifdef SK_DEBUG
|
||||||
void UniformCache::validate() const {
|
void PipelineDataCache::validate() const {
|
||||||
for (size_t i = 0; i < fUniformBlock.size(); ++i) {
|
for (size_t i = 0; i < fUniformBlock.size(); ++i) {
|
||||||
auto kv = fUniformBlockIDs.find(fUniformBlock[i].get());
|
auto kv = fUniformBlockIDs.find(fUniformBlock[i].get());
|
||||||
SkASSERT(kv != fUniformBlockIDs.end());
|
SkASSERT(kv != fUniformBlockIDs.end());
|
||||||
@ -46,22 +46,22 @@ void UniformCache::validate() const {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t UniformCache::insert(std::unique_ptr<SkUniformBlock> block) {
|
uint32_t PipelineDataCache::insert(std::unique_ptr<SkPipelineData> pipelineData) {
|
||||||
auto kv = fUniformBlockIDs.find(block.get());
|
auto kv = fUniformBlockIDs.find(pipelineData.get());
|
||||||
if (kv != fUniformBlockIDs.end()) {
|
if (kv != fUniformBlockIDs.end()) {
|
||||||
return kv->second;
|
return kv->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t id = SkTo<uint32_t>(fUniformBlock.size());
|
uint32_t id = SkTo<uint32_t>(fUniformBlock.size());
|
||||||
SkASSERT(block && id != kInvalidUniformID);
|
SkASSERT(pipelineData && id != kInvalidUniformID);
|
||||||
|
|
||||||
fUniformBlockIDs.insert({block.get(), id});
|
fUniformBlockIDs.insert({pipelineData.get(), id});
|
||||||
fUniformBlock.push_back(std::move(block));
|
fUniformBlock.push_back(std::move(pipelineData));
|
||||||
this->validate();
|
this->validate();
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
SkUniformBlock* UniformCache::lookup(uint32_t uniqueID) {
|
SkPipelineData* PipelineDataCache::lookup(uint32_t uniqueID) {
|
||||||
SkASSERT(uniqueID < fUniformBlock.size());
|
SkASSERT(uniqueID < fUniformBlock.size());
|
||||||
return fUniformBlock[uniqueID].get();
|
return fUniformBlock[uniqueID].get();
|
||||||
}
|
}
|
@ -5,26 +5,26 @@
|
|||||||
* found in the LICENSE file.
|
* found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef skgpu_UniformCache_DEFINED
|
#ifndef skgpu_PipelineDataCache_DEFINED
|
||||||
#define skgpu_UniformCache_DEFINED
|
#define skgpu_PipelineDataCache_DEFINED
|
||||||
|
|
||||||
#include "include/core/SkRefCnt.h"
|
#include "include/core/SkRefCnt.h"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class SkUniformBlock;
|
class SkPipelineData;
|
||||||
|
|
||||||
namespace skgpu {
|
namespace skgpu {
|
||||||
|
|
||||||
|
|
||||||
class UniformCache {
|
class PipelineDataCache {
|
||||||
public:
|
public:
|
||||||
static constexpr uint32_t kInvalidUniformID = 0;
|
static constexpr uint32_t kInvalidUniformID = 0;
|
||||||
|
|
||||||
UniformCache();
|
PipelineDataCache();
|
||||||
|
|
||||||
// TODO: Revisit the UniformCache::insert and UniformData::Make APIs:
|
// TODO: Revisit the PipelineDataCache::insert and UniformData::Make APIs:
|
||||||
// 1. UniformData::Make requires knowing the data size up front, which involves two invocations
|
// 1. UniformData::Make requires knowing the data size up front, which involves two invocations
|
||||||
// of the UniformManager. Ideally, we could align uniforms on the fly into a dynamic buffer.
|
// of the UniformManager. Ideally, we could align uniforms on the fly into a dynamic buffer.
|
||||||
// 2. UniformData stores the offsets for each uniform, but these aren't needed after we've
|
// 2. UniformData stores the offsets for each uniform, but these aren't needed after we've
|
||||||
@ -45,9 +45,9 @@ public:
|
|||||||
|
|
||||||
// Add the block of uniform data to the cache and return a unique ID that corresponds to its
|
// Add the block of uniform data to the cache and return a unique ID that corresponds to its
|
||||||
// contents. If an identical block of data is already in the cache, that unique ID is returned.
|
// contents. If an identical block of data is already in the cache, that unique ID is returned.
|
||||||
uint32_t insert(std::unique_ptr<SkUniformBlock>);
|
uint32_t insert(std::unique_ptr<SkPipelineData>);
|
||||||
|
|
||||||
SkUniformBlock* lookup(uint32_t uniqueID);
|
SkPipelineData* lookup(uint32_t uniqueID);
|
||||||
|
|
||||||
// The number of unique UniformBlock objects in the cache
|
// The number of unique UniformBlock objects in the cache
|
||||||
size_t count() const {
|
size_t count() const {
|
||||||
@ -58,16 +58,16 @@ public:
|
|||||||
private:
|
private:
|
||||||
struct Hash {
|
struct Hash {
|
||||||
// This hash operator de-references and hashes the data contents
|
// This hash operator de-references and hashes the data contents
|
||||||
size_t operator()(SkUniformBlock*) const;
|
size_t operator()(SkPipelineData*) const;
|
||||||
};
|
};
|
||||||
struct Eq {
|
struct Eq {
|
||||||
// This equality operator de-references and compares the actual data contents
|
// This equality operator de-references and compares the actual data contents
|
||||||
bool operator()(SkUniformBlock*, SkUniformBlock*) const;
|
bool operator()(SkPipelineData*, SkPipelineData*) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The UniformBlock's unique ID is only unique w/in a Recorder _not_ globally
|
// The UniformBlock's unique ID is only unique w/in a Recorder _not_ globally
|
||||||
std::unordered_map<SkUniformBlock*, uint32_t, Hash, Eq> fUniformBlockIDs;
|
std::unordered_map<SkPipelineData*, uint32_t, Hash, Eq> fUniformBlockIDs;
|
||||||
std::vector<std::unique_ptr<SkUniformBlock>> fUniformBlock;
|
std::vector<std::unique_ptr<SkPipelineData>> fUniformBlock;
|
||||||
|
|
||||||
#ifdef SK_DEBUG
|
#ifdef SK_DEBUG
|
||||||
void validate() const;
|
void validate() const;
|
||||||
@ -78,4 +78,4 @@ private:
|
|||||||
|
|
||||||
} // namespace skgpu
|
} // namespace skgpu
|
||||||
|
|
||||||
#endif // skgpu_UniformCache_DEFINED
|
#endif // skgpu_PipelineDataCache_DEFINED
|
@ -15,9 +15,9 @@
|
|||||||
#include "experimental/graphite/src/DrawBufferManager.h"
|
#include "experimental/graphite/src/DrawBufferManager.h"
|
||||||
#include "experimental/graphite/src/GlobalCache.h"
|
#include "experimental/graphite/src/GlobalCache.h"
|
||||||
#include "experimental/graphite/src/Gpu.h"
|
#include "experimental/graphite/src/Gpu.h"
|
||||||
|
#include "experimental/graphite/src/PipelineDataCache.h"
|
||||||
#include "experimental/graphite/src/ResourceProvider.h"
|
#include "experimental/graphite/src/ResourceProvider.h"
|
||||||
#include "experimental/graphite/src/TaskGraph.h"
|
#include "experimental/graphite/src/TaskGraph.h"
|
||||||
#include "experimental/graphite/src/UniformCache.h"
|
|
||||||
#include "src/core/SkUniformData.h"
|
#include "src/core/SkUniformData.h"
|
||||||
|
|
||||||
namespace skgpu {
|
namespace skgpu {
|
||||||
@ -27,7 +27,7 @@ namespace skgpu {
|
|||||||
Recorder::Recorder(sk_sp<Gpu> gpu, sk_sp<GlobalCache> globalCache)
|
Recorder::Recorder(sk_sp<Gpu> gpu, sk_sp<GlobalCache> globalCache)
|
||||||
: fGpu(std::move(gpu))
|
: fGpu(std::move(gpu))
|
||||||
, fGraph(new TaskGraph)
|
, fGraph(new TaskGraph)
|
||||||
, fUniformCache(new UniformCache) {
|
, fPipelineDataCache(new PipelineDataCache) {
|
||||||
|
|
||||||
fResourceProvider = fGpu->makeResourceProvider(std::move(globalCache), this->singleOwner());
|
fResourceProvider = fGpu->makeResourceProvider(std::move(globalCache), this->singleOwner());
|
||||||
fDrawBufferManager.reset(new DrawBufferManager(fResourceProvider.get(),
|
fDrawBufferManager.reset(new DrawBufferManager(fResourceProvider.get(),
|
||||||
|
@ -18,8 +18,8 @@ ResourceProvider* RecorderPriv::resourceProvider() const {
|
|||||||
return fRecorder->fResourceProvider.get();
|
return fRecorder->fResourceProvider.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
UniformCache* RecorderPriv::uniformCache() const {
|
PipelineDataCache* RecorderPriv::pipelineDataCache() const {
|
||||||
return fRecorder->fUniformCache.get();
|
return fRecorder->fPipelineDataCache.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Caps* RecorderPriv::caps() const {
|
const Caps* RecorderPriv::caps() const {
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
void add(sk_sp<Task>);
|
void add(sk_sp<Task>);
|
||||||
|
|
||||||
ResourceProvider* resourceProvider() const;
|
ResourceProvider* resourceProvider() const;
|
||||||
UniformCache* uniformCache() const;
|
PipelineDataCache* pipelineDataCache() const;
|
||||||
DrawBufferManager* drawBufferManager() const;
|
DrawBufferManager* drawBufferManager() const;
|
||||||
const Caps* caps() const;
|
const Caps* caps() const;
|
||||||
|
|
||||||
|
@ -64,6 +64,8 @@ skia_graphite_sources = [
|
|||||||
"$_src/Log.h",
|
"$_src/Log.h",
|
||||||
"$_src/PaintParams.cpp",
|
"$_src/PaintParams.cpp",
|
||||||
"$_src/PaintParams.h",
|
"$_src/PaintParams.h",
|
||||||
|
"$_src/PipelineDataCache.cpp",
|
||||||
|
"$_src/PipelineDataCache.h",
|
||||||
"$_src/Recorder.cpp",
|
"$_src/Recorder.cpp",
|
||||||
"$_src/RecorderPriv.cpp",
|
"$_src/RecorderPriv.cpp",
|
||||||
"$_src/RecorderPriv.h",
|
"$_src/RecorderPriv.h",
|
||||||
@ -93,8 +95,6 @@ skia_graphite_sources = [
|
|||||||
"$_src/TextureProxy.cpp",
|
"$_src/TextureProxy.cpp",
|
||||||
"$_src/TextureProxy.h",
|
"$_src/TextureProxy.h",
|
||||||
"$_src/TextureProxyView.h",
|
"$_src/TextureProxyView.h",
|
||||||
"$_src/UniformCache.cpp",
|
|
||||||
"$_src/UniformCache.h",
|
|
||||||
"$_src/UniformManager.cpp",
|
"$_src/UniformManager.cpp",
|
||||||
"$_src/UniformManager.h",
|
"$_src/UniformManager.h",
|
||||||
"$_src/UploadTask.cpp",
|
"$_src/UploadTask.cpp",
|
||||||
|
@ -339,11 +339,11 @@ graphite_tests_sources = [
|
|||||||
"$_tests/graphite/IntersectionTreeTest.cpp",
|
"$_tests/graphite/IntersectionTreeTest.cpp",
|
||||||
"$_tests/graphite/KeyTest.cpp",
|
"$_tests/graphite/KeyTest.cpp",
|
||||||
"$_tests/graphite/MaskTest.cpp",
|
"$_tests/graphite/MaskTest.cpp",
|
||||||
|
"$_tests/graphite/PipelineDataCacheTest.cpp",
|
||||||
"$_tests/graphite/RecorderTest.cpp",
|
"$_tests/graphite/RecorderTest.cpp",
|
||||||
"$_tests/graphite/RectTest.cpp",
|
"$_tests/graphite/RectTest.cpp",
|
||||||
"$_tests/graphite/ShapeTest.cpp",
|
"$_tests/graphite/ShapeTest.cpp",
|
||||||
"$_tests/graphite/TransformTest.cpp",
|
"$_tests/graphite/TransformTest.cpp",
|
||||||
"$_tests/graphite/UniformCacheTest.cpp",
|
|
||||||
"$_tests/graphite/UniformTest.cpp",
|
"$_tests/graphite/UniformTest.cpp",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -66,12 +66,12 @@ sk_sp<SkBlender> SkBlender::Mode(SkBlendMode mode) {
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkBlenderBase::addToKey(SkShaderCodeDictionary* dict,
|
void SkBlenderBase::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
|
|
||||||
if (std::optional<SkBlendMode> bm = as_BB(this)->asBlendMode(); bm.has_value()) {
|
if (std::optional<SkBlendMode> bm = as_BB(this)->asBlendMode(); bm.has_value()) {
|
||||||
BlendModeBlock::AddToKey(dict, builder, uniformBlock, bm.value());
|
BlendModeBlock::AddToKey(dict, builder, pipelineData, bm.value());
|
||||||
} else {
|
} else {
|
||||||
BlendModeBlock::AddToKey(dict, builder, uniformBlock, SkBlendMode::kSrcOver);
|
BlendModeBlock::AddToKey(dict, builder, pipelineData, SkBlendMode::kSrcOver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,9 +19,9 @@ enum class SkBackend : uint8_t;
|
|||||||
struct GrFPArgs;
|
struct GrFPArgs;
|
||||||
class GrFragmentProcessor;
|
class GrFragmentProcessor;
|
||||||
class SkPaintParamsKeyBuilder;
|
class SkPaintParamsKeyBuilder;
|
||||||
|
class SkPipelineData;
|
||||||
class SkRuntimeEffect;
|
class SkRuntimeEffect;
|
||||||
class SkShaderCodeDictionary;
|
class SkShaderCodeDictionary;
|
||||||
class SkUniformBlock;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encapsulates a blend function, including non-public APIs.
|
* Encapsulates a blend function, including non-public APIs.
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
// TODO: make pure virtual
|
// TODO: make pure virtual
|
||||||
virtual void addToKey(SkShaderCodeDictionary*,
|
virtual void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const;
|
SkPipelineData*) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static SkFlattenable::Type GetFlattenableType() { return kSkBlender_Type; }
|
static SkFlattenable::Type GetFlattenableType() { return kSkBlender_Type; }
|
||||||
|
@ -48,7 +48,7 @@ static const int kBlockDataSize = 0;
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary* /* dict */,
|
void AddToKey(SkShaderCodeDictionary* /* dict */,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* /* uniformBlock */) {
|
SkPipelineData* /* pipelineData */) {
|
||||||
builder->beginBlock(SkBuiltInCodeSnippetID::kDepthStencilOnlyDraw);
|
builder->beginBlock(SkBuiltInCodeSnippetID::kDepthStencilOnlyDraw);
|
||||||
builder->endBlock();
|
builder->endBlock();
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ sk_sp<SkUniformData> make_solid_uniform_data(SkShaderCodeDictionary* dict, SkCol
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary* dict,
|
void AddToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock,
|
SkPipelineData* pipelineData,
|
||||||
const SkColor4f& color) {
|
const SkColor4f& color) {
|
||||||
|
|
||||||
#ifdef SK_GRAPHITE_ENABLED
|
#ifdef SK_GRAPHITE_ENABLED
|
||||||
@ -102,8 +102,8 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
SkBuiltInCodeSnippetID::kSolidColorShader,
|
SkBuiltInCodeSnippetID::kSolidColorShader,
|
||||||
kBlockDataSize);
|
kBlockDataSize);
|
||||||
|
|
||||||
if (uniformBlock) {
|
if (pipelineData) {
|
||||||
uniformBlock->add(make_solid_uniform_data(dict, color));
|
pipelineData->add(make_solid_uniform_data(dict, color));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -272,7 +272,7 @@ GradientData::GradientData(SkShader::GradientType type,
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary* dict,
|
void AddToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder *builder,
|
SkPaintParamsKeyBuilder *builder,
|
||||||
SkUniformBlock* uniformBlock,
|
SkPipelineData* pipelineData,
|
||||||
const GradientData& gradData) {
|
const GradientData& gradData) {
|
||||||
|
|
||||||
#ifdef SK_GRAPHITE_ENABLED
|
#ifdef SK_GRAPHITE_ENABLED
|
||||||
@ -281,26 +281,26 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
switch (gradData.fType) {
|
switch (gradData.fType) {
|
||||||
case SkShader::kLinear_GradientType:
|
case SkShader::kLinear_GradientType:
|
||||||
codeSnippetID = SkBuiltInCodeSnippetID::kLinearGradientShader;
|
codeSnippetID = SkBuiltInCodeSnippetID::kLinearGradientShader;
|
||||||
if (uniformBlock) {
|
if (pipelineData) {
|
||||||
uniformBlock->add(make_linear_gradient_uniform_data(dict, gradData));
|
pipelineData->add(make_linear_gradient_uniform_data(dict, gradData));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SkShader::kRadial_GradientType:
|
case SkShader::kRadial_GradientType:
|
||||||
codeSnippetID = SkBuiltInCodeSnippetID::kRadialGradientShader;
|
codeSnippetID = SkBuiltInCodeSnippetID::kRadialGradientShader;
|
||||||
if (uniformBlock) {
|
if (pipelineData) {
|
||||||
uniformBlock->add(make_radial_gradient_uniform_data(dict, gradData));
|
pipelineData->add(make_radial_gradient_uniform_data(dict, gradData));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SkShader::kSweep_GradientType:
|
case SkShader::kSweep_GradientType:
|
||||||
codeSnippetID = SkBuiltInCodeSnippetID::kSweepGradientShader;
|
codeSnippetID = SkBuiltInCodeSnippetID::kSweepGradientShader;
|
||||||
if (uniformBlock) {
|
if (pipelineData) {
|
||||||
uniformBlock->add(make_sweep_gradient_uniform_data(dict, gradData));
|
pipelineData->add(make_sweep_gradient_uniform_data(dict, gradData));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SkShader::GradientType::kConical_GradientType:
|
case SkShader::GradientType::kConical_GradientType:
|
||||||
codeSnippetID = SkBuiltInCodeSnippetID::kConicalGradientShader;
|
codeSnippetID = SkBuiltInCodeSnippetID::kConicalGradientShader;
|
||||||
if (uniformBlock) {
|
if (pipelineData) {
|
||||||
uniformBlock->add(make_conical_gradient_uniform_data(dict, gradData));
|
pipelineData->add(make_conical_gradient_uniform_data(dict, gradData));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SkShader::GradientType::kColor_GradientType:
|
case SkShader::GradientType::kColor_GradientType:
|
||||||
@ -324,7 +324,7 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
|
|
||||||
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
||||||
// TODO: add implementation of other backends
|
// TODO: add implementation of other backends
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, SkColors::kRed);
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData, SkColors::kRed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -362,7 +362,7 @@ sk_sp<SkUniformData> make_image_uniform_data(SkShaderCodeDictionary* dict,
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary* dict,
|
void AddToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock,
|
SkPipelineData* pipelineData,
|
||||||
const ImageData& imgData) {
|
const ImageData& imgData) {
|
||||||
|
|
||||||
#ifdef SK_GRAPHITE_ENABLED
|
#ifdef SK_GRAPHITE_ENABLED
|
||||||
@ -377,8 +377,8 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
|
|
||||||
builder->endBlock();
|
builder->endBlock();
|
||||||
|
|
||||||
if (uniformBlock) {
|
if (pipelineData) {
|
||||||
uniformBlock->add(make_image_uniform_data(dict, imgData));
|
pipelineData->add(make_image_uniform_data(dict, imgData));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -386,7 +386,7 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
|
|
||||||
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
||||||
// TODO: add implementation for other backends
|
// TODO: add implementation for other backends
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, SkColors::kRed);
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData, SkColors::kRed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ sk_sp<SkUniformData> make_blendshader_uniform_data(SkShaderCodeDictionary* dict,
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary* dict,
|
void AddToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder *builder,
|
SkPaintParamsKeyBuilder *builder,
|
||||||
SkUniformBlock* uniformBlock,
|
SkPipelineData* pipelineData,
|
||||||
const BlendData& blendData) {
|
const BlendData& blendData) {
|
||||||
|
|
||||||
#ifdef SK_GRAPHITE_ENABLED
|
#ifdef SK_GRAPHITE_ENABLED
|
||||||
@ -432,8 +432,8 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
// When extracted into SkShaderInfo::SnippetEntries the children will appear after their
|
// When extracted into SkShaderInfo::SnippetEntries the children will appear after their
|
||||||
// parent. Thus, the parent's uniform data must appear in the uniform block before the
|
// parent. Thus, the parent's uniform data must appear in the uniform block before the
|
||||||
// uniform data of the children.
|
// uniform data of the children.
|
||||||
if (uniformBlock) {
|
if (pipelineData) {
|
||||||
uniformBlock->add(make_blendshader_uniform_data(dict, blendData.fBM));
|
pipelineData->add(make_blendshader_uniform_data(dict, blendData.fBM));
|
||||||
}
|
}
|
||||||
|
|
||||||
builder->beginBlock(SkBuiltInCodeSnippetID::kBlendShader);
|
builder->beginBlock(SkBuiltInCodeSnippetID::kBlendShader);
|
||||||
@ -442,11 +442,11 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
// TODO: add startChild/endChild entry points to SkPaintParamsKeyBuilder. They could be
|
// TODO: add startChild/endChild entry points to SkPaintParamsKeyBuilder. They could be
|
||||||
// used to compute and store the number of children w/in a block's header.
|
// used to compute and store the number of children w/in a block's header.
|
||||||
int start = builder->sizeInBytes();
|
int start = builder->sizeInBytes();
|
||||||
as_SB(blendData.fDst)->addToKey(dict, builder, uniformBlock);
|
as_SB(blendData.fDst)->addToKey(dict, builder, pipelineData);
|
||||||
int firstShaderSize = builder->sizeInBytes() - start;
|
int firstShaderSize = builder->sizeInBytes() - start;
|
||||||
|
|
||||||
start = builder->sizeInBytes();
|
start = builder->sizeInBytes();
|
||||||
as_SB(blendData.fSrc)->addToKey(dict, builder, uniformBlock);
|
as_SB(blendData.fSrc)->addToKey(dict, builder, pipelineData);
|
||||||
int secondShaderSize = builder->sizeInBytes() - start;
|
int secondShaderSize = builder->sizeInBytes() - start;
|
||||||
|
|
||||||
builder->endBlock();
|
builder->endBlock();
|
||||||
@ -461,7 +461,7 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
|
|
||||||
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
||||||
// TODO: add implementation for other backends
|
// TODO: add implementation for other backends
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, SkColors::kRed);
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData, SkColors::kRed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -476,7 +476,7 @@ static const int kBlockDataSize = 1;
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary* dict,
|
void AddToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder *builder,
|
SkPaintParamsKeyBuilder *builder,
|
||||||
SkUniformBlock* uniformBlock,
|
SkPipelineData* pipelineData,
|
||||||
SkBlendMode bm) {
|
SkBlendMode bm) {
|
||||||
|
|
||||||
#ifdef SK_GRAPHITE_ENABLED
|
#ifdef SK_GRAPHITE_ENABLED
|
||||||
@ -494,7 +494,7 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
|||||||
|
|
||||||
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
if (builder->backend() == SkBackend::kSkVM || builder->backend() == SkBackend::kGanesh) {
|
||||||
// TODO: add implementation for other backends
|
// TODO: add implementation for other backends
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, SkColors::kRed);
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData, SkColors::kRed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ enum class SkBackend : uint8_t;
|
|||||||
class SkPaintParamsKey;
|
class SkPaintParamsKey;
|
||||||
class SkPaintParamsKeyBuilder;
|
class SkPaintParamsKeyBuilder;
|
||||||
class SkShaderCodeDictionary;
|
class SkShaderCodeDictionary;
|
||||||
class SkUniformBlock;
|
class SkPipelineData;
|
||||||
|
|
||||||
// The KeyHelpers can be used to manually construct an SkPaintParamsKey
|
// The KeyHelpers can be used to manually construct an SkPaintParamsKey
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ namespace DepthStencilOnlyBlock {
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary*,
|
void AddToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*);
|
SkPipelineData*);
|
||||||
|
|
||||||
} // namespace DepthStencilOnlyBlock
|
} // namespace DepthStencilOnlyBlock
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ namespace SolidColorShaderBlock {
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary*,
|
void AddToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*,
|
SkPipelineData*,
|
||||||
const SkColor4f&);
|
const SkColor4f&);
|
||||||
|
|
||||||
} // namespace SolidColorShaderBlock
|
} // namespace SolidColorShaderBlock
|
||||||
@ -89,7 +89,7 @@ namespace GradientShaderBlocks {
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary*,
|
void AddToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*,
|
SkPipelineData*,
|
||||||
const GradientData&);
|
const GradientData&);
|
||||||
|
|
||||||
} // namespace GradientShaderBlocks
|
} // namespace GradientShaderBlocks
|
||||||
@ -110,7 +110,7 @@ namespace ImageShaderBlock {
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary*,
|
void AddToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*,
|
SkPipelineData*,
|
||||||
const ImageData&);
|
const ImageData&);
|
||||||
|
|
||||||
} // namespace ImageShaderBlock
|
} // namespace ImageShaderBlock
|
||||||
@ -126,7 +126,7 @@ namespace BlendShaderBlock {
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary*,
|
void AddToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*,
|
SkPipelineData*,
|
||||||
const BlendData&);
|
const BlendData&);
|
||||||
|
|
||||||
} // namespace BlendShaderBlock
|
} // namespace BlendShaderBlock
|
||||||
@ -135,7 +135,7 @@ namespace BlendModeBlock {
|
|||||||
|
|
||||||
void AddToKey(SkShaderCodeDictionary*,
|
void AddToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*,
|
SkPipelineData*,
|
||||||
SkBlendMode);
|
SkBlendMode);
|
||||||
|
|
||||||
} // namespace BlendModeBlock
|
} // namespace BlendModeBlock
|
||||||
|
@ -30,11 +30,11 @@ bool SkUniformData::operator==(const SkUniformData& other) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
void SkUniformBlock::add(sk_sp<SkUniformData> uniforms) {
|
void SkPipelineData::add(sk_sp<SkUniformData> uniforms) {
|
||||||
fUniformData.push_back(std::move(uniforms));
|
fUniformData.push_back(std::move(uniforms));
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SkUniformBlock::totalSize() const {
|
size_t SkPipelineData::totalSize() const {
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
|
|
||||||
// TODO: It seems like we need to worry about alignment between the separate sets of uniforms
|
// TODO: It seems like we need to worry about alignment between the separate sets of uniforms
|
||||||
@ -45,7 +45,7 @@ size_t SkUniformBlock::totalSize() const {
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SkUniformBlock::count() const {
|
int SkPipelineData::count() const {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
for (auto& u : fUniformData) {
|
for (auto& u : fUniformData) {
|
||||||
@ -55,7 +55,7 @@ int SkUniformBlock::count() const {
|
|||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SkUniformBlock::operator==(const SkUniformBlock& other) const {
|
bool SkPipelineData::operator==(const SkPipelineData& other) const {
|
||||||
if (fUniformData.size() != other.fUniformData.size()) {
|
if (fUniformData.size() != other.fUniformData.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ bool SkUniformBlock::operator==(const SkUniformBlock& other) const {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SkUniformBlock::hash() const {
|
size_t SkPipelineData::hash() const {
|
||||||
int32_t hash = 0;
|
int32_t hash = 0;
|
||||||
|
|
||||||
for (auto& u : fUniformData) {
|
for (auto& u : fUniformData) {
|
||||||
|
@ -73,14 +73,14 @@ private:
|
|||||||
const size_t fDataSize;
|
const size_t fDataSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: The current plan for fixing uniform padding is for the SkUniformBlock to hold a
|
// TODO: The current plan for fixing uniform padding is for the SkPipelineData to hold a
|
||||||
// persistent uniformManager. A stretch goal for this system would be for this combination
|
// persistent uniformManager. A stretch goal for this system would be for this combination
|
||||||
// to accumulate all the uniforms and then rearrange them to minimize padding. This would,
|
// to accumulate all the uniforms and then rearrange them to minimize padding. This would,
|
||||||
// obviously, vastly complicate uniform accumulation.
|
// obviously, vastly complicate uniform accumulation.
|
||||||
class SkUniformBlock {
|
class SkPipelineData {
|
||||||
public:
|
public:
|
||||||
SkUniformBlock() = default;
|
SkPipelineData() = default;
|
||||||
SkUniformBlock(sk_sp<SkUniformData> initial) {
|
SkPipelineData(sk_sp<SkUniformData> initial) {
|
||||||
fUniformData.push_back(std::move(initial));
|
fUniformData.push_back(std::move(initial));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +90,8 @@ public:
|
|||||||
size_t totalSize() const; // TODO: cache this?
|
size_t totalSize() const; // TODO: cache this?
|
||||||
int count() const; // TODO: cache this?
|
int count() const; // TODO: cache this?
|
||||||
|
|
||||||
bool operator==(const SkUniformBlock&) const;
|
bool operator==(const SkPipelineData&) const;
|
||||||
bool operator!=(const SkUniformBlock& other) const { return !(*this == other); }
|
bool operator!=(const SkPipelineData& other) const { return !(*this == other); }
|
||||||
size_t hash() const;
|
size_t hash() const;
|
||||||
|
|
||||||
using container = std::vector<sk_sp<SkUniformData>>;
|
using container = std::vector<sk_sp<SkUniformData>>;
|
||||||
|
@ -143,14 +143,14 @@ std::unique_ptr<GrFragmentProcessor> SkColor4Shader::asFragmentProcessor(
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkColorShader::addToKey(SkShaderCodeDictionary* dict,
|
void SkColorShader::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock,
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData,
|
||||||
SkColor4f::FromColor(fColor));
|
SkColor4f::FromColor(fColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkColor4Shader::addToKey(SkShaderCodeDictionary* dict,
|
void SkColor4Shader::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, fColor);
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData, fColor);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -72,7 +72,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -195,10 +195,10 @@ std::unique_ptr<GrFragmentProcessor> SkShader_Blend::asFragmentProcessor(
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkShader_Blend::addToKey(SkShaderCodeDictionary* dict,
|
void SkShader_Blend::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
// TODO: add blender support
|
// TODO: add blender support
|
||||||
SkASSERT(!fBlender);
|
SkASSERT(!fBlender);
|
||||||
|
|
||||||
BlendShaderBlock::AddToKey(dict, builder, uniformBlock, { fDst.get(), fSrc.get(), fMode });
|
BlendShaderBlock::AddToKey(dict, builder, pipelineData, { fDst.get(), fSrc.get(), fMode });
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -379,8 +379,8 @@ std::unique_ptr<GrFragmentProcessor> SkImageShader::asFragmentProcessor(
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkImageShader::addToKey(SkShaderCodeDictionary* dict,
|
void SkImageShader::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
ImageShaderBlock::AddToKey(dict, builder, uniformBlock, { fTileModeX, fTileModeY });
|
ImageShaderBlock::AddToKey(dict, builder, pipelineData, { fTileModeX, fTileModeY });
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
static SkM44 CubicResamplerMatrix(float B, float C);
|
static SkM44 CubicResamplerMatrix(float B, float C);
|
||||||
|
|
||||||
|
@ -156,8 +156,8 @@ SkUpdatableShader* SkShaderBase::onUpdatableShader(SkArenaAlloc* alloc) const {
|
|||||||
// TODO: add implementations for derived classes
|
// TODO: add implementations for derived classes
|
||||||
void SkShaderBase::addToKey(SkShaderCodeDictionary* dict,
|
void SkShaderBase::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
SolidColorShaderBlock::AddToKey(dict, builder, uniformBlock, SkColors::kRed);
|
SolidColorShaderBlock::AddToKey(dict, builder, pipelineData, SkColors::kRed);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,10 +30,10 @@ class SkImage;
|
|||||||
struct SkImageInfo;
|
struct SkImageInfo;
|
||||||
class SkPaint;
|
class SkPaint;
|
||||||
class SkPaintParamsKeyBuilder;
|
class SkPaintParamsKeyBuilder;
|
||||||
|
class SkPipelineData;
|
||||||
class SkRasterPipeline;
|
class SkRasterPipeline;
|
||||||
class SkRuntimeEffect;
|
class SkRuntimeEffect;
|
||||||
class SkShaderCodeDictionary;
|
class SkShaderCodeDictionary;
|
||||||
class SkUniformBlock;
|
|
||||||
class SkStageUpdater;
|
class SkStageUpdater;
|
||||||
|
|
||||||
class SkUpdatableShader;
|
class SkUpdatableShader;
|
||||||
@ -221,11 +221,11 @@ public:
|
|||||||
|
|
||||||
@param dictionary dictionary of code fragments available to be used in the key
|
@param dictionary dictionary of code fragments available to be used in the key
|
||||||
@param builder builder for creating the key for this SkShader
|
@param builder builder for creating the key for this SkShader
|
||||||
@param uniformBlock if non-null, storage for this shader's uniform data
|
@param pipelineData if non-null, storage for this shader's data
|
||||||
*/
|
*/
|
||||||
virtual void addToKey(SkShaderCodeDictionary* dictionary,
|
virtual void addToKey(SkShaderCodeDictionary* dictionary,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const;
|
SkPipelineData* pipelineData) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -111,7 +111,7 @@ std::unique_ptr<GrFragmentProcessor> SkLinearGradient::asFragmentProcessor(
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkLinearGradient::addToKey(SkShaderCodeDictionary* dict,
|
void SkLinearGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
GradientShaderBlocks::GradientData data(kLinear_GradientType,
|
GradientShaderBlocks::GradientData data(kLinear_GradientType,
|
||||||
fStart, fEnd,
|
fStart, fEnd,
|
||||||
0.0f, 0.0f,
|
0.0f, 0.0f,
|
||||||
@ -120,6 +120,6 @@ void SkLinearGradient::addToKey(SkShaderCodeDictionary* dict,
|
|||||||
fOrigColors4f,
|
fOrigColors4f,
|
||||||
fOrigPos);
|
fOrigPos);
|
||||||
|
|
||||||
GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data);
|
GradientShaderBlocks::AddToKey(dict, builder, pipelineData, data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -89,7 +89,7 @@ std::unique_ptr<GrFragmentProcessor> SkRadialGradient::asFragmentProcessor(
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkRadialGradient::addToKey(SkShaderCodeDictionary* dict,
|
void SkRadialGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
GradientShaderBlocks::GradientData data(kRadial_GradientType,
|
GradientShaderBlocks::GradientData data(kRadial_GradientType,
|
||||||
fCenter, { 0.0f, 0.0f },
|
fCenter, { 0.0f, 0.0f },
|
||||||
fRadius, 0.0f,
|
fRadius, 0.0f,
|
||||||
@ -98,6 +98,6 @@ void SkRadialGradient::addToKey(SkShaderCodeDictionary* dict,
|
|||||||
fOrigColors4f,
|
fOrigColors4f,
|
||||||
fOrigPos);
|
fOrigPos);
|
||||||
|
|
||||||
GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data);
|
GradientShaderBlocks::AddToKey(dict, builder, pipelineData, data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,7 +23,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
SkRadialGradient(SkReadBuffer& buffer);
|
SkRadialGradient(SkReadBuffer& buffer);
|
||||||
|
@ -113,7 +113,7 @@ std::unique_ptr<GrFragmentProcessor> SkSweepGradient::asFragmentProcessor(
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkSweepGradient::addToKey(SkShaderCodeDictionary* dict,
|
void SkSweepGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
GradientShaderBlocks::GradientData data(kSweep_GradientType,
|
GradientShaderBlocks::GradientData data(kSweep_GradientType,
|
||||||
fCenter, { 0.0f, 0.0f },
|
fCenter, { 0.0f, 0.0f },
|
||||||
0.0, 0.0f,
|
0.0, 0.0f,
|
||||||
@ -122,6 +122,6 @@ void SkSweepGradient::addToKey(SkShaderCodeDictionary* dict,
|
|||||||
fOrigColors4f,
|
fOrigColors4f,
|
||||||
fOrigPos);
|
fOrigPos);
|
||||||
|
|
||||||
GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data);
|
GradientShaderBlocks::AddToKey(dict, builder, pipelineData, data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SkScalar getTBias() const { return fTBias; }
|
SkScalar getTBias() const { return fTBias; }
|
||||||
|
@ -283,7 +283,7 @@ std::unique_ptr<GrFragmentProcessor> SkTwoPointConicalGradient::asFragmentProces
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void SkTwoPointConicalGradient::addToKey(SkShaderCodeDictionary* dict,
|
void SkTwoPointConicalGradient::addToKey(SkShaderCodeDictionary* dict,
|
||||||
SkPaintParamsKeyBuilder* builder,
|
SkPaintParamsKeyBuilder* builder,
|
||||||
SkUniformBlock* uniformBlock) const {
|
SkPipelineData* pipelineData) const {
|
||||||
GradientShaderBlocks::GradientData data(kConical_GradientType,
|
GradientShaderBlocks::GradientData data(kConical_GradientType,
|
||||||
fCenter1, fCenter2,
|
fCenter1, fCenter2,
|
||||||
fRadius1, fRadius2,
|
fRadius1, fRadius2,
|
||||||
@ -292,6 +292,6 @@ void SkTwoPointConicalGradient::addToKey(SkShaderCodeDictionary* dict,
|
|||||||
fOrigColors4f,
|
fOrigColors4f,
|
||||||
fOrigPos);
|
fOrigPos);
|
||||||
|
|
||||||
GradientShaderBlocks::AddToKey(dict, builder, uniformBlock, data);
|
GradientShaderBlocks::AddToKey(dict, builder, pipelineData, data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
#ifdef SK_ENABLE_SKSL
|
#ifdef SK_ENABLE_SKSL
|
||||||
void addToKey(SkShaderCodeDictionary*,
|
void addToKey(SkShaderCodeDictionary*,
|
||||||
SkPaintParamsKeyBuilder*,
|
SkPaintParamsKeyBuilder*,
|
||||||
SkUniformBlock*) const override;
|
SkPipelineData*) const override;
|
||||||
#endif
|
#endif
|
||||||
bool isOpaque() const override;
|
bool isOpaque() const override;
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
#include "experimental/graphite/include/Context.h"
|
#include "experimental/graphite/include/Context.h"
|
||||||
#include "experimental/graphite/include/Recorder.h"
|
#include "experimental/graphite/include/Recorder.h"
|
||||||
|
#include "experimental/graphite/src/PipelineDataCache.h"
|
||||||
#include "experimental/graphite/src/RecorderPriv.h"
|
#include "experimental/graphite/src/RecorderPriv.h"
|
||||||
#include "experimental/graphite/src/UniformCache.h"
|
|
||||||
#include "src/core/SkUniform.h"
|
#include "src/core/SkUniform.h"
|
||||||
#include "src/core/SkUniformData.h"
|
#include "src/core/SkUniformData.h"
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ using namespace skgpu;
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
std::unique_ptr<SkUniformBlock> make_ub(int numUniforms, int dataSize) {
|
std::unique_ptr<SkPipelineData> make_pd(int numUniforms, int dataSize) {
|
||||||
static constexpr int kMaxUniforms = 3;
|
static constexpr int kMaxUniforms = 3;
|
||||||
static constexpr SkUniform kUniforms[kMaxUniforms] {
|
static constexpr SkUniform kUniforms[kMaxUniforms] {
|
||||||
{"point0", SkSLType::kFloat2 },
|
{"point0", SkSLType::kFloat2 },
|
||||||
@ -37,66 +37,66 @@ std::unique_ptr<SkUniformBlock> make_ub(int numUniforms, int dataSize) {
|
|||||||
ud->data()[i] = i % 255;
|
ud->data()[i] = i % 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::make_unique<SkUniformBlock>(std::move(ud));
|
return std::make_unique<SkPipelineData>(std::move(ud));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
DEF_GRAPHITE_TEST_FOR_CONTEXTS(UniformCacheTest, reporter, context) {
|
DEF_GRAPHITE_TEST_FOR_CONTEXTS(PipelineDataCacheTest, reporter, context) {
|
||||||
std::unique_ptr<Recorder> recorder = context->makeRecorder();
|
std::unique_ptr<Recorder> recorder = context->makeRecorder();
|
||||||
|
|
||||||
auto cache = recorder->priv().uniformCache();
|
auto cache = recorder->priv().pipelineDataCache();
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, cache->count() == 0);
|
REPORTER_ASSERT(reporter, cache->count() == 0);
|
||||||
|
|
||||||
// Nullptr should already be in the cache and return kInvalidUniformID
|
// Nullptr should already be in the cache and return kInvalidUniformID
|
||||||
{
|
{
|
||||||
uint32_t result0 = cache->insert(nullptr);
|
uint32_t result0 = cache->insert(nullptr);
|
||||||
REPORTER_ASSERT(reporter, result0 == UniformCache::kInvalidUniformID);
|
REPORTER_ASSERT(reporter, result0 == PipelineDataCache::kInvalidUniformID);
|
||||||
REPORTER_ASSERT(reporter, cache->count() == 0);
|
REPORTER_ASSERT(reporter, cache->count() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a new unique UB
|
// Add a new unique PD
|
||||||
SkUniformBlock* danglingUB1 = nullptr;
|
SkPipelineData* danglingPD1 = nullptr;
|
||||||
uint32_t result1;
|
uint32_t result1;
|
||||||
{
|
{
|
||||||
std::unique_ptr<SkUniformBlock> ub1 = make_ub(2, 16);
|
std::unique_ptr<SkPipelineData> pd1 = make_pd(2, 16);
|
||||||
danglingUB1 = ub1.get();
|
danglingPD1 = pd1.get();
|
||||||
result1 = cache->insert(std::move(ub1));
|
result1 = cache->insert(std::move(pd1));
|
||||||
REPORTER_ASSERT(reporter, result1 != UniformCache::kInvalidUniformID);
|
REPORTER_ASSERT(reporter, result1 != PipelineDataCache::kInvalidUniformID);
|
||||||
SkUniformBlock* lookup = cache->lookup(result1);
|
SkPipelineData* lookup = cache->lookup(result1);
|
||||||
REPORTER_ASSERT(reporter, lookup == danglingUB1);
|
REPORTER_ASSERT(reporter, lookup == danglingPD1);
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, cache->count() == 1);
|
REPORTER_ASSERT(reporter, cache->count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to add a duplicate UB
|
// Try to add a duplicate PD
|
||||||
{
|
{
|
||||||
std::unique_ptr<SkUniformBlock> ub2 = make_ub(2, 16);
|
std::unique_ptr<SkPipelineData> pd2 = make_pd(2, 16);
|
||||||
SkUniformBlock* danglingUB2 = ub2.get();
|
SkPipelineData* danglingPD2 = pd2.get();
|
||||||
uint32_t result2 = cache->insert(std::move(ub2));
|
uint32_t result2 = cache->insert(std::move(pd2));
|
||||||
REPORTER_ASSERT(reporter, result2 != UniformCache::kInvalidUniformID);
|
REPORTER_ASSERT(reporter, result2 != PipelineDataCache::kInvalidUniformID);
|
||||||
REPORTER_ASSERT(reporter, result2 == result1);
|
REPORTER_ASSERT(reporter, result2 == result1);
|
||||||
SkUniformBlock* lookup = cache->lookup(result2);
|
SkPipelineData* lookup = cache->lookup(result2);
|
||||||
REPORTER_ASSERT(reporter, lookup != danglingUB2);
|
REPORTER_ASSERT(reporter, lookup != danglingPD2);
|
||||||
REPORTER_ASSERT(reporter, lookup == danglingUB1);
|
REPORTER_ASSERT(reporter, lookup == danglingPD1);
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, cache->count() == 1);
|
REPORTER_ASSERT(reporter, cache->count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a second new unique UB
|
// Add a second new unique PD
|
||||||
{
|
{
|
||||||
std::unique_ptr<SkUniformBlock> ub3 = make_ub(3, 16);
|
std::unique_ptr<SkPipelineData> pd3 = make_pd(3, 16);
|
||||||
SkUniformBlock* danglingUB3 = ub3.get();
|
SkPipelineData* danglingPD3 = pd3.get();
|
||||||
uint32_t result3 = cache->insert(std::move(ub3));
|
uint32_t result3 = cache->insert(std::move(pd3));
|
||||||
REPORTER_ASSERT(reporter, result3 != UniformCache::kInvalidUniformID);
|
REPORTER_ASSERT(reporter, result3 != PipelineDataCache::kInvalidUniformID);
|
||||||
REPORTER_ASSERT(reporter, result3 != result1);
|
REPORTER_ASSERT(reporter, result3 != result1);
|
||||||
SkUniformBlock* lookup = cache->lookup(result3);
|
SkPipelineData* lookup = cache->lookup(result3);
|
||||||
REPORTER_ASSERT(reporter, lookup == danglingUB3);
|
REPORTER_ASSERT(reporter, lookup == danglingPD3);
|
||||||
REPORTER_ASSERT(reporter, lookup != danglingUB1);
|
REPORTER_ASSERT(reporter, lookup != danglingPD1);
|
||||||
|
|
||||||
REPORTER_ASSERT(reporter, cache->count() == 2);
|
REPORTER_ASSERT(reporter, cache->count() == 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(robertphillips): expand this test to exercise all the UD comparison failure modes
|
// TODO(robertphillips): expand this test to exercise all the PD comparison failure modes
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user