Skip to content

Commit 6082b5f

Browse files
committed
Add ability to disable Crossfire
The desired Crossfire mode is now passed into agsInit. In addition to the existing ability to enable the explicit Crossfire API, AGS now supports the ability to disable Crossfire. This update also includes some minor cleanup and updates to the samples.
1 parent 904b53f commit 6082b5f

19 files changed

+158
-41
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
See `ags_lib\CHANGELOG.md` for changes to the core AGS library.
44

5+
### v3.2.0 - 2016-02-12
6+
* Update ags_sample to use the library version number from the optional info parameter of `agsInit`
7+
* Update crossfire_sample to call `agsInit` prior to device creation
8+
* Update eyefinity_sample with latest DXUT
9+
510
### v3.1.1 - 2016-01-28
611
* Display library version number in ags_sample
712
* Do not display `radeonSoftwareVersion` in ags_sample while we wait for a needed driver update

ags_sample/src/AGSSample.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,17 @@ int main(int argc, char* argv[])
119119
displayIndex++;
120120
}
121121

122-
AGSGPUInfo info;
123-
124-
if ( agsInit( &agsContext, &info ) == AGS_SUCCESS )
122+
AGSGPUInfo gpuInfo;
123+
if ( agsInit( &agsContext, nullptr, &gpuInfo ) == AGS_SUCCESS )
125124
{
126-
printf( "AGS Library initialized: v%d.%d.%d\n\n", AMD_AGS_LIB_VERSION_MAJOR, AMD_AGS_LIB_VERSION_MINOR, AMD_AGS_LIB_VERSION_PATCH );
125+
printf( "AGS Library initialized: v%d.%d.%d\n\n", gpuInfo.agsVersionMajor, gpuInfo.agsVersionMinor, gpuInfo.agsVersionPatch );
127126
printf( "-----------------------------------------------------------------\n" );
128127

129-
printf( "%s, device id: 0x%04X, revision id: 0x%02X\n", info.adapterString ? info.adapterString : "unknown GPU", info.deviceId, info.revisionId );
130-
printf( "Driver version: %s\n", info.driverVersion );
128+
printf( "%s, device id: 0x%04X, revision id: 0x%02X\n", gpuInfo.adapterString ? gpuInfo.adapterString : "unknown GPU", gpuInfo.deviceId, gpuInfo.revisionId );
129+
printf( "Driver version: %s\n", gpuInfo.driverVersion );
131130
printf( "-----------------------------------------------------------------\n" );
132131

133-
printf( "Is %sGCN, %d CUs, core clock %d MHz, memory clock %d MHz, %.1f Tflops\n", info.version == AGSGPUInfo::ArchitectureVersion_GCN ? "" : "not ", info.iNumCUs, info.iCoreClock, info.iMemoryClock, info.fTFlops );
132+
printf( "Is %sGCN, %d CUs, core clock %d MHz, memory clock %d MHz, %.1f Tflops\n", gpuInfo.architectureVersion == AGSGPUInfo::ArchitectureVersion_GCN ? "" : "not ", gpuInfo.iNumCUs, gpuInfo.iCoreClock, gpuInfo.iMemoryClock, gpuInfo.fTFlops );
134133

135134
int totalGPUs = 0;
136135
if ( agsGetTotalGPUCount( agsContext, &totalGPUs ) == AGS_SUCCESS )

crossfire_sample/src/CFXAPISample.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,21 @@ void CFXAPISample::Present ()
202202
swapChain_->Present (1, 0);
203203
}
204204

205-
void CFXAPISample::InitializeAMDCFXAPI ()
205+
void CFXAPISample::InitializeAMDAGS()
206206
{
207-
agsInit (&agsContext_, nullptr);
207+
// the desired Crossfire mode needs to be passed to agsInit
208+
// prior to device creation
209+
AGSConfiguration config;
210+
config.crossfireMode = AGS_CROSSFIRE_MODE_EXPLICIT_AFR;
211+
agsInit (&agsContext_, &config, nullptr );
212+
}
208213

214+
void CFXAPISample::InitializeAMDCFXAPI ()
215+
{
209216
unsigned int supportedExtensions = 0;
210217
agsDriverExtensions_Init (agsContext_, device_.Get (), &supportedExtensions);
211218

212219
if ((supportedExtensions & AGS_EXTENSION_CROSSFIRE_API) == AGS_EXTENSION_CROSSFIRE_API) {
213-
agsDriverExtensions_SetCrossfireMode (agsContext_, AGS_CROSSFIRE_MODE_EXPLICIT_AFR);
214-
215220
cfxEnabled_ = true;
216221
} else {
217222
cfxEnabled_ = false;
@@ -223,6 +228,9 @@ void CFXAPISample::Initialize ()
223228
{
224229
window_.reset (new Window ("AMD CFX API test", 1920, 1080));
225230

231+
// Call this before device creation
232+
InitializeAMDAGS ();
233+
226234
CreateDeviceAndSwapChain ();
227235

228236
InitializeAMDCFXAPI ();
@@ -286,12 +294,13 @@ void CFXAPISample::Initialize ()
286294
void CFXAPISample::Shutdown ()
287295
{
288296
agsDriverExtensions_DeInit (agsContext_);
289-
agsDeInit (agsContext_);
290297

291298
// Clear things out to avoid false-positive D3D debug runtime ref-count warnings.
292299
swapChain_->SetFullscreenState (FALSE, 0);
293300
deviceContext_->ClearState ();
294301
deviceContext_->Flush ();
302+
303+
agsDeInit (agsContext_);
295304
}
296305

297306
///////////////////////////////////////////////////////////////////////////////

crossfire_sample/src/CFXAPISample.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
// THE SOFTWARE.
2121
//
22-
#ifndef AMD_AGS_SDK_CFX_API_SAMPLE_MAIN_H_
23-
#define AMD_AGS_SDK_CFX_API_SAMPLE_MAIN_H_
22+
#ifndef AMD_AGS_CFX_API_SAMPLE_MAIN_H
23+
#define AMD_AGS_CFX_API_SAMPLE_MAIN_H
2424

2525
#include <d3d11.h>
2626
#include <wrl.h>
@@ -74,6 +74,7 @@ class CFXAPISample
7474
void Present ();
7575
void CreateDeviceAndSwapChain ();
7676
void CreateMeshBuffers ();
77+
void InitializeAMDAGS ();
7778
void InitializeAMDCFXAPI ();
7879

7980
std::unique_ptr<Window> window_;

crossfire_sample/src/Window.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
// THE SOFTWARE.
2121
//
22-
#ifndef AMD_AGS_SDK_CFX_API_SAMPLE_WINDOW_H_
23-
#define AMD_AGS_SDK_CFX_API_SAMPLE_WINDOW_H_
22+
#ifndef AMD_AGS_CFX_API_SAMPLE_WINDOW_H
23+
#define AMD_AGS_CFX_API_SAMPLE_WINDOW_H
2424

2525
#include <string>
2626
#include <Windows.h>

eyefinity_sample/dxut/Core/DDSTextureLoader.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct DDS_PIXELFORMAT
6565
#define DDS_RGB 0x00000040 // DDPF_RGB
6666
#define DDS_LUMINANCE 0x00020000 // DDPF_LUMINANCE
6767
#define DDS_ALPHA 0x00000002 // DDPF_ALPHA
68+
#define DDS_BUMPDUDV 0x00080000 // DDPF_BUMPDUDV
6869

6970
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
7071

@@ -579,7 +580,7 @@ static DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf )
579580
// No DXGI format maps to ISBITMASK(0x000000ff,0x0000ff00,0x00ff0000,0x00000000) aka D3DFMT_X8B8G8R8
580581

581582
// Note that many common DDS reader/writers (including D3DX) swap the
582-
// the RED/BLUE masks for 10:10:10:2 formats. We assumme
583+
// the RED/BLUE masks for 10:10:10:2 formats. We assume
583584
// below that the 'backwards' header mask is being used since it is most
584585
// likely written by D3DX. The more robust solution is to use the 'DX10'
585586
// header extension and specify the DXGI_FORMAT_R10G10B10A2_UNORM format directly
@@ -662,6 +663,32 @@ static DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf )
662663
return DXGI_FORMAT_A8_UNORM;
663664
}
664665
}
666+
else if (ddpf.flags & DDS_BUMPDUDV)
667+
{
668+
if (16 == ddpf.RGBBitCount)
669+
{
670+
if (ISBITMASK(0x00ff, 0xff00, 0x0000, 0x0000))
671+
{
672+
return DXGI_FORMAT_R8G8_SNORM; // D3DX10/11 writes this out as DX10 extension
673+
}
674+
}
675+
676+
if (32 == ddpf.RGBBitCount)
677+
{
678+
if (ISBITMASK(0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000))
679+
{
680+
return DXGI_FORMAT_R8G8B8A8_SNORM; // D3DX10/11 writes this out as DX10 extension
681+
}
682+
if (ISBITMASK(0x0000ffff, 0xffff0000, 0x00000000, 0x00000000))
683+
{
684+
return DXGI_FORMAT_R16G16_SNORM; // D3DX10/11 writes this out as DX10 extension
685+
}
686+
687+
// No DXGI format maps to ISBITMASK(0x3ff00000, 0x000ffc00, 0x000003ff, 0xc0000000) aka D3DFMT_A2W10V10U10
688+
}
689+
}
690+
691+
665692
else if (ddpf.flags & DDS_FOURCC)
666693
{
667694
if (MAKEFOURCC( 'D', 'X', 'T', '1' ) == ddpf.fourCC)
@@ -677,7 +704,7 @@ static DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf )
677704
return DXGI_FORMAT_BC3_UNORM;
678705
}
679706

680-
// While pre-mulitplied alpha isn't directly supported by the DXGI formats,
707+
// While pre-multiplied alpha isn't directly supported by the DXGI formats,
681708
// they are basically the same as these BC formats so they can be mapped
682709
if (MAKEFOURCC( 'D', 'X', 'T', '2' ) == ddpf.fourCC)
683710
{
@@ -1048,6 +1075,11 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice,
10481075
SRVDesc.Texture2D.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
10491076
}
10501077

1078+
if (SRVDesc.Format == DXGI_FORMAT_R32_TYPELESS)
1079+
{
1080+
SRVDesc.Format = DXGI_FORMAT_R32_FLOAT;
1081+
}
1082+
10511083
hr = d3dDevice->CreateShaderResourceView( tex,
10521084
&SRVDesc,
10531085
textureView

eyefinity_sample/dxut/Core/DDSTextureLoader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#pragma once
2323
#endif
2424

25-
#include <d3d11_1.h>
25+
#include <d3d11.h>
2626

2727
#pragma warning(push)
2828
#pragma warning(disable : 4005)

eyefinity_sample/dxut/Core/DXUT.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ class DXUTState
9393
ID3D11RenderTargetView* m_D3D11RenderTargetView; // the D3D11 render target view
9494
ID3D11RasterizerState* m_D3D11RasterizerState; // the D3D11 Rasterizer state
9595

96+
#ifdef USE_DIRECT3D11_1
9697
// D3D11.1 specific
9798
ID3D11Device1* m_D3D11Device1; // the D3D11.1 rendering device
9899
ID3D11DeviceContext1* m_D3D11DeviceContext1; // the D3D11.1 immediate device context
100+
#endif
99101

100102
#ifdef USE_DIRECT3D11_2
101103
// D3D11.2 specific
@@ -310,8 +312,10 @@ class DXUTState
310312
GET_SET_ACCESSOR( ID3D11RenderTargetView*, D3D11RenderTargetView );
311313
GET_SET_ACCESSOR( ID3D11RasterizerState*, D3D11RasterizerState );
312314

315+
#ifdef USE_DIRECT3D11_1
313316
GET_SET_ACCESSOR( ID3D11Device1*, D3D11Device1 );
314317
GET_SET_ACCESSOR( ID3D11DeviceContext1*, D3D11DeviceContext1 );
318+
#endif
315319

316320
#ifdef USE_DIRECT3D11_2
317321
GET_SET_ACCESSOR(ID3D11Device2*, D3D11Device2);
@@ -607,8 +611,11 @@ IDXGIFactory1* WINAPI DXUTGetDXGIFactory() { DXUTDelayLoadDXGI()
607611

608612
ID3D11Device* WINAPI DXUTGetD3D11Device() { return GetDXUTState().GetD3D11Device(); }
609613
ID3D11DeviceContext* WINAPI DXUTGetD3D11DeviceContext() { return GetDXUTState().GetD3D11DeviceContext(); }
614+
615+
#ifdef USE_DIRECT3D11_1
610616
ID3D11Device1* WINAPI DXUTGetD3D11Device1() { return GetDXUTState().GetD3D11Device1(); }
611617
ID3D11DeviceContext1* WINAPI DXUTGetD3D11DeviceContext1() { return GetDXUTState().GetD3D11DeviceContext1(); }
618+
#endif
612619

613620
#ifdef USE_DIRECT3D11_2
614621
ID3D11Device2* WINAPI DXUTGetD3D11Device2() { return GetDXUTState().GetD3D11Device2(); }
@@ -752,9 +759,13 @@ void DXUTParseCommandLine(WCHAR* strCommandLine,
752759
}
753760
else
754761
#endif
762+
#ifdef USE_DIRECT3D11_1
755763
if (_wcsnicmp( strFlag, L"D3D_FEATURE_LEVEL_11_1", MAX_PATH) == 0 ) {
756764
GetDXUTState().SetOverrideForceFeatureLevel(D3D_FEATURE_LEVEL_11_1);
757-
}else if (_wcsnicmp( strFlag, L"D3D_FEATURE_LEVEL_11_0", MAX_PATH) == 0 ) {
765+
}
766+
else
767+
#endif
768+
if (_wcsnicmp( strFlag, L"D3D_FEATURE_LEVEL_11_0", MAX_PATH) == 0 ) {
758769
GetDXUTState().SetOverrideForceFeatureLevel(D3D_FEATURE_LEVEL_11_0);
759770
}else if (_wcsnicmp( strFlag, L"D3D_FEATURE_LEVEL_10_1", MAX_PATH) == 0 ) {
760771
GetDXUTState().SetOverrideForceFeatureLevel(D3D_FEATURE_LEVEL_10_1);
@@ -2572,6 +2583,7 @@ HRESULT DXUTCreate3DEnvironment11()
25722583
assert( pd3dImmediateContext );
25732584
_Analysis_assume_( pd3dImmediateContext );
25742585

2586+
#ifdef USE_DIRECT3D11_1
25752587
// Direct3D 11.1
25762588
{
25772589
ID3D11Device1* pd3d11Device1 = nullptr;
@@ -2588,6 +2600,7 @@ HRESULT DXUTCreate3DEnvironment11()
25882600
}
25892601
}
25902602
}
2603+
#endif
25912604

25922605
#ifdef USE_DIRECT3D11_2
25932606
// Direct3D 11.2
@@ -3046,10 +3059,12 @@ void DXUTCleanup3DEnvironment( _In_ bool bReleaseSettings )
30463059
assert( pImmediateContext );
30473060
pImmediateContext->ClearState();
30483061
pImmediateContext->Flush();
3062+
#ifdef USE_DIRECT3D11_1
30493063
auto pImmediateContext1 = DXUTGetD3D11DeviceContext1();
3050-
assert( pImmediateContext1 );
3064+
assert(pImmediateContext1);
30513065
pImmediateContext1->ClearState();
30523066
pImmediateContext1->Flush();
3067+
#endif
30533068
#ifdef USE_DIRECT3D11_2
30543069
auto pImmediateContext2 = DXUTGetD3D11DeviceContext2();
30553070
assert(pImmediateContext2);
@@ -3067,8 +3082,10 @@ void DXUTCleanup3DEnvironment( _In_ bool bReleaseSettings )
30673082
SAFE_RELEASE( pImmediateContext );
30683083
GetDXUTState().SetD3D11DeviceContext( nullptr );
30693084

3085+
#ifdef USE_DIRECT3D11_1
30703086
SAFE_RELEASE( pImmediateContext1 );
30713087
GetDXUTState().SetD3D11DeviceContext1( nullptr );
3088+
#endif
30723089

30733090
#ifdef USE_DIRECT3D11_2
30743091
SAFE_RELEASE(pImmediateContext2);
@@ -3083,9 +3100,11 @@ void DXUTCleanup3DEnvironment( _In_ bool bReleaseSettings )
30833100
// Report live objects
30843101
if ( pd3dDevice )
30853102
{
3103+
#ifdef USE_DIRECT3D11_1
30863104
auto pd3dDevice1 = DXUTGetD3D11Device1();
30873105
SAFE_RELEASE( pd3dDevice1 );
30883106
GetDXUTState().SetD3D11Device1(nullptr);
3107+
#endif
30893108

30903109
#ifdef USE_DIRECT3D11_2
30913110
auto pd3dDevice2 = DXUTGetD3D11Device2();
@@ -4201,9 +4220,11 @@ void DXUTUpdateD3D11DeviceStats( D3D_DRIVER_TYPE DeviceType, D3D_FEATURE_LEVEL f
42014220
case D3D_FEATURE_LEVEL_11_0:
42024221
wcscat_s( pstrDeviceStats, 256, L" (FL 11.0)" );
42034222
break;
4223+
#ifdef USE_DIRECT3D11_1
42044224
case D3D_FEATURE_LEVEL_11_1:
42054225
wcscat_s( pstrDeviceStats, 256, L" (FL 11.1)" );
42064226
break;
4227+
#endif
42074228
#ifdef USE_DIRECT3D11_3
42084229
case D3D_FEATURE_LEVEL_12_0:
42094230
wcscat_s(pstrDeviceStats, 256, L" (FL 12.0)");

eyefinity_sample/dxut/Core/DXUT.h

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,37 @@
2020
#define STRICT
2121
#endif
2222

23-
// If app hasn't choosen, set to work with Windows Vista and beyond
23+
// If app hasn't choosen, set to work with Windows 7 and beyond
2424
#ifndef WINVER
25-
#define WINVER 0x0600
25+
#define WINVER 0x0601
2626
#endif
2727
#ifndef _WIN32_WINDOWS
28-
#define _WIN32_WINDOWS 0x0600
28+
#define _WIN32_WINDOWS 0x0601
2929
#endif
3030
#ifndef _WIN32_WINNT
31-
#define _WIN32_WINNT 0x0600
31+
#define _WIN32_WINNT 0x0601
3232
#endif
3333

3434
#if (_WIN32_WINNT >= 0x0A00) && !defined(USE_DIRECT3D11_3)
35-
#define DIRECT3D11_3
35+
#define USE_DIRECT3D11_3
3636
#endif
3737

3838
#if (_WIN32_WINNT >= 0x0603) && !defined(USE_DIRECT3D11_2)
39-
#define DIRECT3D11_2
39+
#define USE_DIRECT3D11_2
4040
#endif
4141

4242
#if defined(USE_DIRECT3D11_3) && !defined(USE_DIRECT3D11_2)
4343
#define USE_DIRECT3D11_2
4444
#endif
4545

46+
#if (_WIN32_WINNT >= 0x0602) && !defined(USE_DIRECT3D11_1)
47+
#define USE_DIRECT3D11_1
48+
#endif
49+
50+
#if defined(USE_DIRECT3D11_2) && !defined(USE_DIRECT3D11_1)
51+
#define USE_DIRECT3D11_1
52+
#endif
53+
4654
// #define DXUT_AUTOLIB to automatically include the libs needed for DXUT
4755
#ifdef DXUT_AUTOLIB
4856
#pragma comment( lib, "comctl32.lib" )
@@ -78,9 +86,13 @@
7886
// Direct3D11 includes
7987
#include <d3dcommon.h>
8088
#include <dxgi.h>
81-
#include <d3d11_1.h>
89+
#include <d3d11.h>
8290
#include <d3dcompiler.h>
8391

92+
#ifdef USE_DIRECT3D11_1
93+
#include <d3d11_1.h>
94+
#endif
95+
8496
#ifdef USE_DIRECT3D11_2
8597
#include <d3d11_2.h>
8698
#endif
@@ -142,7 +154,7 @@
142154
((DWORD)((((a)&0xff)<<24)|(((r)&0xff)<<16)|(((g)&0xff)<<8)|((b)&0xff)))
143155
#endif
144156

145-
#define DXUT_VERSION 1110
157+
#define DXUT_VERSION 1111
146158

147159
//--------------------------------------------------------------------------------------
148160
// Structs
@@ -291,8 +303,10 @@ ID3D11DepthStencilView* WINAPI DXUTGetD3D11DepthStencilView();
291303
ID3D11Device* WINAPI DXUTGetD3D11Device();
292304
ID3D11DeviceContext* WINAPI DXUTGetD3D11DeviceContext();
293305

306+
#ifdef USE_DIRECT3D11_1
294307
ID3D11Device1* WINAPI DXUTGetD3D11Device1();
295308
ID3D11DeviceContext1* WINAPI DXUTGetD3D11DeviceContext1();
309+
#endif
296310

297311
#ifdef USE_DIRECT3D11_2
298312
ID3D11Device2* WINAPI DXUTGetD3D11Device2();

0 commit comments

Comments
 (0)