1 /*
2 * Copyright 2024 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "tests/Test.h"
9
10 #include "include/gpu/graphite/Context.h"
11 #include "include/gpu/graphite/ContextOptions.h"
12 #include "include/gpu/graphite/Recorder.h"
13
14 static constexpr size_t kContextBudget = 1234567;
15
set_context_budget(skgpu::graphite::ContextOptions * options)16 static void set_context_budget(skgpu::graphite::ContextOptions* options) {
17 options->fGpuBudgetInBytes = kContextBudget;
18 }
19
20 DEF_CONDITIONAL_GRAPHITE_TEST_FOR_CONTEXTS(CacheBudgetTest,
21 /* filter= */ nullptr,
22 reporter,
23 context,
24 testContext,
25 /* anonymous options */,
26 set_context_budget,
27 /* condition= */ true,
28 CtsEnforcement::kApiLevel_202404) {
29 REPORTER_ASSERT(reporter, context->maxBudgetedBytes() == kContextBudget);
30
31 static constexpr size_t kRecorderBudget = 7654321;
32 skgpu::graphite::RecorderOptions recorderOptions;
33 recorderOptions.fGpuBudgetInBytes = kRecorderBudget;
34
35 auto recorder = context->makeRecorder(recorderOptions);
36 if (!recorder) {
37 ERRORF(reporter, "Could not create recorder.");
38 return;
39 }
40
41 REPORTER_ASSERT(reporter, recorder->maxBudgetedBytes() == kRecorderBudget);
42 }
43