Skip to content

Commit

Permalink
chore: collect render target count in render encoder data
Browse files Browse the repository at this point in the history
  • Loading branch information
3Shain committed Dec 8, 2024
1 parent f7c3dcd commit d393e41
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/d3d11/d3d11_context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3289,7 +3289,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p

renderPassDescriptor->setRenderTargetArrayLength(render_target_array);

ctx.startRenderPass(std::move(renderPassDescriptor), dsv_planar_flags);
ctx.startRenderPass(std::move(renderPassDescriptor), dsv_planar_flags, rtvs.size());
});
}

Expand Down
7 changes: 5 additions & 2 deletions src/dxmt/dxmt_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,16 @@ ArgumentEncodingContext::present(Rc<Texture> &texture, CA::MetalDrawable *drawab
}

RenderEncoderData *
ArgumentEncodingContext::startRenderPass(Obj<MTL::RenderPassDescriptor> &&descriptor, uint32_t dsv_planar_flags) {
ArgumentEncodingContext::startRenderPass(
Obj<MTL::RenderPassDescriptor> &&descriptor, uint32_t dsv_planar_flags, uint32_t render_target_count
) {
assert(!encoder_current);
auto encoder_info = allocate<RenderEncoderData>();
encoder_info->type = EncoderType::Render;
encoder_info->id = nextEncoderId();
encoder_info->descriptor = std::move(descriptor);
encoder_info->dsv_planar_flags = dsv_planar_flags;
encoder_info->render_target_count = render_target_count;
encoder_current = encoder_info;

vro_state_.beginEncoder();
Expand Down Expand Up @@ -649,7 +652,7 @@ ArgumentEncodingContext::checkEncoderRelation(EncoderData *former, EncoderData *
clear->type = EncoderType::Null;
return DXMT_ENCODER_LIST_OP_COALESCE;
} else {
for (unsigned i = 0; i < 8 /* FIXME: optimize constant */; i++) {
for (unsigned i = 0; i < render->render_target_count; i++) {
auto attachment = render->descriptor->colorAttachments()->object(i);
if (attachment->texture() == clear->texture.ptr() && attachment->loadAction() == MTL::LoadActionLoad) {
attachment->setLoadAction(MTL::LoadActionClear);
Expand Down
8 changes: 3 additions & 5 deletions src/dxmt/dxmt_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,9 @@ struct RenderEncoderData : EncoderData {
CommandList<RenderCommandContext> cmds;
CommandList<RenderCommandContext> pretess_cmds;
uint32_t dsv_planar_flags;
uint32_t render_target_count = 0;
bool use_visibility_result = 0;
bool use_tessellation = 0;
bool coalesced_start = 0;
bool coalesced_end = 0;
};

struct ComputeCommandContext {
Expand All @@ -117,8 +116,6 @@ struct ComputeCommandContext {

struct ComputeEncoderData : EncoderData {
CommandList<ComputeCommandContext> cmds;
bool coalesced_start;
bool coalesced_end;
};

struct BlitCommandContext {
Expand Down Expand Up @@ -463,7 +460,8 @@ class ArgumentEncodingContext {
);
void resolveTexture(Rc<Texture> &&src, unsigned srcSlice, Rc<Texture> &&dst, unsigned dstSlice, unsigned dstLevel);

RenderEncoderData *startRenderPass(Obj<MTL::RenderPassDescriptor> &&descriptor, uint32_t dsv_planar_flags);
RenderEncoderData *
startRenderPass(Obj<MTL::RenderPassDescriptor> &&descriptor, uint32_t dsv_planar_flags, uint32_t render_target_count);
EncoderData *startComputePass();
EncoderData *startBlitPass();

Expand Down

0 comments on commit d393e41

Please sign in to comment.