Commit 1692b457 authored by Antoine Labour's avatar Antoine Labour Committed by Commit Bot

Remove ScopedWriteLockRaster

At this point it's only used in tests, to test itself.
Also remove Resource::usage, which isn't used for anything anymore.

Bug: None
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel
Change-Id: I3b75bba09565d52a126c0f27c344d94ed50fc4c6
Reviewed-on: https://chromium-review.googlesource.com/1014274Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Antoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551212}
parent e636cd89
......@@ -361,10 +361,9 @@ viz::ResourceId LayerTreeResourceProvider::CreateGpuTextureResource(
viz::ResourceType::kTexture, format, color_space));
if (use_overlay && settings_.use_texture_storage_image &&
viz::IsGpuMemoryBufferFormatSupported(format)) {
resource->usage = gfx::BufferUsage::SCANOUT;
resource->target = GetImageTextureTarget(
compositor_context_provider_->ContextCapabilities(), resource->usage,
format);
resource->target = gpu::GetBufferTextureTarget(
gfx::BufferUsage::SCANOUT, BufferFormat(format),
compositor_context_provider_->ContextCapabilities());
resource->buffer_format = BufferFormat(format);
resource->is_overlay_candidate = true;
}
......@@ -616,13 +615,6 @@ void LayerTreeResourceProvider::FlushPendingDeletions() const {
gl->ShallowFlushCHROMIUM();
}
GLenum LayerTreeResourceProvider::GetImageTextureTarget(
const gpu::Capabilities& caps,
gfx::BufferUsage usage,
viz::ResourceFormat format) const {
return gpu::GetBufferTextureTarget(usage, BufferFormat(format), caps);
}
bool LayerTreeResourceProvider::IsTextureFormatSupported(
viz::ResourceFormat format) const {
gpu::Capabilities caps;
......@@ -730,7 +722,6 @@ LayerTreeResourceProvider::ScopedWriteLockGpu::ScopedWriteLockGpu(
DCHECK_EQ(resource->type, viz::ResourceType::kTexture);
resource_provider->CreateTexture(resource);
size_ = resource->size;
usage_ = resource->usage;
format_ = resource->format;
color_space_ = resource_provider_->GetResourceColorSpaceForRaster(resource);
texture_id_ = resource->gl_id;
......@@ -821,45 +812,6 @@ void LayerTreeResourceProvider::ScopedWriteLockGL::LazyAllocate(
}
}
LayerTreeResourceProvider::ScopedWriteLockRaster::ScopedWriteLockRaster(
LayerTreeResourceProvider* resource_provider,
viz::ResourceId resource_id)
: ScopedWriteLockGpu(resource_provider, resource_id) {}
LayerTreeResourceProvider::ScopedWriteLockRaster::~ScopedWriteLockRaster() {}
GLuint LayerTreeResourceProvider::ScopedWriteLockRaster::ConsumeTexture(
gpu::raster::RasterInterface* ri) {
DCHECK(ri);
DCHECK(!mailbox_.IsZero());
GLuint texture_id =
ri->CreateAndConsumeTexture(is_overlay_, usage_, format_, mailbox_.name);
DCHECK(texture_id);
LazyAllocate(ri, texture_id);
return texture_id;
}
void LayerTreeResourceProvider::ScopedWriteLockRaster::LazyAllocate(
gpu::raster::RasterInterface* ri,
GLuint texture_id) {
// ETC1 resources cannot be preallocated.
if (format_ == viz::ETC1)
return;
if (allocated_)
return;
allocated_ = true;
ri->TexStorage2D(texture_id, 1, size_.width(), size_.height());
if (is_overlay_ && color_space_.IsValid()) {
ri->SetColorSpaceMetadata(texture_id,
reinterpret_cast<GLColorSpace>(&color_space_));
}
}
LayerTreeResourceProvider::ScopedWriteLockSoftware::ScopedWriteLockSoftware(
LayerTreeResourceProvider* resource_provider,
viz::ResourceId resource_id)
......
......@@ -17,7 +17,6 @@ class SharedBitmapManager;
} // namespace viz
namespace gpu {
struct Capabilities;
class GpuMemoryBufferManager;
namespace raster {
class RasterInterface;
......@@ -105,10 +104,6 @@ class CC_EXPORT LayerTreeResourceProvider : public ResourceProvider {
// be called after texture deletions that may happen during an idle state.
void FlushPendingDeletions() const;
GLenum GetImageTextureTarget(const gpu::Capabilities& caps,
gfx::BufferUsage usage,
viz::ResourceFormat format) const;
bool IsTextureFormatSupported(viz::ResourceFormat format) const;
// Returns true if the provided |format| can be used as a render buffer.
......@@ -180,7 +175,6 @@ class CC_EXPORT LayerTreeResourceProvider : public ResourceProvider {
// The following are copied from the resource.
gfx::Size size_;
gfx::BufferUsage usage_;
viz::ResourceFormat format_;
gfx::ColorSpace color_space_;
GLuint texture_id_;
......@@ -215,22 +209,6 @@ class CC_EXPORT LayerTreeResourceProvider : public ResourceProvider {
DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockGL);
};
class CC_EXPORT ScopedWriteLockRaster : public ScopedWriteLockGpu {
public:
ScopedWriteLockRaster(LayerTreeResourceProvider* resource_provider,
viz::ResourceId resource_id);
~ScopedWriteLockRaster();
// Creates a texture id, allocating if necessary, on the given context. The
// texture id must be deleted by the caller.
GLuint ConsumeTexture(gpu::raster::RasterInterface* ri);
private:
void LazyAllocate(gpu::raster::RasterInterface* gl, GLuint texture_id);
DISALLOW_COPY_AND_ASSIGN(ScopedWriteLockRaster);
};
class CC_EXPORT ScopedWriteLockSoftware {
public:
ScopedWriteLockSoftware(LayerTreeResourceProvider* resource_provider,
......
......@@ -3384,176 +3384,5 @@ TEST_P(ResourceProviderTest, ScopedWriteLockGL_Overlay) {
resource_provider->DeleteResource(id);
}
TEST_P(ResourceProviderTest, ScopedWriteLockRaster_Mailbox) {
if (!use_gpu())
return;
std::unique_ptr<AllocationTrackingContext3D> context_owned(
new StrictMock<AllocationTrackingContext3D>);
AllocationTrackingContext3D* context = context_owned.get();
auto context_provider =
viz::TestContextProvider::Create(std::move(context_owned));
context_provider->BindToCurrentThread();
const int kWidth = 2;
const int kHeight = 2;
const viz::ResourceFormat format = viz::RGBA_8888;
const unsigned kTextureId = 123u;
const unsigned kWorkerTextureId = 234u;
auto resource_provider(std::make_unique<LayerTreeResourceProvider>(
context_provider.get(), shared_bitmap_manager_.get(), nullptr,
kDelegatedSyncPointsRequired, CreateResourceSettings()));
viz::ResourceId id = resource_provider->CreateGpuTextureResource(
gfx::Size(kWidth, kHeight), viz::ResourceTextureHint::kDefault, format,
gfx::ColorSpace());
InSequence sequence;
gpu::SyncToken sync_token;
// First use will create mailbox when lock is created and allocate lazily in
// ConsumeTexture.
{
EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(kTextureId));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId));
EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber());
LayerTreeResourceProvider::ScopedWriteLockRaster lock(
resource_provider.get(), id);
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, produceTextureDirectCHROMIUM(kTextureId, _));
lock.CreateMailbox();
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_))
.WillOnce(Return(kWorkerTextureId));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kWorkerTextureId));
EXPECT_CALL(*context, texImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(format),
kWidth, kHeight, 0, GLDataFormat(format),
GLDataType(format), nullptr));
EXPECT_EQ(kWorkerTextureId,
lock.ConsumeTexture(context_provider->RasterInterface()));
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
context_provider->ContextGL()->DeleteTextures(1, &kWorkerTextureId);
Mock::VerifyAndClearExpectations(context);
}
// Subsequent uses will not create mailbox or allocate.
{
LayerTreeResourceProvider::ScopedWriteLockRaster lock(
resource_provider.get(), id);
lock.CreateMailbox();
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_))
.WillOnce(Return(kWorkerTextureId));
EXPECT_EQ(kWorkerTextureId,
lock.ConsumeTexture(context_provider->RasterInterface()));
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
context_provider->ContextGL()->DeleteTextures(1, &kWorkerTextureId);
sync_token = LayerTreeResourceProvider::GenerateSyncTokenHelper(
context_provider->RasterInterface());
lock.set_sync_token(sync_token);
Mock::VerifyAndClearExpectations(context);
}
// Wait for worker context sync token before deleting texture.
EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token)));
EXPECT_CALL(*context, RetireTextureId(kTextureId));
resource_provider->DeleteResource(id);
}
TEST_P(ResourceProviderTest, ScopedWriteLockRaster_Mailbox_Overlay) {
if (!use_gpu())
return;
std::unique_ptr<AllocationTrackingContext3D> context_owned(
new StrictMock<AllocationTrackingContext3D>);
AllocationTrackingContext3D* context = context_owned.get();
context->set_support_texture_storage_image(true);
auto context_provider =
viz::TestContextProvider::Create(std::move(context_owned));
context_provider->BindToCurrentThread();
const int kWidth = 2;
const int kHeight = 2;
const viz::ResourceFormat format = viz::RGBA_8888;
const unsigned kTextureId = 123u;
const unsigned kWorkerTextureId = 234u;
auto resource_provider(std::make_unique<LayerTreeResourceProvider>(
context_provider.get(), shared_bitmap_manager_.get(), nullptr,
kDelegatedSyncPointsRequired, CreateResourceSettings()));
viz::ResourceId id = resource_provider->CreateGpuTextureResource(
gfx::Size(kWidth, kHeight), viz::ResourceTextureHint::kOverlay, format,
gfx::ColorSpace());
InSequence sequence;
gpu::SyncToken sync_token;
// First use will create mailbox when lock is created and allocate lazily in
// ConsumeTexture.
{
EXPECT_CALL(*context, NextTextureId()).WillOnce(Return(kTextureId));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kTextureId));
EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber());
LayerTreeResourceProvider::ScopedWriteLockRaster lock(
resource_provider.get(), id);
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, produceTextureDirectCHROMIUM(kTextureId, _));
lock.CreateMailbox();
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_))
.WillOnce(Return(kWorkerTextureId));
EXPECT_CALL(*context, bindTexture(GL_TEXTURE_2D, kWorkerTextureId));
EXPECT_CALL(*context, texStorage2DImageCHROMIUM(GL_TEXTURE_2D, GL_RGBA8_OES,
GL_SCANOUT_CHROMIUM, kWidth,
kHeight));
EXPECT_EQ(kWorkerTextureId,
lock.ConsumeTexture(context_provider->RasterInterface()));
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
context_provider->ContextGL()->DeleteTextures(1, &kWorkerTextureId);
Mock::VerifyAndClearExpectations(context);
}
// Subsequent uses will not create mailbox or allocate.
{
LayerTreeResourceProvider::ScopedWriteLockRaster lock(
resource_provider.get(), id);
lock.CreateMailbox();
Mock::VerifyAndClearExpectations(context);
EXPECT_CALL(*context, createAndConsumeTextureCHROMIUM(_))
.WillOnce(Return(kWorkerTextureId));
EXPECT_EQ(kWorkerTextureId,
lock.ConsumeTexture(context_provider->RasterInterface()));
Mock::VerifyAndClearExpectations(context);
sync_token = LayerTreeResourceProvider::GenerateSyncTokenHelper(
context_provider->RasterInterface());
lock.set_sync_token(sync_token);
EXPECT_CALL(*context, RetireTextureId(kWorkerTextureId));
context_provider->ContextGL()->DeleteTextures(1, &kWorkerTextureId);
Mock::VerifyAndClearExpectations(context);
}
// Wait for worker context sync token before deleting texture.
EXPECT_CALL(*context, waitSyncToken(MatchesSyncToken(sync_token)));
EXPECT_CALL(*context, RetireTextureId(kTextureId));
resource_provider->DeleteResource(id);
}
} // namespace
} // namespace cc
......@@ -189,9 +189,6 @@ struct VIZ_COMMON_EXPORT Resource {
ResourceTextureHint hint = ResourceTextureHint::kDefault;
// The type of backing for the resource (such as gpu vs software).
ResourceType type = ResourceType::kBitmap;
// GpuMemoryBuffer resource allocation needs to know how the resource will
// be used.
gfx::BufferUsage usage = gfx::BufferUsage::GPU_READ_CPU_READ_WRITE;
// This is the the actual format of the underlying GpuMemoryBuffer, if any,
// and might not correspond to ResourceFormat. This format is needed to
// allocate the GpuMemoryBuffer and scanout the buffer as a hardware overlay.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment