Skip to content

Commit

Permalink
Merge branch 'dev/adunn/move_doublesided_to_instance' into 'main'
Browse files Browse the repository at this point in the history
Remix API: Move doublesided flag to instance info

See merge request lightspeedrtx/dxvk-remix-nv!607
  • Loading branch information
AlexDunn committed Dec 7, 2023
2 parents 0efd070 + 4769b79 commit 79a970f
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions public/include/remix/remix.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,6 @@ namespace remix {
hash = 0;
surfaces_values = {};
surfaces_count = 0;
doubleSided = false;
static_assert(sizeof remixapi_MeshInfo == 40);
}
};
Expand Down Expand Up @@ -531,7 +530,8 @@ namespace remix {
categoryFlags = 0;
mesh = 0;
transform = {};
static_assert(sizeof remixapi_InstanceInfo == 80);
doubleSided = false;
static_assert(sizeof remixapi_InstanceInfo == 88);
}
};

Expand Down
2 changes: 1 addition & 1 deletion public/include/remix/remix_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ extern "C" {
uint64_t hash;
const remixapi_MeshInfoSurfaceTriangles* surfaces_values;
uint32_t surfaces_count;
remixapi_Bool doubleSided;
} remixapi_MeshInfo;

typedef remixapi_ErrorCode(REMIXAPI_PTR* PFN_remixapi_CreateMesh)(
Expand Down Expand Up @@ -371,6 +370,7 @@ extern "C" {
remixapi_InstanceCategoryFlags categoryFlags;
remixapi_MeshHandle mesh;
remixapi_Transform transform;
remixapi_Bool doubleSided;
} remixapi_InstanceInfo;

typedef remixapi_ErrorCode(REMIXAPI_PTR* PFN_remixapi_DrawInstance)(
Expand Down
3 changes: 2 additions & 1 deletion src/dxvk/rtx_render/rtx_remix_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ dxvk::ExternalDrawState dxvk::RemixAPIPrivateAccessor::toRtDrawState(const remix
info.mesh,
convert::categoryToCameraType(info.categoryFlags),
convert::toRtCategories(info.categoryFlags),
convert::tobool(info.doubleSided)
};
}

Expand Down Expand Up @@ -713,7 +714,7 @@ namespace {
{
dst.externalMaterial = src.material;
dst.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
dst.cullMode = info->doubleSided ? VK_CULL_MODE_NONE : VK_CULL_MODE_BACK_BIT;
dst.cullMode = VK_CULL_MODE_NONE; // this will be overwritten by the instance info at draw time
dst.frontFace = VK_FRONT_FACE_CLOCKWISE;
dst.vertexCount = src.vertices_count; assert(src.vertices_count < std::numeric_limits<uint32_t>::max());
dst.positionBuffer = dxvk::RasterBuffer { vertexSlice, offsetof(remixapi_HardcodedVertex, position), sizeof(remixapi_HardcodedVertex), VK_FORMAT_R32G32B32_SFLOAT };
Expand Down
1 change: 1 addition & 0 deletions src/dxvk/rtx_render/rtx_scene_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1432,6 +1432,7 @@ namespace dxvk {

for (const RasterGeometry& submesh : m_pReplacer->accessExternalMesh(state.mesh)) {
state.drawCall.geometryData = submesh;
state.drawCall.geometryData.cullMode = state.doubleSided ? VK_CULL_MODE_NONE : VK_CULL_MODE_BACK_BIT;

const MaterialData* material = m_pReplacer->accessExternalMaterial(submesh.externalMaterial);
if (material != nullptr) {
Expand Down
1 change: 1 addition & 0 deletions src/dxvk/rtx_render/rtx_scene_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ struct ExternalDrawState {
remixapi_MeshHandle mesh {};
CameraType::Enum cameraType {};
CategoryFlags categories {};
bool doubleSided {};
};

// Scene manager is a super manager, it's the interface between rendering and world state
Expand Down

0 comments on commit 79a970f

Please sign in to comment.