D3D疑问记录

1.Supersampling 和 Multisampling之间有什么差别?

在龙书《Introduction to 3D Game Programming with Directx 11》的4.1.7小节有这么一段话:

Observe the key difference between supersampling and multisampling. With supersampling, the image color is computed per subpixel, and so each subpixel could potentially be a different color. With multisampling ( Figure 4.5), the image color is computed once per pixel and that color is replicated into all visible subpixels that are covered by the polygon. Because computing the image color is one of the most expensive steps in the graphics pipeline, the savings from multisampling over supersampling is significant. On the other hand, supersampling is technically more accurate and handles texture and shader aliasing, which multisampling does not.

Multisampling
段落中提到的图也附在上面。看起来Supersampling很容易理解,但相对的Multisampling到底如何产生抗锯齿的作用,却显得让人费解了。
结合其他资料,反复读了很久这段话才明白,所谓的With multisampling, the image color is computed once per pixel and that color is replicated into all visible subpixels 与不采用Multisampling时的区别:无论采用Multisampling还是不采用任何抗锯齿技术,每个pixel只计算一次颜色值。但是Multisampling下,这个计算出来的颜色值被赋值到subpixel中被多边形覆盖的部分(也就是需要着色的部分),未覆盖区域保留原来的值(可能是背景色或上次着色的值)。
这也是为什么在一个论坛上看到这样的描述(其中it指Multisampling),说Multisampling只在画edge时有用:

OTOH, it doesn’t do anything to solve aliasing within the interior of the primitive. It only antialiases at edges; either the actual edges of primitives or when fragments are clipped by depth or stencil tests. Note that it doesn’t antialias “edges” resulting from the alpha channel.


2.texture数据类型中,颜色类型的alpha通道是干什么用的?

我们在设置texture类型时,发现DXGI_FORMAT枚举的数据中有类似以下这样的:

DXGI_FORMAT_R8G8B8A8_UNORM;  // Each element has four 8-bit unsigned components mapped to the [0, 1] range.
DXGI_FORMAT_R8G8B8A8_SNORM;  // Each element has four 8-bit signed components mapped to the [−1, 1] range.
DXGI_FORMAT_R8G8B8A8_SINT;  // Each element has four 8-bit signed integer components mapped to the [−128, 127] range.
DXGI_FORMAT_R8G8B8A8_UINT;  // Each element has four 8-bit unsigned integer components mapped to the [0, 255] range.

类型中的RGB很容易理解,但A是什么?

《Introduction to 3D Game Programming with Directx 11》中4.1.3小节回答了这个问题:

The alpha channel or alpha component is generally used to control transparency.


3.IDXGIFactory以及IDXGIFactory1,2,3…分别是什么关系?

在通过device获取对应的IDXGIFactory时,MSDN的官方示例里采用了这样的写法:

IDXGIFactory1* dxgiFactory = nullptr;
    {
        IDXGIDevice* dxgiDevice = nullptr;
        hr = g_pd3dDevice->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void**>(&dxgiDevice));
        if (SUCCEEDED(hr))  {
            IDXGIAdapter* adapter = nullptr;
            hr = dxgiDevice->GetAdapter(&adapter);
            if (SUCCEEDED(hr))  {
                hr = adapter->GetParent(__uuidof(IDXGIFactory1), reinterpret_cast<void**>(&dxgiFactory));
                adapter->Release();
            }
            dxgiDevice->Release();
        }
    }
    if (FAILED(hr))
        return hr;

    IDXGIFactory2* dxgiFactory2 = nullptr;
    hr = dxgiFactory->QueryInterface(__uuidof(IDXGIFactory2), reinterpret_cast<void**>(&dxgiFactory2));
    if (dxgiFactory2)
        // 说明是DirectX 11.1 or later,后续略

在龙书中的代码只实现了前半段(除去倒数四行),并且第一行和第九行中不是IDXGIFactory1而是IDXGIFactory。原因是:

26076: 10-30 14:23:46.906403 3177 4886 E TestFixed: handleTopActivityLaunchingInDifferentOrientation-11, checkOpening = true, r = ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64}, orientationSrc = ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64}, activityOrientation = 1, !rInTransition = true, config.orientation = 1, call by=com.android.server.wm.DisplayContent.updateOrientation:2037 com.android.server.wm.DisplayContent.updateOrientation:1955 com.android.server.wm.WindowManagerService.relayoutWindow:2944 com.android.server.wm.Session.relayout:317 com.android.server.wm.Session.relayoutAsync:336 android.view.IWindowSession$Stub.onTransact:755 com.android.server.wm.Session.onTransact:227 android.os.Binder.execTransactInternal:1444 android.os.Binder.execTransact:1378 <bottom of call stack> <bottom of call stack> <bottom of call stack> 行 26211: 10-30 14:23:46.985705 3177 4886 D OplusStartingWindowManager: updateRecordSurfaceViewState windowToken = android.os.BinderProxy@a23b17c, surfaceState = true, attachedToWindow = true, inList = false, win = Window{32e8a05 u0 sg.bigo.live/sg.bigo.live.home.MainActivity} 行 26348: 10-30 14:23:47.027071 2010 7490 I AF::PthrPatchRecord: creating track with enforcement level 0 行 26476: 10-30 14:23:47.072056 3177 3616 D QosSceneRecognizer: updateAssProcRecord add: true, isProvider: true, cmpAssParams: CmpAssParams{mCallingUid=10370, mCallingPid=20328, mCalledUid=10370, mCalledPid=20217, mCalledPkgName=sg.bigo.live, mCalledProcessName=sg.bigo.live, mCmpName=ae58186/sg.bigo.live/sg.bigo.sdk.push.database.content.PushMessageProvider} 行 26760: 10-30 14:23:47.124341 1783 19173 I AGM: oplus_agm_fb: recordOpenedSessions: 69 i = 0, record open session_id = 126 行 26974: 10-30 14:23:47.161219 3177 5764 I OGuardManager_WeakAwareManager: stop uid:10370 type:MediaMute valid:false duration:0 recorder:false sysMute:false 行 26992: 10-30 14:23:47.168085 3177 3616 D QosSceneRecognizer: updateAssProcRecord add: true, isProvider: false, cmpAssParams: CmpAssParams{mCallingUid=10137, mCallingPid=6671, mCalledUid=10132, mCalledPid=5131, mCalledPkgName=com.google.android.gms, mCalledProcessName=com.google.android.gms.persistent, mCmpName=com.google.android.gms/.chimera.PersistentApiService} 行 28098: 10-30 14:23:47.846061 20217 20217 W InputLog: VRI[MainActivity] : debugInputEventFinished event:MotionEvent { action=ACTION_DOWN, actionButton=0, id[0]=0, x[0]=673.5, y[0]=2715.875, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=2247138, downTime=2247138, deviceId=5, source=0x1002, displayId=0, eventId=816082425 }, sEvent=DebugEvent [ type=2, action=0, downTime=2247138, eventTime=2247138, stateRecord=[2025-10-30 14:23:47.827|START_EVENT, 2025-10-30 14:23:47.828|ENQUEUE_EVENT|true|false, 2025-10-30 14:23:47.830|EarlyPostImeInputStage|0x0, 2025-10-30 14:23:47.830|NativePostImeInputStage|0x0, 2025-10-30 14:23:47.845|ViewPostImeInputStage|0xc, 2025-10-30 14:23:47.845|SyntheticInputStage|0xc, 2025-10-30 14:23:47.845|FINISH_EVENT|0xc], handleDetail=|Touch handled by view onTouchEvent in androidx.appcompat.widget.AppCompatImageButton|Handle Touch in viewtree|mView handled=true ] 行 28102: 10-30 14:23:47.847783 20217 20217 W InputLog: VRI[MainActivity] : debugInputEventFinished event:MotionEvent { action=ACTION_MOVE, actionButton=0, id[0]=0, x[0]=673.5, y[0]=2715.875, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=2, eventTime=2247150, downTime=2247138, deviceId=5, source=0x1002, displayId=0, eventId=628715831 }, sEvent=DebugEvent [ type=2, action=2, downTime=2247138, eventTime=2247150, stateRecord=[2025-10-30 14:23:47.846|START_EVENT, 2025-10-30 14:23:47.846|ENQUEUE_EVENT|true|false, 2025-10-30 14:23:47.846|EarlyPostImeInputStage|0x0, 2025-10-30 14:23:47.847|NativePostImeInputStage|0x0, 2025-10-30 14:23:47.847|ViewPostImeInputStage|0xc, 2025-10-30 14:23:47.847|SyntheticInputStage|0xc, 2025-10-30 14:23:47.847|FINISH_EVENT|0xc], handleDetail=|Touch handled by view onTouchEvent in androidx.appcompat.widget.AppCompatImageButton|Handle Touch in viewtree|mView handled=true ] 行 28228: 10-30 14:23:47.914312 20217 20217 W InputLog: VRI[MainActivity] : debugInputEventFinished event:MotionEvent { action=ACTION_UP, actionButton=0, id[0]=0, x[0]=673.5, y[0]=2715.875, toolType[0]=TOOL_TYPE_FINGER, buttonState=0, classification=NONE, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=0, eventTime=2247227, downTime=2247138, deviceId=5, source=0x1002, displayId=0, eventId=742771632 }, sEvent=DebugEvent [ type=2, action=1, downTime=2247138, eventTime=2247227, stateRecord=[2025-10-30 14:23:47.911|START_EVENT, 2025-10-30 14:23:47.912|ENQUEUE_EVENT|true|false, 2025-10-30 14:23:47.912|EarlyPostImeInputStage|0x0, 2025-10-30 14:23:47.912|NativePostImeInputStage|0x0, 2025-10-30 14:23:47.914|ViewPostImeInputStage|0xc, 2025-10-30 14:23:47.914|SyntheticInputStage|0xc, 2025-10-30 14:23:47.914|FINISH_EVENT|0xc], handleDetail=|Touch handled by view onTouchEvent in androidx.appcompat.widget.AppCompatImageButton|Handle Touch in viewtree|mView handled=true ] 行 28264: 10-30 14:23:47.923760 3177 3616 D QosSceneRecognizer: updateAssProcRecord add: false, isProvider: true, cmpAssParams: CmpAssParams{mCallingUid=1000, mCallingPid=4217, mCalledUid=10139, mCalledPid=4455, mCalledPkgName=com.oplus.statistics.rom, mCalledProcessName=com.oplus.statistics.rom, mCmpName=76d1566/com.oplus.statistics.rom/.service.DcsContentProvider} 行 28299: 10-30 14:23:47.941783 3177 4936 D OplusStartingWindowManager: updateRecordSurfaceViewState windowToken = android.os.BinderProxy@a23b17c, surfaceState = false, attachedToWindow = true, inList = false, win = Window{32e8a05 u0 sg.bigo.live/sg.bigo.live.home.MainActivity} 行 28396: 10-30 14:23:47.999427 3177 4478 D OplusAccessControlManagerService: checkStartActivityForAppLock: start intent=Intent { xflg=0x4 cmp=sg.bigo.live/.LiveVideoOwnerActivity (has extras) mCallingUid=10370 } requestCode=0 sourceRecord=ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} aInfo.applicationInfo.uid=10370 realCallingUid=10370 isSkip=false encryptEnable=false isPreLoad=false isKeyguardLock=false isEncrypt=false inTask=null isMinimizedPocketStudio=false isInSplitBlackList=false isRelatedActivity=false isBackToChatStart=false 行 28397: 10-30 14:23:47.999812 3177 4478 V WindowManager: State movement: ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity from:null to:INITIALIZING reason:ActivityRecord ctor 行 28398: 10-30 14:23:47.999953 3177 4478 V WindowManager: setClientVisible: ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t-1} clientVisible=true Callers=com.android.server.wm.ActivityRecord.<init>:2206 com.android.server.wm.ActivityRecord.<init>:0 com.android.server.wm.ActivityRecord$Builder.build:12023 com.android.server.wm.ActivityStarter.executeRequest:1788 com.android.server.wm.ActivityStarter.execute:1004 com.android.server.wm.ActivityTaskManagerService.startActivityAsUser:1478 com.android.server.wm.ActivityTaskManagerService.startActivityAsUser:1417 com.android.server.wm.ActivityTaskManagerService.startActivity:1385 android.app.IActivityTaskManager$Stub.onTransact:971 com.android.server.wm.ActivityTaskManagerService.onTransact:6485 行 28399: 10-30 14:23:47.999967 3177 4478 D WindowManager: NFW_setClientVisible:ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t-1} clientVisible:true 行 28435: 10-30 14:23:48.009861 3177 4478 D OplusZoomTaskCloneController: cloneTaskForZoomWindowIfNeeded:ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t-1} targetTask:null 行 28436: 10-30 14:23:48.009918 3177 4478 D OplusZoomTaskCloneController: needInterfereStartResult ? launch mode:0 sourceRecord:ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} realCallingUid:10370 launcherUid:10260 callingPackage:sg.bigo.live 行 28438: 10-30 14:23:48.010030 3177 4478 D ActivityStarterExtImpl: setForceUpdateWindow, targetTask = Task{d3a521c #64 type=standard A=10370:sg.bigo.live} r = ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t-1} notFinish =false 行 28445: 10-30 14:23:48.011491 3177 4478 D FlexibleWindowManagerService: no reused task found for ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t-1} 行 28450: 10-30 14:23:48.012352 3177 4478 D OplusFlexibleActivityController: parseFlexibleActivityInfo: sourceRecord{flexibleActivityInfo=null} record{ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t-1}} 行 28454: 10-30 14:23:48.013759 2069 2289 D OplusLayer: Layer() sequence=2418, name=ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t64}#2418 行 28489: 10-30 14:23:48.015344 3177 4478 I WindowManager: Adding activity ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t64} to task Task{d3a521c #64 type=standard A=10370:sg.bigo.live} callers: java.lang.RuntimeException: here 行 28490: 10-30 14:23:48.015382 3177 4478 D OplusStartingWindowManager: reviseWindowFlagsForStarting ar =:ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t64}, activityCreated =:false, RUS version:20250825 行 28495: 10-30 14:23:48.015706 3177 4478 D ActivityTaskManager: addStartingWindow for ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t64}, mainWin=null, state=INITIALIZING, isKeyguardLocked=false, isKeyguardGoingAway=false 行 28498: 10-30 14:23:48.015774 3177 4478 D ActivityRecordExtImpl: handleStartingWindowForCompactWindow origin type:0, adjustType : 0 行 28501: 10-30 14:23:48.015924 3177 4478 E AppQuickStartController: attachExStartingSurface not support issue ar:ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t64} ar.task:Task{d3a521c #64 type=standard A=10370:sg.bigo.live} reason: 8448 type:2, mStartFromLauncherBeforeAnimGo: false 行 28502: 10-30 14:23:48.016009 3177 4478 D TaskFragmentExtImpl: shouldDeferResumeUntilRecentsAnimFinished prev=ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t64}, next=ActivityRecord{110035859 u0 sg.bigo.live/.LiveVideoOwnerActivity t64}, task=Task{d3a521c #64 type=standard A=10370:sg.bigo.live} 行 28507: 10-30 14:23:48.016895 3177 4478 D OplusWindowAnimationManager: applyNoAnimationForResumed resumed: ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} 行 28509: 10-30 14:23:48.017421 3177 4478 D WindowManager: resumeTopActivity: Pausing ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} 行 28510: 10-30 14:23:48.017434 3177 4478 D WindowManager: startPausing: taskFrag=Task{d3a521c #64 type=standard A=10370:sg.bigo.live} mResumedActivity=ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} 行 28514: 10-30 14:23:48.017487 3177 4478 V WindowManager: Moving to PAUSING: ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} 行 28515: 10-30 14:23:48.017511 3177 4478 V WindowManager: State movement: ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} from:RESUMED to:PAUSING reason:startPausingLocked 行 28516: 10-30 14:23:48.017540 3177 4478 V WindowManager: Sending position change to ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64}, onTop: false 行 28517: 10-30 14:23:48.017576 3177 4478 V WindowManager: Waiting for top state to be released by ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} 行 28518: 10-30 14:23:48.017652 3177 4478 V WindowManager: Enqueueing pending pause: ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} 行 28623: 10-30 14:23:48.057030 3177 3616 D QosSceneRecognizer: updateAssProcRecord add: false, isProvider: true, cmpAssParams: CmpAssParams{mCallingUid=10260, mCallingPid=4504, mCalledUid=1000, mCalledPid=15685, mCalledPkgName=com.oplus.notificationmanager, mCalledProcessName=com.oplus.notificationmanager, mCmpName=b3d7287/com.oplus.notificationmanager/.badge.NotificationContentProvider} 行 28625: 10-30 14:23:48.059356 3177 4998 D ActivityTaskManager: activityPaused, token=Token{481ae25 ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64}}, timeout=false, callers=com.android.server.wm.ActivityClientController.activityPaused:269 android.app.IActivityClientController$Stub.onTransact:695 com.android.server.wm.ActivityClientController.onTransact:184 android.os.Binder.execTransactInternal:1439 android.os.Binder.execTransact:1378 行 28626: 10-30 14:23:48.059564 3177 4998 V WindowManager: Moving to PAUSED: ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} (pause complete) 行 28627: 10-30 14:23:48.059701 3177 4998 D TaskFragmentExtImpl: shouldDeferResumeUntilRecentsAnimFinished prev=ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64}, next=null, task=Task{d3a521c #64 type=standard A=10370:sg.bigo.live} 行 28630: 10-30 14:23:48.059860 3177 4998 V WindowManager: Complete pause: ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} 行 28631: 10-30 14:23:48.059884 3177 4998 V WindowManager: State movement: ActivityRecord{254776812 u0 sg.bigo.live/.home.MainActivity t64} from:PAUSING to:PAUSED reason:completePausedLocked
最新发布
11-05
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值