Make GrBufferAccess a nested class of GrProcessor
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4978 Change-Id: I08c24e9183108f4dd6068216488fd3ac9b5f3ec2 Reviewed-on: https://skia-review.googlesource.com/4978 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
ce1d293880
commit
b014cca49d
@ -10,7 +10,6 @@ _include = get_path_info("../include", "abspath")
|
||||
skia_gpu_sources = [
|
||||
"$_include/gpu/GrBlend.h",
|
||||
"$_include/gpu/GrBuffer.h",
|
||||
"$_include/gpu/GrBufferAccess.h",
|
||||
"$_include/gpu/GrCaps.h",
|
||||
"$_include/gpu/GrClip.h",
|
||||
"$_include/gpu/GrColor.h",
|
||||
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef GrBufferAccess_DEFINED
|
||||
#define GrBufferAccess_DEFINED
|
||||
|
||||
#include "GrBuffer.h"
|
||||
#include "GrGpuResourceRef.h"
|
||||
|
||||
/**
|
||||
* Used to represent a texel buffer that will be read in a GrProcessor. It holds a GrBuffer along
|
||||
* with an associated offset and texel config.
|
||||
*/
|
||||
class GrBufferAccess : public SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* Must be initialized before adding to a GrProcessor's buffer access list.
|
||||
*/
|
||||
void reset(GrPixelConfig texelConfig, GrBuffer* buffer,
|
||||
GrShaderFlags visibility = kFragment_GrShaderFlag) {
|
||||
fTexelConfig = texelConfig;
|
||||
fBuffer.set(SkRef(buffer), kRead_GrIOType);
|
||||
fVisibility = visibility;
|
||||
}
|
||||
|
||||
bool operator==(const GrBufferAccess& that) const {
|
||||
return fTexelConfig == that.fTexelConfig &&
|
||||
this->buffer() == that.buffer() &&
|
||||
fVisibility == that.fVisibility;
|
||||
}
|
||||
|
||||
bool operator!=(const GrBufferAccess& that) const { return !(*this == that); }
|
||||
|
||||
GrPixelConfig texelConfig() const { return fTexelConfig; }
|
||||
GrBuffer* buffer() const { return fBuffer.get(); }
|
||||
GrShaderFlags visibility() const { return fVisibility; }
|
||||
|
||||
/**
|
||||
* For internal use by GrProcessor.
|
||||
*/
|
||||
const GrGpuResourceRef* getProgramBuffer() const { return &fBuffer;}
|
||||
|
||||
private:
|
||||
GrPixelConfig fTexelConfig;
|
||||
GrTGpuResourceRef<GrBuffer> fBuffer;
|
||||
GrShaderFlags fVisibility;
|
||||
|
||||
typedef SkNoncopyable INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
@ -9,9 +9,11 @@
|
||||
#define GrProcessor_DEFINED
|
||||
|
||||
#include "GrColor.h"
|
||||
#include "GrBuffer.h"
|
||||
#include "GrGpuResourceRef.h"
|
||||
#include "GrProcessorUnitTest.h"
|
||||
#include "GrProgramElement.h"
|
||||
#include "GrBufferAccess.h"
|
||||
#include "GrSamplerParams.h"
|
||||
#include "SkMath.h"
|
||||
#include "SkString.h"
|
||||
#include "../private/SkAtomics.h"
|
||||
@ -59,14 +61,15 @@ private:
|
||||
class GrProcessor : public GrProgramElement {
|
||||
public:
|
||||
class TextureSampler;
|
||||
class BufferAccess;
|
||||
|
||||
virtual ~GrProcessor();
|
||||
|
||||
/** Human-meaningful string to identify this prcoessor; may be embedded
|
||||
in generated shader code. */
|
||||
/** Human-meaningful string to identify this prcoessor; may be embedded in generated shader
|
||||
code. */
|
||||
virtual const char* name() const = 0;
|
||||
|
||||
// Human-readable dump of all information
|
||||
/** Human-readable dump of all information */
|
||||
virtual SkString dumpInfo() const {
|
||||
SkString str;
|
||||
str.appendf("Missing data");
|
||||
@ -83,13 +86,9 @@ public:
|
||||
|
||||
/** Returns the access pattern for the buffer at index. index must be valid according to
|
||||
numBuffers(). */
|
||||
const GrBufferAccess& bufferAccess(int index) const {
|
||||
return *fBufferAccesses[index];
|
||||
}
|
||||
const BufferAccess& bufferAccess(int index) const { return *fBufferAccesses[index]; }
|
||||
|
||||
/**
|
||||
* Platform specific built-in features that a processor can request for the fragment shader.
|
||||
*/
|
||||
/** Platform specific built-in features that a processor can request for the fragment shader. */
|
||||
enum RequiredFeatures {
|
||||
kNone_RequiredFeatures = 0,
|
||||
kFragmentPosition_RequiredFeature = 1 << 0,
|
||||
@ -110,9 +109,7 @@ public:
|
||||
::operator delete(target, placement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for down-casting to a GrProcessor subclass
|
||||
*/
|
||||
/** Helper for down-casting to a GrProcessor subclass */
|
||||
template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
|
||||
|
||||
uint32_t classID() const { SkASSERT(kIllegalProcessorClassID != fClassID); return fClassID; }
|
||||
@ -123,12 +120,11 @@ protected:
|
||||
/**
|
||||
* Subclasses call these from their constructor to register sampler sources. The processor
|
||||
* subclass manages the lifetime of the objects (these functions only store pointers). The
|
||||
* TextureSampler and/or GrBufferAccess instances are typically member fields of the
|
||||
* GrProcessor subclass. These must only be called from the constructor because GrProcessors
|
||||
* are immutable.
|
||||
* TextureSampler and/or BufferAccess instances are typically member fields of the GrProcessor
|
||||
* subclass. These must only be called from the constructor because GrProcessors are immutable.
|
||||
*/
|
||||
void addTextureSampler(const TextureSampler*);
|
||||
void addBufferAccess(const GrBufferAccess* bufferAccess);
|
||||
void addBufferAccess(const BufferAccess* bufferAccess);
|
||||
|
||||
bool hasSameSamplers(const GrProcessor&) const;
|
||||
|
||||
@ -170,7 +166,7 @@ private:
|
||||
|
||||
RequiredFeatures fRequiredFeatures;
|
||||
SkSTArray<4, const TextureSampler*, true> fTextureSamplers;
|
||||
SkSTArray<2, const GrBufferAccess*, true> fBufferAccesses;
|
||||
SkSTArray<2, const BufferAccess*, true> fBufferAccesses;
|
||||
|
||||
typedef GrProgramElement INHERITED;
|
||||
};
|
||||
@ -230,4 +226,45 @@ private:
|
||||
typedef SkNoncopyable INHERITED;
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to represent a texel buffer that will be read in a GrProcessor. It holds a GrBuffer along
|
||||
* with an associated offset and texel config.
|
||||
*/
|
||||
class GrProcessor::BufferAccess : public SkNoncopyable {
|
||||
public:
|
||||
/**
|
||||
* Must be initialized before adding to a GrProcessor's buffer access list.
|
||||
*/
|
||||
void reset(GrPixelConfig texelConfig, GrBuffer* buffer,
|
||||
GrShaderFlags visibility = kFragment_GrShaderFlag) {
|
||||
fTexelConfig = texelConfig;
|
||||
fBuffer.set(SkRef(buffer), kRead_GrIOType);
|
||||
fVisibility = visibility;
|
||||
}
|
||||
|
||||
bool operator==(const BufferAccess& that) const {
|
||||
return fTexelConfig == that.fTexelConfig &&
|
||||
this->buffer() == that.buffer() &&
|
||||
fVisibility == that.fVisibility;
|
||||
}
|
||||
|
||||
bool operator!=(const BufferAccess& that) const { return !(*this == that); }
|
||||
|
||||
GrPixelConfig texelConfig() const { return fTexelConfig; }
|
||||
GrBuffer* buffer() const { return fBuffer.get(); }
|
||||
GrShaderFlags visibility() const { return fVisibility; }
|
||||
|
||||
/**
|
||||
* For internal use by GrProcessor.
|
||||
*/
|
||||
const GrGpuResourceRef* getProgramBuffer() const { return &fBuffer;}
|
||||
|
||||
private:
|
||||
GrPixelConfig fTexelConfig;
|
||||
GrTGpuResourceRef<GrBuffer> fBuffer;
|
||||
GrShaderFlags fVisibility;
|
||||
|
||||
typedef SkNoncopyable INHERITED;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -120,7 +120,7 @@ void GrProcessor::addTextureSampler(const TextureSampler* access) {
|
||||
this->addGpuResource(access->programTexture());
|
||||
}
|
||||
|
||||
void GrProcessor::addBufferAccess(const GrBufferAccess* access) {
|
||||
void GrProcessor::addBufferAccess(const BufferAccess* access) {
|
||||
fBufferAccesses.push_back(access);
|
||||
this->addGpuResource(access->getProgramBuffer());
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ static void add_sampler_keys(GrProcessorKeyBuilder* b, const GrProcessor& proc,
|
||||
textureSampler.visibility(), caps);
|
||||
}
|
||||
for (; i < numSamplers; ++i) {
|
||||
const GrBufferAccess& access = proc.bufferAccess(i - numTextureSamplers);
|
||||
const GrProcessor::BufferAccess& access = proc.bufferAccess(i - numTextureSamplers);
|
||||
k16[i] = sampler_key(kBufferSampler_GrSLType, access.texelConfig(),
|
||||
access.visibility(), caps);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ void GrGLProgram::bindTextures(const GrProcessor& processor,
|
||||
allowSRGBInputs, static_cast<GrGLTexture*>(sampler.texture()));
|
||||
}
|
||||
for (int i = 0; i < processor.numBuffers(); ++i) {
|
||||
const GrBufferAccess& access = processor.bufferAccess(i);
|
||||
const GrProcessor::BufferAccess& access = processor.bufferAccess(i);
|
||||
fGpu->bindTexelBuffer((*nextSamplerIdx)++, access.texelConfig(),
|
||||
static_cast<GrGLBuffer*>(access.buffer()));
|
||||
}
|
||||
|
@ -97,9 +97,9 @@ public:
|
||||
@param texSamplers Contains one entry for each TextureSampler of the GrProcessor.
|
||||
These can be passed to the builder to emit texture reads in the
|
||||
generated code.
|
||||
@param bufferSamplers Contains one entry for each GrBufferAccess of the GrProcessor.
|
||||
These can be passed to the builder to emit buffer reads in the
|
||||
generated code.
|
||||
@param bufferSamplers Contains one entry for each BufferAccess of the GrProcessor. These
|
||||
can be passed to the builder to emit buffer reads in the generated
|
||||
code.
|
||||
*/
|
||||
struct EmitArgs {
|
||||
EmitArgs(GrGLSLFPFragmentBuilder* fragBuilder,
|
||||
|
@ -264,7 +264,7 @@ void GrGLSLProgramBuilder::emitSamplers(const GrProcessor& processor,
|
||||
GrShaderFlags texelBufferVisibility = kNone_GrShaderFlags;
|
||||
|
||||
for (int b = 0; b < numBuffers; ++b) {
|
||||
const GrBufferAccess& access = processor.bufferAccess(b);
|
||||
const GrProcessor::BufferAccess& access = processor.bufferAccess(b);
|
||||
name.printf("BufferSampler_%d", outBufferSamplers->count());
|
||||
this->emitSampler(kBufferSampler_GrSLType, access.texelConfig(), name.c_str(),
|
||||
access.visibility(), outBufferSamplers);
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define gr_instanced_InstanceProcessor_DEFINED
|
||||
|
||||
#include "GrCaps.h"
|
||||
#include "GrBufferAccess.h"
|
||||
#include "GrGeometryProcessor.h"
|
||||
#include "instanced/InstancedRenderingTypes.h"
|
||||
|
||||
@ -57,8 +56,8 @@ private:
|
||||
*/
|
||||
static GrCaps::InstancedSupport CheckSupport(const GrGLSLCaps&, const GrCaps&);
|
||||
|
||||
const BatchInfo fBatchInfo;
|
||||
GrBufferAccess fParamsAccess;
|
||||
const BatchInfo fBatchInfo;
|
||||
BufferAccess fParamsAccess;
|
||||
|
||||
friend class GLInstancedRendering; // For CheckSupport.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user