wip
This commit is contained in:
parent
32758022df
commit
22c9d133bd
2 changed files with 29 additions and 13 deletions
|
@ -371,11 +371,10 @@ impl DirectXRenderer {
|
|||
});
|
||||
start_vertex_location += path.vertices.len() as u32;
|
||||
|
||||
vertices.extend(path.vertices.iter().map(|v| PathVertex {
|
||||
vertices.extend(path.vertices.iter().map(|v| DirectXPathVertex {
|
||||
xy_position: v.xy_position,
|
||||
content_mask: ContentMask {
|
||||
bounds: path.content_mask.bounds,
|
||||
},
|
||||
content_mask: path.content_mask.bounds,
|
||||
sprite_index: i as u32,
|
||||
}));
|
||||
|
||||
sprites.push(PathSprite {
|
||||
|
@ -796,7 +795,7 @@ impl PathsPipelineState {
|
|||
let view = create_buffer_view(device, &buffer)?;
|
||||
let vertex_buffer = Some(create_buffer(
|
||||
device,
|
||||
std::mem::size_of::<PathVertex<ScaledPixels>>(),
|
||||
std::mem::size_of::<DirectXPathVertex>(),
|
||||
32,
|
||||
)?);
|
||||
let indirect_draw_buffer = create_indirect_draw_buffer(device, 32)?;
|
||||
|
@ -836,6 +835,15 @@ impl PathsPipelineState {
|
|||
InputSlotClass: D3D11_INPUT_PER_VERTEX_DATA,
|
||||
InstanceDataStepRate: 0,
|
||||
},
|
||||
D3D11_INPUT_ELEMENT_DESC {
|
||||
SemanticName: windows::core::s!("GLOBALIDX"),
|
||||
SemanticIndex: 0,
|
||||
Format: DXGI_FORMAT_R32_UINT,
|
||||
InputSlot: 0,
|
||||
AlignedByteOffset: 24,
|
||||
InputSlotClass: D3D11_INPUT_PER_VERTEX_DATA,
|
||||
InstanceDataStepRate: 0,
|
||||
},
|
||||
],
|
||||
shader_bytes,
|
||||
Some(&mut layout),
|
||||
|
@ -862,7 +870,7 @@ impl PathsPipelineState {
|
|||
device: &ID3D11Device,
|
||||
device_context: &ID3D11DeviceContext,
|
||||
buffer_data: &[PathSprite],
|
||||
vertices_data: &[PathVertex<ScaledPixels>],
|
||||
vertices_data: &[DirectXPathVertex],
|
||||
draw_commands: &[DrawInstancedIndirectArgs],
|
||||
) -> Result<()> {
|
||||
if self.buffer_size < buffer_data.len() {
|
||||
|
@ -888,7 +896,7 @@ impl PathsPipelineState {
|
|||
);
|
||||
let vertex_buffer = create_buffer(
|
||||
device,
|
||||
std::mem::size_of::<PathVertex<ScaledPixels>>(),
|
||||
std::mem::size_of::<DirectXPathVertex>(),
|
||||
new_vertex_buffer_size,
|
||||
)?;
|
||||
self.vertex_buffer = Some(vertex_buffer);
|
||||
|
@ -932,7 +940,7 @@ impl PathsPipelineState {
|
|||
global_params,
|
||||
);
|
||||
unsafe {
|
||||
const STRIDE: u32 = std::mem::size_of::<PathVertex<ScaledPixels>>() as u32;
|
||||
const STRIDE: u32 = std::mem::size_of::<DirectXPathVertex>() as u32;
|
||||
device_context.IASetVertexBuffers(
|
||||
0,
|
||||
1,
|
||||
|
@ -954,6 +962,13 @@ impl PathsPipelineState {
|
|||
}
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
struct DirectXPathVertex {
|
||||
xy_position: Point<ScaledPixels>,
|
||||
content_mask: Bounds<ScaledPixels>,
|
||||
sprite_index: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
#[repr(C)]
|
||||
struct PathSprite {
|
||||
|
|
|
@ -879,6 +879,7 @@ float4 shadow_fragment(ShadowFragmentInput input): SV_TARGET {
|
|||
struct PathVertex {
|
||||
float2 xy_position: POSITION;
|
||||
Bounds content_mask: TEXCOORD;
|
||||
uint idx: GLOBALIDX;
|
||||
};
|
||||
|
||||
struct PathSprite {
|
||||
|
@ -905,13 +906,13 @@ struct PathFragmentInput {
|
|||
|
||||
StructuredBuffer<PathSprite> path_sprites: register(t1);
|
||||
|
||||
PathVertexOutput paths_vertex(PathVertex v, uint instance_id: SV_InstanceID) {
|
||||
PathSprite sprite = path_sprites[instance_id];
|
||||
PathVertexOutput paths_vertex(PathVertex input) {
|
||||
PathSprite sprite = path_sprites[input.idx];
|
||||
|
||||
PathVertexOutput output;
|
||||
output.position = to_device_position_impl(v.xy_position);
|
||||
output.clip_distance = distance_from_clip_rect_impl(v.xy_position, v.content_mask);
|
||||
output.sprite_id = instance_id;
|
||||
output.position = to_device_position_impl(input.xy_position);
|
||||
output.clip_distance = distance_from_clip_rect_impl(input.xy_position, input.content_mask);
|
||||
output.sprite_id = input.idx;
|
||||
|
||||
GradientColor gradient = prepare_gradient_color(
|
||||
sprite.color.tag,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue