39#include <initializer_list>
58namespace skgpu {
struct VulkanInterface; }
60#ifdef VK_USE_PLATFORM_WIN32_KHR
74 const uint32_t* canvasPixels =
static_cast<const uint32_t*
>(
bitmap.getPixels());
76 bool failureFound =
false;
78 for (
int cy = 0; cy <
CHILD_H && !failureFound; ++cy) {
79 for (
int cx = 0; cx <
CHILD_W && !failureFound; ++cx) {
83 expectedPixel = 0xFF0000FF;
85 expectedPixel = 0xFFFF0000;
88 expectedPixel = 0xFF00FF00;
90 if (expectedPixel != canvasPixel) {
92 ERRORF(
reporter,
"Wrong color at %d, %d. Got 0x%08x when we expected 0x%08x",
93 cx, cy, canvasPixel, expectedPixel);
125 childSurface->
wait(1, &semaphore);
136 bitmap.allocPixels(childII);
150 if (!mainCtx->priv().caps()->backendSemaphoreSupport()) {
162 auto blueImage = blueSurface->makeImageSnapshot();
177 createInfo.
pNext =
nullptr;
178 createInfo.
flags = 0;
186 info.fNumSemaphores = 2;
187 info.fSignalSemaphores = semaphores.
get();
193 mainCtx->flush(blueImage,
info);
196 mainCtx->flush(
info);
220#if defined(SK_BUILD_FOR_UNIX) || defined(SK_BUILD_FOR_WIN) || defined(SK_BUILD_FOR_MAC)
266 auto ctx = ctxInfo.directContext();
267 if (!ctx->priv().caps()->backendSemaphoreSupport()) {
297 VkCommandBuffer cmdBuffer;
316 cmdBufferBeginInfo.
pNext =
nullptr;
328 err =
GR_VK_CALL(interface, CreateFence(
device, &fenceInfo,
nullptr, &fence));
335 submitInfo.
pNext =
nullptr;
346 err =
GR_VK_CALL(interface, WaitForFences(
device, 1, &fence,
true, 3000000000));
356 SK_ABORT(
"Waiting on semaphore indefinitely");
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kTopLeft_GrSurfaceOrigin
#define GR_VK_CALL(IFACE, X)
#define GR_VK_CALL_ERRCHECK(GPU, X)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SK_ABORT(message,...)
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
void sk_ignore_unused_variable(const T &)
DEF_GANESH_TEST_FOR_RENDERING_CONTEXTS(EmptySurfaceSemaphoreTest, reporter, ctxInfo, CtsEnforcement::kApiLevel_T)
void check_pixels(skiatest::Reporter *reporter, const SkBitmap &bitmap)
void surface_semaphore_test(skiatest::Reporter *reporter, const sk_gpu_test::ContextInfo &mainInfo, const sk_gpu_test::ContextInfo &childInfo1, const sk_gpu_test::ContextInfo &childInfo2, FlushType flushType)
DEF_GANESH_TEST(SurfaceSemaphores, reporter, options, CtsEnforcement::kApiLevel_T)
void draw_child(skiatest::Reporter *reporter, const sk_gpu_test::ContextInfo &childInfo, const GrBackendTexture &backendTexture, const GrBackendSemaphore &semaphore)
#define REPORTER_ASSERT(r, cond,...)
VkCommandPool vkCommandPool() const
GrVkCommandPool * cmdPool() const
void drawIRect(const SkIRect &rect, const SkPaint &paint)
void clear(SkColor color)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
sk_sp< SkSurface > makeSurface(const SkImageInfo &imageInfo)
@ kFlushRead
back-end object is readable
bool wait(int numSemaphores, const GrBackendSemaphore *waitSemaphores, bool deleteSemaphoresAfterWait=true)
bool readPixels(const SkPixmap &dst, int srcX, int srcY)
GrBackendApi backend() const
GrDirectContext * directContext() const
TestContext * testContext() const
ContextInfo getContextInfo(ContextType type, ContextOverrides=ContextOverrides::kNone)
ContextInfo getSharedContextInfo(GrDirectContext *shareContext, uint32_t shareIndex=0)
SK_API GrBackendSemaphore MakeVk(VkSemaphore semaphore)
SK_API VkSemaphore GetVkSemaphore(const GrBackendSemaphore &)
SK_API void SetVkImageLayout(GrBackendTexture *, VkImageLayout)
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
sk_sp< SkBlender > blender SkRect rect
@ kNoAccess
back-end surface will not be used by client
SK_API GrBackendTexture GetBackendTexture(SkSurface *, BackendHandleAccess)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
static const int kContextTypeCount
const char * ContextTypeName(skgpu::ContextType type)
bool IsRenderingContext(skgpu::ContextType type)
static constexpr auto kNativeGLType
GrBackendSemaphore * fSignalSemaphores
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
const VkCommandBufferInheritanceInfo * pInheritanceInfo
VkCommandBufferUsageFlags flags
VkSemaphoreCreateFlags flags
uint32_t waitSemaphoreCount
const VkPipelineStageFlags * pWaitDstStageMask
uint32_t commandBufferCount
const VkSemaphore * pWaitSemaphores
uint32_t signalSemaphoreCount
const VkCommandBuffer * pCommandBuffers
const VkSemaphore * pSignalSemaphores
VkFlags VkPipelineStageFlags
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
@ VK_COMMAND_BUFFER_LEVEL_PRIMARY
@ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
@ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
@ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
@ VK_STRUCTURE_TYPE_SUBMIT_INFO