• About
    • Resume
A Game Developer also plays some guitar

Tag Archives: Id3d10effectpass

ID3D10EffectPass::Apply

June 15, 2009 5:13 pm / Benny Chen

因为没有很好的理解这个函数的作用,而导致被一个Bug纠缠了半天。

这个Bug是这样的:渲染一个人物模型和一个地板模型,它们分别有不同的纹理,但渲染出来的结果却是——人物的纹理贴到了地板上,地板的纹理贴到了人物上,纹理错位了!

我明明在渲染前都分别将各自的纹理视图(ID3D10ShaderResourceView)设置到shader的纹理接口(ID3D10EffectShaderResource)上了啊,怎么会出现如此诡异的现象。

调的很崩溃,freaking me out…对于bug源的推理,我磨了好久,才想到了去打破我的思维定势——真正启动Shader开始执行的是Draw函数,所以对于渲染状态的设置只需要在Draw函数前设置就是有效的。

前半句没错,后半句,非也!

我忽视了Apply函数的作用,它不仅仅只是挑选某个pass而已。

这是DirectX SDK Document对ID3D10EffectPass::Apply的描述:

Set the state contained in a pass to the device.

将状态提交到设备。马上我就恍然大悟,我设置纹理的语句是在Apply之后进行的。把设置纹理的语句提到Apply函数之前,于是,纹理物归原主。

调试BUG,除了需要很好的逻辑推理排错能力,还要勇于去怀疑一些思维定势(当然也没必要怀疑一切),有时,或许越是深信不疑的某些东西就是错误的根源,打破它,错误也便迎刃而解。

before bug was fixed
before bug was fixed

after bug was fixed
after bug was fixed

Posted in: Computer Graphics / Tagged: Apply, DX10, ID3D10EffectPass

LinkedIn

Milan Petrovic

Categories

  • In My Life (25)
    • A Day in the Life (8)
    • English Learning (2)
    • Learn a Word (7)
    • Something In The Way (8)
  • Music Heaven (8)
    • Guitar (1)
    • In Concert (1)
    • Lyrics (3)
  • OK Computer (54)
    • 3D (3)
    • C++ (10)
    • Computer Graphics (15)
    • Game Programming (23)
    • iOS (6)
    • Linux (1)
    • Lua (9)
    • My Projects (3)
    • Some Experiences (9)
    • Talking in Code (2)
    • Unity (2)
  • Quotations (2)
  • Uncategorized (1)
  • Visca Barça (24)
    • FCB BJ (5)

Recent Posts

  • [译]优化你的手机游戏(没有延迟的,才是健康的)- 一篇给游戏美术设计师读的文章
  • 新浪微博API for MOAI
  • 稍后继续
  • Unity Developer ++
  • Another Thread @ Moai Forum
  • 1st Day of Golden Week
  • 为SyntaxHighlighter添加新语言
  • 基于Lua的State Pattern
  • Class Diagram of Pacman
  • 基于Moai的Pacman

Recent Comments

  • 约修亚_RK on 为SyntaxHighlighter添加新语言
  • 爱装的小男孩 on 小心DLL链接静态库时的内存错误
  • happyfire on Game Loop的几种实现方式
  • William on 新浪微博API for MOAI
  • Benny Chen on 新浪微博API for MOAI
  • your man on 新浪微博API for MOAI
  • 你家男人 on 稍后继续
  • 逍遥 on 关于对std::vector的遍历
  • papa on Unity Developer ++
  • T客网 ︱ Techpot » Blog Archive » iOS开发与OpenGL ES相关问题整理(1) on iOS开发与OpenGL ES相关问题整理(1)

Tags

2d 3D 3dsmax 3ds max air Apply architecture Asia tour barca Beijing bilbao binary search blocked bob boost bruce springsteen C++ capo CGContextDrawImage Champions League Change DLL DX10 eval exporter flash framework frustum culling game game engine iniesta ios linux lua Moai opengles pacman plug-in plugin 北京 导出插件 崩溃 巴萨 游戏引擎 踢球
© Copyright 2025 - A Game Developer
Infinity Theme by DesignCoral / WordPress