mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1265824 - Pass the texture direct mapping info to all texture creating functions r=mattwoodrow
The client side can't get the GL context in CompositorOGL. So, it can't know the texture direct mapping capability directly. This patch adds the texture direct mapping info in TextureFactoryIdentifier. Then, the client side could get the info form the TextureFactoryIdentifier. MozReview-Commit-ID: KEazDVg0p9Y --HG-- extra : rebase_source : 425159494772431283138bbaa4574c6201a2bc59
This commit is contained in:
parent
40c168f2fd
commit
1cfb8ec041
@ -105,8 +105,13 @@ static bool UsingX11Compositor()
|
||||
}
|
||||
|
||||
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
||||
LayersBackend aLayersBackend)
|
||||
LayersBackend aLayersBackend,
|
||||
bool aSupportsTextureDirectMapping)
|
||||
{
|
||||
if (aSupportsTextureDirectMapping) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return aLayersBackend != LayersBackend::LAYERS_BASIC
|
||||
|| UsingX11Compositor()
|
||||
|| aFormat == gfx::SurfaceFormat::UNKNOWN;
|
||||
@ -168,7 +173,8 @@ BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator,
|
||||
}
|
||||
|
||||
bool hasIntermediateBuffer = aAllocator ? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
|
||||
aAllocator->GetCompositorBackendType())
|
||||
aAllocator->GetCompositorBackendType(),
|
||||
aAllocator->SupportsTextureDirectMapping())
|
||||
: true;
|
||||
|
||||
// Initialize the metadata with something, even if it will have to be rewritten
|
||||
@ -210,7 +216,8 @@ BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator,
|
||||
bool hasIntermediateBuffer =
|
||||
aAllocator
|
||||
? ComputeHasIntermediateBuffer(gfx::SurfaceFormat::YUV,
|
||||
aAllocator->GetCompositorBackendType())
|
||||
aAllocator->GetCompositorBackendType(),
|
||||
aAllocator->SupportsTextureDirectMapping())
|
||||
: true;
|
||||
|
||||
YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aYStride,
|
||||
@ -525,7 +532,9 @@ MemoryTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
|
||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat,
|
||||
aLayersBackend,
|
||||
aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING);
|
||||
|
||||
GfxMemoryImageReporter::DidAlloc(buf);
|
||||
|
||||
@ -601,7 +610,9 @@ ShmemTextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat, aLayersBackend);
|
||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(aFormat,
|
||||
aLayersBackend,
|
||||
aAllocFlags & ALLOC_ALLOW_DIRECT_MAPPING);
|
||||
|
||||
BufferDescriptor descriptor = RGBDescriptor(aSize, aFormat, hasIntermediateBuffer);
|
||||
|
||||
|
@ -17,7 +17,8 @@ namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
bool ComputeHasIntermediateBuffer(gfx::SurfaceFormat aFormat,
|
||||
LayersBackend aLayersBackend);
|
||||
LayersBackend aLayersBackend,
|
||||
bool aSupportsTextureDirectMapping);
|
||||
|
||||
class BufferTextureData : public TextureData
|
||||
{
|
||||
|
@ -175,6 +175,7 @@ struct TextureFactoryIdentifier
|
||||
LayersBackend mParentBackend;
|
||||
GeckoProcessType mParentProcessType;
|
||||
int32_t mMaxTextureSize;
|
||||
bool mSupportsTextureDirectMapping;
|
||||
bool mCompositorUseANGLE;
|
||||
bool mCompositorUseDComp;
|
||||
bool mSupportsTextureBlitting;
|
||||
@ -186,6 +187,7 @@ struct TextureFactoryIdentifier
|
||||
explicit TextureFactoryIdentifier(LayersBackend aLayersBackend = LayersBackend::LAYERS_NONE,
|
||||
GeckoProcessType aParentProcessType = GeckoProcessType_Default,
|
||||
int32_t aMaxTextureSize = 4096,
|
||||
bool aSupportsTextureDirectMapping = false,
|
||||
bool aCompositorUseANGLE = false,
|
||||
bool aCompositorUseDComp = false,
|
||||
bool aSupportsTextureBlitting = false,
|
||||
@ -195,6 +197,7 @@ struct TextureFactoryIdentifier
|
||||
: mParentBackend(aLayersBackend)
|
||||
, mParentProcessType(aParentProcessType)
|
||||
, mMaxTextureSize(aMaxTextureSize)
|
||||
, mSupportsTextureDirectMapping(aSupportsTextureDirectMapping)
|
||||
, mCompositorUseANGLE(aCompositorUseANGLE)
|
||||
, mCompositorUseDComp(aCompositorUseDComp)
|
||||
, mSupportsTextureBlitting(aSupportsTextureBlitting)
|
||||
@ -209,11 +212,13 @@ struct TextureFactoryIdentifier
|
||||
mParentBackend == aOther.mParentBackend &&
|
||||
mParentProcessType == aOther.mParentProcessType &&
|
||||
mMaxTextureSize == aOther.mMaxTextureSize &&
|
||||
mSupportsTextureDirectMapping == aOther.mSupportsTextureDirectMapping &&
|
||||
mCompositorUseANGLE == aOther.mCompositorUseANGLE &&
|
||||
mCompositorUseDComp == aOther.mCompositorUseDComp &&
|
||||
mSupportsTextureBlitting == aOther.mSupportsTextureBlitting &&
|
||||
mSupportsPartialUploads == aOther.mSupportsPartialUploads &&
|
||||
mSupportsComponentAlpha == aOther.mSupportsComponentAlpha &&
|
||||
mUsingAdvancedLayers == aOther.mUsingAdvancedLayers &&
|
||||
mSyncHandle == aOther.mSyncHandle;
|
||||
}
|
||||
};
|
||||
|
@ -762,10 +762,14 @@ ContentClientRemoteBuffer::CreateBufferInternal(const gfx::IntRect& aRect,
|
||||
|
||||
RefPtr<TextureClient> textureClientOnWhite;
|
||||
if (aFlags & TextureFlags::COMPONENT_ALPHA) {
|
||||
TextureAllocationFlags allocFlags = ALLOC_CLEAR_BUFFER_WHITE;
|
||||
if (mForwarder->SupportsTextureDirectMapping()) {
|
||||
allocFlags = TextureAllocationFlags(allocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
||||
}
|
||||
textureClientOnWhite = textureClient->CreateSimilar(
|
||||
mForwarder->GetCompositorBackendType(),
|
||||
aFlags | ExtraTextureFlags(),
|
||||
TextureAllocationFlags::ALLOC_CLEAR_BUFFER_WHITE
|
||||
allocFlags
|
||||
);
|
||||
if (!textureClientOnWhite || !AddTextureClient(textureClientOnWhite)) {
|
||||
return nullptr;
|
||||
|
@ -660,7 +660,9 @@ TextureClient::UpdateFromSurface(gfx::SourceSurface* aSurface)
|
||||
|
||||
|
||||
already_AddRefed<TextureClient>
|
||||
TextureClient::CreateSimilar(LayersBackend aLayersBackend, TextureFlags aFlags, TextureAllocationFlags aAllocFlags) const
|
||||
TextureClient::CreateSimilar(LayersBackend aLayersBackend,
|
||||
TextureFlags aFlags,
|
||||
TextureAllocationFlags aAllocFlags) const
|
||||
{
|
||||
MOZ_ASSERT(IsValid());
|
||||
|
||||
@ -670,7 +672,10 @@ TextureClient::CreateSimilar(LayersBackend aLayersBackend, TextureFlags aFlags,
|
||||
}
|
||||
|
||||
LockActor();
|
||||
TextureData* data = mData->CreateSimilar(mAllocator, aLayersBackend, aFlags, aAllocFlags);
|
||||
TextureData* data = mData->CreateSimilar(mAllocator,
|
||||
aLayersBackend,
|
||||
aFlags,
|
||||
aAllocFlags);
|
||||
UnlockActor();
|
||||
|
||||
if (!data) {
|
||||
@ -1060,6 +1065,9 @@ TextureClient::CreateForDrawing(KnowsCompositor* aAllocator,
|
||||
TextureAllocationFlags aAllocFlags)
|
||||
{
|
||||
LayersBackend layersBackend = aAllocator->GetCompositorBackendType();
|
||||
if (aAllocator->SupportsTextureDirectMapping()) {
|
||||
aAllocFlags = TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
||||
}
|
||||
return TextureClient::CreateForDrawing(aAllocator->GetTextureForwarder(),
|
||||
aFormat, aSize,
|
||||
layersBackend,
|
||||
@ -1226,6 +1234,16 @@ TextureClient::CreateForRawBufferAccess(KnowsCompositor* aAllocator,
|
||||
TextureFlags aTextureFlags,
|
||||
TextureAllocationFlags aAllocFlags)
|
||||
{
|
||||
// If we exceed the max texture size for the GPU, then just fall back to no
|
||||
// texture direct mapping. If it becomes a problem we can implement tiling
|
||||
// logic inside DirectMapTextureSource to allow this.
|
||||
bool supportsTextureDirectMapping = aAllocator->SupportsTextureDirectMapping() &&
|
||||
std::max(aSize.width, aSize.height) <= aAllocator->GetMaxTextureSize();
|
||||
if (supportsTextureDirectMapping) {
|
||||
aAllocFlags = TextureAllocationFlags(aAllocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
||||
} else {
|
||||
aAllocFlags = TextureAllocationFlags(aAllocFlags & ~ALLOC_ALLOW_DIRECT_MAPPING);
|
||||
}
|
||||
return CreateForRawBufferAccess(aAllocator->GetTextureForwarder(),
|
||||
aFormat, aSize, aMoz2DBackend,
|
||||
aAllocator->GetCompositorBackendType(),
|
||||
|
@ -94,6 +94,10 @@ enum TextureAllocationFlags {
|
||||
// The texture is going to be updated using UpdateFromSurface and needs to support
|
||||
// that call.
|
||||
ALLOC_UPDATE_FROM_SURFACE = 1 << 7,
|
||||
|
||||
// In practice, this means we support the APPLE_client_storage extension, meaning
|
||||
// the buffer will not be internally copied by the graphics driver.
|
||||
ALLOC_ALLOW_DIRECT_MAPPING = 1 << 8,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,7 @@ ClearCallback(nsITimer *aTimer, void *aClosure)
|
||||
}
|
||||
|
||||
TextureClientPool::TextureClientPool(LayersBackend aLayersBackend,
|
||||
bool aSupportsTextureDirectMapping,
|
||||
int32_t aMaxTextureSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
gfx::IntSize aSize,
|
||||
@ -60,6 +61,7 @@ TextureClientPool::TextureClientPool(LayersBackend aLayersBackend,
|
||||
, mOutstandingClients(0)
|
||||
, mSurfaceAllocator(aAllocator)
|
||||
, mDestroyed(false)
|
||||
, mSupportsTextureDirectMapping(aSupportsTextureDirectMapping)
|
||||
{
|
||||
TCP_LOG("TexturePool %p created with maximum unused texture clients %u\n",
|
||||
this, mInitialPoolSize);
|
||||
@ -149,6 +151,12 @@ TextureClientPool::AllocateTextureClient()
|
||||
TCP_LOG("TexturePool %p allocating TextureClient, outstanding %u\n",
|
||||
this, mOutstandingClients);
|
||||
|
||||
TextureAllocationFlags allocFlags = ALLOC_DEFAULT;
|
||||
|
||||
if (mSupportsTextureDirectMapping) {
|
||||
allocFlags = TextureAllocationFlags(allocFlags | ALLOC_ALLOW_DIRECT_MAPPING);
|
||||
}
|
||||
|
||||
RefPtr<TextureClient> newClient;
|
||||
if (gfxPrefs::ForceShmemTiles()) {
|
||||
// gfx::BackendType::NONE means use the content backend
|
||||
@ -157,7 +165,7 @@ TextureClientPool::AllocateTextureClient()
|
||||
mFormat, mSize,
|
||||
gfx::BackendType::NONE,
|
||||
mBackend,
|
||||
mFlags, ALLOC_DEFAULT);
|
||||
mFlags, allocFlags);
|
||||
} else {
|
||||
newClient =
|
||||
TextureClient::CreateForDrawing(mSurfaceAllocator,
|
||||
@ -165,7 +173,7 @@ TextureClientPool::AllocateTextureClient()
|
||||
mBackend,
|
||||
mMaxTextureSize,
|
||||
BackendSelector::Content,
|
||||
mFlags);
|
||||
mFlags, allocFlags);
|
||||
}
|
||||
|
||||
if (newClient) {
|
||||
|
@ -46,6 +46,7 @@ class TextureClientPool final : public TextureClientAllocator
|
||||
|
||||
public:
|
||||
TextureClientPool(LayersBackend aBackend,
|
||||
bool aSupportsTextureDirectMapping,
|
||||
int32_t aMaxTextureSize,
|
||||
gfx::SurfaceFormat aFormat,
|
||||
gfx::IntSize aSize,
|
||||
@ -170,6 +171,8 @@ private:
|
||||
// we won't accept returns of TextureClients anymore, and the refcounting
|
||||
// should take care of their destruction.
|
||||
bool mDestroyed;
|
||||
|
||||
bool mSupportsTextureDirectMapping;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
@ -936,6 +936,7 @@ CompositorBridgeChild::GetTexturePool(KnowsCompositor* aAllocator,
|
||||
|
||||
mTexturePools.AppendElement(
|
||||
new TextureClientPool(aAllocator->GetCompositorBackendType(),
|
||||
aAllocator->SupportsTextureDirectMapping(),
|
||||
aAllocator->GetMaxTextureSize(),
|
||||
aFormat,
|
||||
gfx::gfxVars::TileSize(),
|
||||
|
@ -102,6 +102,11 @@ public:
|
||||
return mTextureFactoryIdentifier.mSupportsComponentAlpha;
|
||||
}
|
||||
|
||||
bool SupportsTextureDirectMapping() const
|
||||
{
|
||||
return mTextureFactoryIdentifier.mSupportsTextureDirectMapping;
|
||||
}
|
||||
|
||||
bool SupportsD3D11() const
|
||||
{
|
||||
return GetCompositorBackendType() == layers::LayersBackend::LAYERS_D3D11 ||
|
||||
|
@ -335,6 +335,7 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
|
||||
WriteParam(aMsg, aParam.mParentBackend);
|
||||
WriteParam(aMsg, aParam.mParentProcessType);
|
||||
WriteParam(aMsg, aParam.mMaxTextureSize);
|
||||
WriteParam(aMsg, aParam.mSupportsTextureDirectMapping);
|
||||
WriteParam(aMsg, aParam.mCompositorUseANGLE);
|
||||
WriteParam(aMsg, aParam.mCompositorUseDComp);
|
||||
WriteParam(aMsg, aParam.mSupportsTextureBlitting);
|
||||
@ -349,6 +350,7 @@ struct ParamTraits<mozilla::layers::TextureFactoryIdentifier>
|
||||
bool result = ReadParam(aMsg, aIter, &aResult->mParentBackend) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mParentProcessType) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mMaxTextureSize) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mSupportsTextureDirectMapping) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mCompositorUseANGLE) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mCompositorUseDComp) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mSupportsTextureBlitting) &&
|
||||
|
@ -115,8 +115,11 @@ SharedPlanarYCbCrImage::AdoptData(const Data& aData)
|
||||
uint32_t crOffset = aData.mCrChannel - base;
|
||||
|
||||
auto fwd = mCompositable->GetForwarder();
|
||||
bool supportsTextureDirectMapping = fwd->SupportsTextureDirectMapping() &&
|
||||
std::max(mSize.width, mSize.height) <= fwd->GetMaxTextureSize();
|
||||
bool hasIntermediateBuffer = ComputeHasIntermediateBuffer(
|
||||
gfx::SurfaceFormat::YUV, fwd->GetCompositorBackendType());
|
||||
gfx::SurfaceFormat::YUV, fwd->GetCompositorBackendType(),
|
||||
supportsTextureDirectMapping);
|
||||
|
||||
static_cast<BufferTextureData*>(mTextureClient->GetInternalData())
|
||||
->SetDesciptor(YCbCrDescriptor(aData.mYSize,
|
||||
|
@ -1920,6 +1920,18 @@ CompositorOGL::GetTemporaryTexture(GLenum aTarget, GLenum aUnit)
|
||||
return mTexturePool->GetTexture(aTarget, aUnit);
|
||||
}
|
||||
|
||||
bool
|
||||
CompositorOGL::SupportsTextureDirectMapping()
|
||||
{
|
||||
if (mGLContext) {
|
||||
mGLContext->MakeCurrent();
|
||||
return mGLContext->IsExtensionSupported(gl::GLContext::APPLE_client_storage) &&
|
||||
mGLContext->IsExtensionSupported(gl::GLContext::APPLE_texture_range);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
GLuint
|
||||
PerUnitTexturePoolOGL::GetTexture(GLenum aTarget, GLenum aTextureUnit)
|
||||
{
|
||||
|
@ -141,6 +141,7 @@ public:
|
||||
TextureFactoryIdentifier(LayersBackend::LAYERS_OPENGL,
|
||||
XRE_GetProcessType(),
|
||||
GetMaxTextureSize(),
|
||||
SupportsTextureDirectMapping(),
|
||||
false,
|
||||
mFBOTextureTarget == LOCAL_GL_TEXTURE_2D,
|
||||
SupportsPartialTextureUpdate());
|
||||
@ -273,6 +274,8 @@ private:
|
||||
|
||||
void PrepareViewport(CompositingRenderTargetOGL *aRenderTarget);
|
||||
|
||||
bool SupportsTextureDirectMapping();
|
||||
|
||||
/** Widget associated with this compositor */
|
||||
LayoutDeviceIntSize mWidgetSize;
|
||||
RefPtr<GLContext> mGLContext;
|
||||
|
Loading…
Reference in New Issue
Block a user