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