Revert "Reland "Add api on GrContext to update the data of GrBackendTextures.""

This reverts commit 83c6626946.

Reason for revert: technospark is failing to upload pixmaps to non base mip levels

Original change's description:
> Reland "Add api on GrContext to update the data of GrBackendTextures."
> 
> This reverts commit 93ca54e0ac.
> 
> Reason for revert: relanding with fix
> 
> Original change's description:
> > Revert "Add api on GrContext to update the data of GrBackendTextures."
> > 
> > This reverts commit ac09f7cd7a.
> > 
> > Reason for revert: breaking bots, may need to use swizzled color for
> > correctness test
> > 
> > Original change's description:
> > > Add api on GrContext to update the data of GrBackendTextures.
> > > 
> > > Change-Id: I680f12bf58fc7b66a6b2f3fa4c4723ae84d3f949
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288555
> > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > 
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > 
> > Change-Id: I47f41f536619ac13ca3ceeb216e7eaed9a9af255
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288630
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> 
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> 
> # Not skipping CQ checks because this is a reland.
> 
> Change-Id: I82283b2437e523b80acead71c5f7c651180620db
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288631
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>

TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com

Change-Id: I5d6614db8db59a69ded511726507a186596cfbd4
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/288907
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2020-05-11 15:48:32 +00:00 committed by Skia Commit-Bot
parent 76cb9c4d4c
commit ed219fe171
5 changed files with 28 additions and 186 deletions

View File

@ -6,10 +6,6 @@ This file includes a list of high level updates for each milestone release.
Milestone 84
* Add api on GrContext, updateBackendTexture that will upload new data to a
GrBackendTexture.
https://review.skia.org/288555
* GrContext::createBackendTexture functions that initialize the texture no longer
guarantee that all the data has been uploaded and the gpu is done with the texture.
Instead the client can assume the upload work has been submitted to the gpu and they

View File

@ -546,42 +546,6 @@ public:
finishedContext);
}
/**
* If possible, updates a backend texture to be filled to a particular color. The client should
* check the return value to see if the update was successful. The client can pass in a
* finishedProc to be notified when the data has been uploaded by the gpu and the texture can be
* deleted. The client can assume the upload work has been submitted to the gpu. The
* finishedProc will always get called even if we failed to update the GrBackendTexture.
* For the Vulkan backend after a successful update the layout of the created VkImage will be:
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
*/
bool updateBackendTexture(const GrBackendTexture&,
const SkColor4f& color,
GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext);
/**
* If possible, updates a backend texture filled with the provided pixmap data. The client
* should check the return value to see if the update was successful. The client can pass in a
* finishedProc to be notified when the data has been uploaded by the gpu and the texture can be
* deleted. The client can assume the upload work has been submitted to the gpu. The
* finishedProc will always get called even if we failed to create the GrBackendTexture.
* The backend texture must be compatible with the provided pixmap(s). Compatible, in this case,
* means that the backend format is compatible with the base pixmap's colortype.
* If the backend texture is mip mapped, the data for all the mipmap levels must be provided.
* In the mipmapped case all the colortypes of the provided pixmaps must be the same.
* Additionally, all the miplevels must be sized correctly (please see
* SkMipMap::ComputeLevelSize and ComputeLevelCount).
* Note: the pixmap's alphatypes and colorspaces are ignored.
* For the Vulkan backend after a successful update the layout of the created VkImage will be:
* VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
*/
bool updateBackendTexture(const GrBackendTexture&,
const SkPixmap srcData[],
int numLevels,
GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext);
/**
* Retrieve the GrBackendFormat for a given SkImage::CompressionType. This is
* guaranteed to match the backend format used by the following

View File

@ -623,58 +623,6 @@ GrBackendTexture GrContext::createBackendTexture(const SkPixmap srcData[], int n
finishedContext, &data);
}
bool GrContext::updateBackendTexture(const GrBackendTexture& backendTexture,
const SkColor4f& color,
GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) {
if (!this->asDirectContext()) {
finishedProc(finishedContext);
return false;
}
if (this->abandoned()) {
finishedProc(finishedContext);
return false;
}
GrGpu::BackendTextureData data(color);
return fGpu->updateBackendTexture(backendTexture, finishedProc, finishedContext, &data);
}
bool GrContext::updateBackendTexture(const GrBackendTexture& backendTexture,
const SkPixmap srcData[],
int numLevels,
GrGpuFinishedProc finishedProc,
GrGpuFinishedContext finishedContext) {
if (!this->asDirectContext()) {
finishedProc(finishedContext);
return false;
}
if (this->abandoned()) {
finishedProc(finishedContext);
return false;
}
if (!srcData || numLevels <= 0) {
finishedProc(finishedContext);
return false;
}
int numExpectedLevels = 1;
if (backendTexture.hasMipMaps()) {
numExpectedLevels = SkMipMap::ComputeLevelCount(backendTexture.width(),
backendTexture.height()) + 1;
}
if (numLevels != numExpectedLevels) {
finishedProc(finishedContext);
return false;
}
GrGpu::BackendTextureData data(srcData);
return fGpu->updateBackendTexture(backendTexture, finishedProc, finishedContext, &data);
}
//////////////////////////////////////////////////////////////////////////////
GrBackendTexture GrContext::createCompressedBackendTexture(int width, int height,

View File

@ -3569,22 +3569,6 @@ bool GrGLGpu::onUpdateBackendTexture(const GrBackendTexture& backendTexture,
this->bindTextureToScratchUnit(GR_GL_TEXTURE_2D, info.fID);
// If we have mips make sure the base level is set to 0 and the max level set to numMipLevesl-1
// so that the uploads go to the right levels.
if (numMipLevels) {
auto params = backendTexture.getGLTextureParams();
GrGLTextureParameters::NonsamplerState nonsamplerState = params->nonsamplerState();
if (params->nonsamplerState().fBaseMipMapLevel != 0) {
GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_BASE_LEVEL, 0));
nonsamplerState.fBaseMipMapLevel = 0;
}
if (params->nonsamplerState().fMaxMipMapLevel != (numMipLevels - 1)) {
GL_CALL(TexParameteri(GR_GL_TEXTURE_2D, GR_GL_TEXTURE_MAX_LEVEL, numMipLevels - 1));
nonsamplerState.fBaseMipMapLevel = numMipLevels - 1;
}
params->set(nullptr, nonsamplerState, fResetTimestampForTextureParameters);
}
SkASSERT(data->type() != BackendTextureData::Type::kCompressed);
if (data->type() == BackendTextureData::Type::kPixmaps) {
SkTDArray<GrMipLevel> texels;

View File

@ -28,7 +28,8 @@
#include "src/gpu/mtl/GrMtlCppUtil.h"
#endif
static void wait_on_backend_work_to_finish(GrContext* context, bool* finishedCreate) {
static void delete_backend_texture(GrContext* context, const GrBackendTexture& backendTexture,
bool* finishedCreate) {
while (finishedCreate && !(*finishedCreate)) {
context->checkAsyncWorkCompletion();
}
@ -38,18 +39,9 @@ static void wait_on_backend_work_to_finish(GrContext* context, bool* finishedCre
// Reset it here so that it can be use to signal a future backend texture's creation
*finishedCreate = false;
}
}
static void delete_backend_texture(GrContext* context, const GrBackendTexture& backendTexture,
bool* finishedCreate) {
wait_on_backend_work_to_finish(context, finishedCreate);
context->deleteBackendTexture(backendTexture);
}
static void mark_signaled(void* context) {
*(bool*)context = true;
}
// Test wrapping of GrBackendObjects in SkSurfaces and SkImages (non-static since used in Mtl test)
void test_wrapping(GrContext* context, skiatest::Reporter* reporter,
std::function<GrBackendTexture (GrContext*,
@ -321,35 +313,16 @@ void test_color_init(GrContext* context, skiatest::Reporter* reporter,
return;
}
auto checkBackendTexture = [&](const SkColor4f& testColor) {
if (mipMapped == GrMipMapped::kYes) {
SkColor4f expectedColor = get_expected_color(testColor, skColorType);
SkColor4f expectedColors[6] = {expectedColor, expectedColor, expectedColor,
expectedColor, expectedColor, expectedColor};
check_mipmaps(context, backendTex, skColorType, expectedColors, reporter, "colorinit");
}
// The last step in this test will dirty the mipmaps so do it last
check_base_readbacks(context, backendTex, skColorType, renderable, testColor, reporter,
"colorinit");
};
checkBackendTexture(color);
// Make sure the initial create work has finished so we can test the update independently.
wait_on_backend_work_to_finish(context, finishedBECreate);
SkColor4f newColor = {color.fB , color.fR, color.fG, color.fA };
// Reupload the new data and make sure everything still works. We test with an SkColorType so
// we may actually swizzle the input during the create path. The update does not do any swizzle
// of the passed in color. So we manually do it here so we get the same expected results.
SkColor4f swizzledColor = context->priv().caps()->getWriteSwizzle(
backendTex.getBackendFormat(), grColorType).applyTo(newColor);
context->updateBackendTexture(backendTex, swizzledColor, mark_signaled, finishedBECreate);
checkBackendTexture(newColor);
if (mipMapped == GrMipMapped::kYes) {
SkColor4f expectedColor = get_expected_color(color, skColorType);
SkColor4f expectedColors[6] = { expectedColor, expectedColor, expectedColor,
expectedColor, expectedColor, expectedColor };
check_mipmaps(context, backendTex, skColorType, expectedColors, reporter, "colorinit");
}
// The last step in this test will dirty the mipmaps so do it last
check_base_readbacks(context, backendTex, skColorType, renderable, color,
reporter, "colorinit");
delete_backend_texture(context, backendTex, finishedBECreate);
}
@ -488,49 +461,22 @@ static void test_pixmap_init(GrContext* context, skiatest::Reporter* reporter,
return;
}
auto checkBackendTexture = [&](SkColor4f colors[6]) {
if (mipMapped == GrMipMapped::kYes) {
SkColor4f expectedColors[6] = {
get_expected_color(colors[0], skColorType),
get_expected_color(colors[1], skColorType),
get_expected_color(colors[2], skColorType),
get_expected_color(colors[3], skColorType),
get_expected_color(colors[4], skColorType),
get_expected_color(colors[5], skColorType),
};
if (mipMapped == GrMipMapped::kYes) {
SkColor4f expectedColors[6] = {
get_expected_color(colors[0], skColorType),
get_expected_color(colors[1], skColorType),
get_expected_color(colors[2], skColorType),
get_expected_color(colors[3], skColorType),
get_expected_color(colors[4], skColorType),
get_expected_color(colors[5], skColorType),
};
check_mipmaps(context, backendTex, skColorType, expectedColors, reporter, "pixmap");
}
// The last step in this test will dirty the mipmaps so do it last
check_base_readbacks(context, backendTex, skColorType, renderable, colors[0], reporter,
"pixmap");
};
checkBackendTexture(colors);
// Make sure the initial create work has finished so we can test the update independently.
wait_on_backend_work_to_finish(context, finishedBECreate);
SkColor4f colorsNew[6] = {
{1.0f, 1.0f, 0.0f, 0.2f}, // Y
{1.0f, 0.0f, 0.0f, 1.0f}, // R
{0.0f, 1.0f, 0.0f, 0.9f}, // G
{0.0f, 0.0f, 1.0f, 0.7f}, // B
{0.0f, 1.0f, 1.0f, 0.5f}, // C
{1.0f, 0.0f, 1.0f, 0.3f}, // M
};
make_pixmaps(skColorType, mipMapped, colorsNew, pixmapMem);
for (int i = 0; i < numMipLevels; ++i) {
pixmaps[i].reset(pixmapMem[i].info(), pixmapMem[i].addr(), pixmapMem[i].rowBytes());
check_mipmaps(context, backendTex, skColorType, expectedColors, reporter, "pixmap");
}
// Upload new data and make sure everything still works
context->updateBackendTexture(backendTex, pixmaps, numMipLevels, mark_signaled,
finishedBECreate);
checkBackendTexture(colorsNew);
// The last step in this test will dirty the mipmaps so do it last
check_base_readbacks(context, backendTex, skColorType, renderable, colors[0],
reporter, "pixmap");
delete_backend_texture(context, backendTex, finishedBECreate);
}
@ -563,6 +509,10 @@ void check_vk_layout(const GrBackendTexture& backendTex, VkLayout layout) {
#endif
}
static void mark_signaled(void* context) {
*(bool*)context = true;
}
///////////////////////////////////////////////////////////////////////////////
// This test is a bit different from the others in this file. It is mainly checking that, for any
// SkSurface we can create in Ganesh, we can also create a backend texture that is compatible with