-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kotlin: Async wrappers for the new callback info method type.
This will be the only type of async method supported by Dawn in the future. Test: ImageTests Bug: 352710628 Change-Id: I9c776965316872b636c4a243380cc00b2a32f078 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/218954 Reviewed-by: Loko Kung <[email protected]> Commit-Queue: Loko Kung <[email protected]> Reviewed-by: Mariia (Mary) Koliadenko <[email protected]>
- Loading branch information
1 parent
08c3f83
commit 2173090
Showing
2 changed files
with
117 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
tools/android/webgpu/src/androidTest/java/android/dawn/AsyncHelperTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import android.dawn.* | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(AndroidJUnit4::class) | ||
class AsyncHelperTest { | ||
@Test | ||
fun asyncMethodTest() { | ||
dawnTestLauncher() { device -> | ||
/* Set up a shader module to support the async call. */ | ||
val shaderModule = device.createShaderModule( | ||
ShaderModuleDescriptor(shaderSourceWGSL = ShaderSourceWGSL("")) | ||
) | ||
|
||
/* Call an asynchronous method, converted from a callback pattern by a helper. */ | ||
val result = device.createRenderPipelineAsync( | ||
RenderPipelineDescriptor(vertex = VertexState(module = shaderModule)) | ||
) | ||
|
||
assert(result.status == CreatePipelineAsyncStatus.ValidationError) { | ||
"""Create render pipeline (async) should fail when no shader entry point exists. | ||
The result was: ${result.status}""" | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun asyncMethodTestValidationPasses() { | ||
dawnTestLauncher() { device -> | ||
/* Set up a shader module to support the async call. */ | ||
val shaderModule = device.createShaderModule( | ||
ShaderModuleDescriptor( | ||
shaderSourceWGSL = ShaderSourceWGSL( | ||
""" | ||
@vertex fn vertexMain(@builtin(vertex_index) i : u32) -> | ||
@builtin(position) vec4f { | ||
return vec4f(); | ||
} | ||
@fragment fn fragmentMain() -> @location(0) vec4f { | ||
return vec4f(); | ||
} | ||
""" | ||
) | ||
) | ||
) | ||
|
||
/* Call an asynchronous method, converted from a callback pattern by a helper. */ | ||
val result = device.createRenderPipelineAsync( | ||
RenderPipelineDescriptor( | ||
vertex = VertexState(module = shaderModule), | ||
fragment = FragmentState( | ||
module = shaderModule, | ||
targets = arrayOf(ColorTargetState(format = TextureFormat.RGBA8Unorm)) | ||
) | ||
) | ||
) | ||
|
||
assert(result.status == CreatePipelineAsyncStatus.Success) { | ||
"""Create render pipeline (async) should pass with a simple shader. | ||
The result was: ${result.status} | ||
The message was: ${result.message}""" | ||
} | ||
} | ||
} | ||
} |