Skip to content

Commit

Permalink
Add a kinc_g4_render_target_use_color_as_texture variation for Kong
Browse files Browse the repository at this point in the history
  • Loading branch information
RobDangerous committed Sep 26, 2023
1 parent 94e35eb commit 421d669
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,17 @@ void kinc_g4_render_target_destroy(kinc_g4_render_target_t *renderTarget) {
renderTarget->impl.textureSample->lpVtbl->Release(renderTarget->impl.textureSample);
}

#ifdef KINC_KONG
void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, uint32_t unit) {
if (renderTarget->impl.textureSample != renderTarget->impl.textureRender) {
dx_ctx.context->lpVtbl->ResolveSubresource(dx_ctx.context, (ID3D11Resource *)renderTarget->impl.textureSample, 0,
(ID3D11Resource *)renderTarget->impl.textureRender, 0, DXGI_FORMAT_R8G8B8A8_UNORM);
}

dx_ctx.context->lpVtbl->PSSetShaderResources(dx_ctx.context, unit, 1,
renderTarget->isDepthAttachment ? &renderTarget->impl.depthStencilSRV : &renderTarget->impl.renderTargetSRV);
}
#else
void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, kinc_g4_texture_unit_t unit) {
if (unit.stages[KINC_G4_SHADER_TYPE_FRAGMENT] < 0 && unit.stages[KINC_G4_SHADER_TYPE_VERTEX] < 0)
return;
Expand All @@ -394,6 +405,7 @@ void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderT
: &renderTarget->impl.renderTargetSRV);
}
}
#endif

void kinc_g4_render_target_use_depth_as_texture(kinc_g4_render_target_t *renderTarget, kinc_g4_texture_unit_t unit) {
if (unit.stages[KINC_G4_SHADER_TYPE_VERTEX] >= 0) {
Expand Down
9 changes: 9 additions & 0 deletions Sources/kinc/graphics4/rendertarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,21 @@ KINC_FUNC void kinc_g4_render_target_init_cube_with_multisampling(kinc_g4_render
/// <param name="renderTarget">The render-target to destroy</param>
KINC_FUNC void kinc_g4_render_target_destroy(kinc_g4_render_target_t *renderTarget);

#ifdef KINC_KONG
/// <summary>
/// Uses the color-component of a render-target as a texture.
/// </summary>
/// <param name="renderTarget">The render-target to use</param>
/// <param name="unit">The texture-unit to assign the render-target to</param>
KINC_FUNC void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, uint32_t unit);
#else
/// <summary>
/// Uses the color-component of a render-target as a texture.
/// </summary>
/// <param name="renderTarget">The render-target to use</param>
/// <param name="unit">The texture-unit to assign the render-target to</param>
KINC_FUNC void kinc_g4_render_target_use_color_as_texture(kinc_g4_render_target_t *renderTarget, kinc_g4_texture_unit_t unit);
#endif

/// <summary>
/// Uses the depth-component of a render-target as a texture.
Expand Down

0 comments on commit 421d669

Please sign in to comment.