#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/modules/webgpu/gpu_render_pipeline.h"
#include "third_party/blink/renderer/bindings/core/v8/native_value_traits_impl.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_blend_component.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_blend_state.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_color_state_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_color_target_state.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_depth_stencil_state.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_fragment_state.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_multisample_state.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_primitive_state.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_rasterization_state_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_render_pipeline_descriptor.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_stencil_face_state.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_vertex_attribute.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_vertex_buffer_layout.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_gpu_vertex_state.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_bind_group_layout.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_device.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_pipeline_layout.h"
#include "third_party/blink/renderer/modules/webgpu/gpu_shader_module.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/script_state.h"
namespace blink {
namespace {
const char kGPUBlendComponentPartiallySpecifiedMessage[] = …;
wgpu::BlendComponent AsDawnType(const GPUBlendComponent* webgpu_desc) { … }
wgpu::BlendState AsDawnType(const GPUBlendState* webgpu_desc) { … }
bool ValidateBlendComponent(GPUDevice* device,
const GPUBlendComponent* webgpu_desc,
ExceptionState& exception_state) { … }
}
wgpu::ColorTargetState AsDawnType(const GPUColorTargetState* webgpu_desc) { … }
wgpu::VertexBufferLayout AsDawnType(const GPUVertexBufferLayout* webgpu_desc) { … }
wgpu::VertexAttribute AsDawnType(const GPUVertexAttribute* webgpu_desc) { … }
namespace {
wgpu::StencilFaceState AsDawnType(const GPUStencilFaceState* webgpu_desc) { … }
wgpu::PrimitiveState AsDawnType(const GPUPrimitiveState* webgpu_desc) { … }
wgpu::DepthStencilState AsDawnType(GPUDevice* device,
const GPUDepthStencilState* webgpu_desc,
wgpu::PrimitiveTopology topology,
ExceptionState& exception_state) { … }
wgpu::MultisampleState AsDawnType(const GPUMultisampleState* webgpu_desc) { … }
void AsDawnVertexBufferLayouts(GPUDevice* device,
const GPUVertexState* descriptor,
OwnedVertexState* dawn_desc_info) { … }
void GPUVertexStateAsWGPUVertexState(GPUDevice* device,
const GPUVertexState* descriptor,
OwnedVertexState* dawn_vertex) { … }
bool IsGPUBlendComponentPartiallySpecified(
const GPUBlendComponent* webgpu_desc) { … }
void GPUFragmentStateAsWGPUFragmentState(GPUDevice* device,
const GPUFragmentState* descriptor,
OwnedFragmentState* dawn_fragment,
ExceptionState& exception_state) { … }
}
void ConvertToDawnType(v8::Isolate* isolate,
GPUDevice* device,
const GPURenderPipelineDescriptor* webgpu_desc,
OwnedRenderPipelineDescriptor* dawn_desc_info,
ExceptionState& exception_state) { … }
GPURenderPipeline* GPURenderPipeline::Create(
ScriptState* script_state,
GPUDevice* device,
const GPURenderPipelineDescriptor* webgpu_desc) { … }
GPURenderPipeline::GPURenderPipeline(GPUDevice* device,
wgpu::RenderPipeline render_pipeline,
const String& label)
: … { … }
GPUBindGroupLayout* GPURenderPipeline::getBindGroupLayout(uint32_t index) { … }
}