MCPcopy Create free account
hub / github.com/crosire/reshade / SetRenderState

Method SetRenderState

source/d3d9/d3d9_device.cpp:1458–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1456 return _orig->GetClipPlane(Index, pPlane);
1457}
1458HRESULT STDMETHODCALLTYPE Direct3DDevice9::SetRenderState(D3DRENDERSTATETYPE State, DWORD Value)
1459{
1460 const HRESULT hr = _orig->SetRenderState(State, Value);
1461#if RESHADE_ADDON >= 2
1462 if (SUCCEEDED(hr) &&
1463 reshade::has_addon_event<reshade::addon_event::bind_pipeline_states>())
1464 {
1465 reshade::api::dynamic_state state = reshade::d3d9::convert_dynamic_state(State);
1466 uint32_t value = Value;
1467
1468 switch (State)
1469 {
1470 case D3DRS_BLENDOP:
1471 case D3DRS_BLENDOPALPHA:
1472 value = static_cast<uint32_t>(reshade::d3d9::convert_blend_op(static_cast<D3DBLENDOP>(Value)));
1473 break;
1474 case D3DRS_SRCBLEND:
1475 case D3DRS_DESTBLEND:
1476 case D3DRS_SRCBLENDALPHA:
1477 case D3DRS_DESTBLENDALPHA:
1478 value = static_cast<uint32_t>(reshade::d3d9::convert_blend_factor(static_cast<D3DBLEND>(Value)));
1479 break;
1480 case D3DRS_FILLMODE:
1481 value = static_cast<uint32_t>(reshade::d3d9::convert_fill_mode(static_cast<D3DFILLMODE>(Value)));
1482 break;
1483 case D3DRS_CULLMODE:
1484 value = static_cast<uint32_t>(reshade::d3d9::convert_cull_mode(static_cast<D3DCULL>(Value), false));
1485 break;
1486 case D3DRS_ZFUNC:
1487 case D3DRS_ALPHAFUNC:
1488 case D3DRS_STENCILFUNC:
1489 case D3DRS_CCW_STENCILFUNC:
1490 value = static_cast<uint32_t>(reshade::d3d9::convert_compare_op(static_cast<D3DCMPFUNC>(Value)));
1491 break;
1492 case D3DRS_STENCILFAIL:
1493 case D3DRS_STENCILZFAIL:
1494 case D3DRS_STENCILPASS:
1495 case D3DRS_CCW_STENCILFAIL:
1496 case D3DRS_CCW_STENCILZFAIL:
1497 case D3DRS_CCW_STENCILPASS:
1498 value = static_cast<uint32_t>(reshade::d3d9::convert_stencil_op(static_cast<D3DSTENCILOP>(Value)));
1499 break;
1500 case D3DRS_POINTSIZE:
1501 if (Value == 0x7FA05000 /* RESZ code */)
1502 {
1503 com_ptr<IDirect3DSurface9> surface;
1504 _orig->GetDepthStencilSurface(&surface);
1505 com_ptr<IDirect3DBaseTexture9> texture;
1506 _orig->GetTexture(0, &texture);
1507
1508 uint32_t src_subresource;
1509 const reshade::api::resource src_resource = get_resource_from_view(to_handle(surface.get()), &src_subresource);
1510 const reshade::api::resource dst_resource = to_handle(texture.get());
1511
1512 reshade::invoke_addon_event<reshade::addon_event::resolve_texture_region>(this, src_resource, src_subresource, nullptr, dst_resource, 0, 0, 0, 0, reshade::api::format::unknown);
1513 return hr;
1514 }
1515 if (Value == MAKEFOURCC('A', '2', 'M', '0') || Value == MAKEFOURCC('A', '2', 'M', '1'))

Callers 7

on_initMethod · 0.80
create_pipelineMethod · 0.80
end_render_passMethod · 0.80
bind_pipeline_statesMethod · 0.80
copy_texture_regionMethod · 0.80
apply_and_releaseMethod · 0.80

Calls 4

GetTextureMethod · 0.80
to_handleFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected