Tuesday, 6 June 2017

Gotchas When Porting C++ and OpenGL Applications to the Dreamcast

Over the past month or so I've been steadily working on porting my game engine Simulant to the Dreamcast. While it's not quite ready for prime-time, I did discover a lot of road-bumps along the way, and I thought I should write some of them down so that anyone else porting to the Dreamcast will at least have some results on Google to look at!

Compile the Dreamcast SDK with GCC 4.x

It didn't take very long to compile my code, but when it came to linking all kinds of trouble awaited me. Whenever I tried to link, most of the C++ symbols (things like string and vector) were missing. After several days trying different linker flags I decided the problem must be with the SDK itself. A quick `nm` of libstdc++.a showed up the problem; only a handful of symbols were in there!

I've been using a Docker container to compile my code, which is fortunate because it allowed me to gradually roll back the Fedora version until I hit one that correctly compiled libstdc++. Fedora 21 is where it worked!

The moral of the story is that for some reason, GCC 5.x and above will not correctly compile libstdc++.a from GCC 4.x - so if you're compiling the SDK for C++ code, you're going to need to use an old GCC version.

Don't rely on std::atomic or std::async

The SH4 CPU only has a single limited atomic instruction which rules out support for std::atomic. That by itself wouldn't be so bad, but it turns out that even though the standard defines that std::async can be implemented without atomics, GCC hasn't done that.

In most cases it's trivial enough to build what you need using std::mutex and std::thread - but it is a bit of a hassle.

std::chrono::high_resolution_clock ... er... isn't

This had me confused for a while. I had a sample GL application running; a spinning cube, and it would run at a consistent 1FPS. I know the DC is slow compared to modern machines, but, 1FPS for a cube?!

Turns out that the "high resolution" timer had an accuracy of 1 second! Using the built-in KallistiOS timer functions fixed it.

libGL is still a WIP

The GL port for the DC is a great little library, but it has some rough edges. I recommend that you get your application runnable on both your PC and the DC and focus on targetting GL 1.1. If the graphics in your application don't work on the Dreamcast but do on the PC then investigate and submit a patch!

33 comments:

  1. Although I don't fully understand this post, I'm sure some of my computer science friends will love your blog. Will share with them.

    ReplyDelete
  2. CrownQQ | Domino agent QQ | BandarQ | Domino99 Online Largest

    Who Is The Agent Bandarq, Domino 99, And The Trusted Online Poker City in Asia comes to all of you with exciting game games and exciting bonuses for all of you

    Bonus on CrownQQ:
    * Bonus rolling 0.5%, every week
    * Refferal Bonus 10% + 10%, lifetime
    * Bonus Jackpot, which you can get easily

    Featured Games CrownQQ:
    * Online Poker
    * BandarQ
    * Domino99
    * Bandar Sakong
    * Sakong
    * Bandar66
    * AduQ
    * Sakong

    More Info Visit:
    Website: AGEN BANDARQ CrownQQ
    BBM: 2B382398
    FB: AgentCrownqq
    Twitter: crown_qq

    ReplyDelete


  3. Mau menang banyak dengan modal sedikit..
    Ayo gabung di Agen Domino NAGAQQ.
    =>Bonus Refferal 20%
    =>Bonus Turn Over 0,5%
    =>Min Deposit Rp 15.000
    =>1 User ID 4 Games
    Situs yang bisa memberikan kemenangan AGEN BANDARQ TERBAIK
    Raih kemenangan anda segera...
    WHATSAPP : +855967014811
    PIN BB : 2B209F68

    ReplyDelete
  4. this blog was really great, never seen a great blog like this before. i think im gonna share this to my friends.. tik tok video

    ReplyDelete
  5. JACKPOT MENANTI ANDA BOSQUEE ^^

    Mari bergabung bersama KARTUVIPQQ Agen Poker Online Terpercaya dan Terbesar di Indonesia.

    Jangan menunda kesempatan untuk jadi jutawan, join sekarang juga !!!

    Jangan mengaku jago main poker & domino kalau belum bermain di KARTUVIPQQQ

    Kami hadir dengan 8 macam permainan dalam 1 ID :
    - Bandar Poker
    - Poker
    - BandarQ
    - Bandar66
    - Domino99
    - Bandar66
    - Sakong
    - Capsa Susun

    Dapatkan bonus terbesar di KARTUVIPQQ
    - BONUS MINGGUAN : 0.5% [Tanpa Syarat]
    - BONUS REFERRAL : 20% [Seumur Hidup]

    Ajak teman anda sebanyak-banyaknya dan tingkatkan turnover Anda, maka makin banyak bonus yang akan di dapatkan.

    Kemenangan anda merupakan kebanggaan kami, karena dengan kemenangan anda, maka anda akan semakin betah bermain di KARTUVIPQQ

    - LiveChat KARTUVIPQQ Online 24 Jam Non Stop
    - Support Platform ANDROID dan IOS
    - Minimal Deposit 15.000 / Withdrawnya Rp 20.000
    - Proses Deposit / Withdraw tidak sampai 3 menit !
    - Bertransaksi di support 5 BANK : BCA - MANDIRI - BNI - BRI - DANAMON
    - 100% Player VS Player ( NO ROBOT / ADMIN!)
    - Win Rate Tertinggi 99% Pasti Menang


    Gabung Di Sini, Lebih Banyak Menangnya !!!

    Untuk informasi lebih lanjut, silahkan hubungi kami di.
    Link : https://bit.ly/2Jhy2iu
    Whatsapp : +85510791654

    ReplyDelete
  6. Saya memiliki skor kredit yang sangat rendah sehingga upaya saya untuk meminjam dari Bank ditolak. Saya bangkrut sampai-sampai saya tidak mampu makan tiga kali sehari dan juga saya benar-benar bangkrut karena nama saya identik dengan kemiskinan. saya berhutang baik dari teman-teman saya dan juga dari rentenir hidup saya di bawah ancaman saya harus melarikan diri dari rumah dan saya membawa anak-anak saya untuk bertemu ibu mertua saya karena sifat ancaman yang saya terima dari orang-orang yang meminjamkan saya uang Jadi saya harus mencari cara cepat dan mendesak untuk membayar kembali uang itu dan juga memulai bisnis baru usaha pertama saya sangat mengerikan karena saya ditipu sebesar Rp5.390.020.00 saya harus pindah juga dua minggu kemudian saya kehilangan Rp350.000,00 kepada pemberi pinjaman yang curang jadi saya turun secara finansial dan emosional karena ini adalah yang paling tidak saya harapkan sehingga seorang teman saya memberi tahu saya untuk menghubungi email ini: :( iskandalestari.kreditpersatuan@gmail.com) bahwa saya harus meminta jumlah berapa pun berharap agar Bunda Iskandar selalu menjadi kembali untuk memberikan bantuan keuangan kepada siapa pun yang membutuhkan sehingga saya meminta untuk jumlah Rp850.000.000,00 dalam waktu 24 jam cerita saya berubah untuk selamanya saya membayar semua hutang saya dan saya juga memiliki cukup uang untuk membiayai sendiri bisnis semua terima kasih kepada teman saya yang memperkenalkan saya kepada ibu khususnya dan juga kepada Ibu Iskandar pada umumnya untuk mengubah rasa malu saya menjadi terkenal
    Atas perkenan: ISKANDAR LESTARI LOAN COMPANY
    Email: (iskandalestari.kreditpersatuan@gmail.com)

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Google seo service from China, black and white seo company

    ReplyDelete
  9. NAGAQQ | AGEN BANDARQ | BANDARQ ONLINE | ADUQ ONLINE | DOMINOQQ TERBAIK

    Yang Merupakan Agen Bandarq, Domino 99, Dan Bandar Poker Online Terpercaya di asia hadir untuk anda semua dengan permainan permainan menarik dan bonus menarik untuk anda semua

    Bonus yang diberikan NagaQQ :
    * Bonus rollingan 0.5%,setiap senin di bagikannya
    * Bonus Refferal 10% + 10%,seumur hidup
    * Bonus Jackpot, yang dapat anda dapatkan dengan mudah
    * Minimal Depo 15.000
    * Minimal WD 20.000
    *Meyediakan Deposit pulsa XL & SIMPATI

    Memegang Gelar atau title sebagai QQ Online Terbaik di masanya

    9 Games Yang di Hadirkan NagaQQ :
    * Poker Online
    * BandarQ
    * Domino99
    * Bandar Poker
    * Bandar66
    * Sakong
    * Capsa Susun
    * AduQ
    * Perang Bacarrat (New Game)


    Info Lebih lanjut Kunjungi :
    Website : NAGAQQ
    Facebook : Facebook
    WHATSAPP : +855977509035
    Line : Cs_nagaQQ
    TELEGRAM :+855967014811

    BACA JUGA BLOGSPORT KAMI YANG LAIN:
    agen bandarq terbaik
    Winner NagaQQ
    Daftar NagaQQ
    AGEN POKER ONLINE

    ReplyDelete
  10. PERMAINAN ONLINE TERBESAR DI INDONESIA

    Website paling ternama dan paling terpercaya di Asia ^^
    Sistem pelayanan 24 Jam Non-Stop bersama dengan CS Berpengalaman respon tercepat :)
    Memiliki 9 Jenis game yang sangat digemari oleh seluruh peminat poker / domino

    - Adu Q
    - Bandar Q
    - Bandar Sakong
    - Bandar Poker
    - Poker
    - Domino 99
    - Capsa Susun
    - BANDAR66 / ADU BALAK
    - Perang Baccarat ( GAME TERBARU )

    Permainan Judi online yang menggunakan uang asli dan mendapatkan uang asli ^^
    * Minimal Deposit : 20.000
    * Minimal Withdraw : 20.000
    * Deposit dan Withdraw 24 jam Non stop ( Kecuali Bank offline / gangguan )
    * Bonus REFFERAL 15 % Seumur hidup tanpa syarat
    * Bonus ROLLINGAN 0.3 % Dibagikan 5 hari 1 kali
    * Proses Deposit & Withdraw PALING CEPAT
    * Sistem keamanan Terbaru & Terjamin
    * Poker Online Terpercaya
    * Live chat yang Responsive
    * Support lebih banyak bank LOKAL


    Contact Us

    Website SahabatQQ
    WA 1 : +85515769793
    WA 2 : +855972076840
    LINE : SAHABATQQ
    FACEBOOK : SahabatQQ Reborn
    TWITTER : SahabatQQ
    YM : cs2_sahabatqq@yahoo.com
    Kami Siap Melayani anda 24 jam Nonstop

    Daftar SahabatQQ


    Typesex69
    Ranseldunia
    Bodyfit45
    Cemesahabat

    ReplyDelete
  11. It's still amazing to see the evolution of, in this case, libGL of KallistiOS. However, some libraries of the proprietary libraries of the official SDK specifically the later versions of kamui2 and shinobi2 is as far as I know, the only way to access the rather low-level, fixed-function pipeline of the Dreamcast when it comes to performance. There's some rather vital parts of those not included in KOS. One can also try it out on a current project without bothering Sega. The amount of vertices/s as per light source is somewhat obvious when performance is measured almost in any case when using KOS with C++ - obviously more so than with plain (albeit an outdated revision of course), which obviously is to be expected.

    If one were to convert more of these Japanese-made libs, which would be time consuming, I personally subjective opinion is that maybe even more games like Arcade Racing from JoshProd would perform better with more "6th gen." graphics, given the project is of a size where it would've mattered, that is.

    It's great to see you guys holding this alive, still, and more so, doing it in the utmost impressive speed with regards to getting offline games, back online and releasing if not the most technically impressive games, atleast and very much so, enjoyable games which is what matters.

    Just giving a props here.

    ReplyDelete
  12. Some typos there.. plain C, and "lack of performance COMPARED"..

    Keep the great news coming - Shu, Pc, Ben, BlueCrab - basically every guy out there doing *something* for the Dreamcast. Hope you guys are proud of what you're doing.

    ReplyDelete
  13. Thank you. I'll be back every day. Guess I will just bookmark this site.토토사이트졸업

    ReplyDelete
  14. 카지노사이트 Your post is an excellent example of why I keep coming back to read your amazing and high quality content.

    ReplyDelete
  15. 온라인카지노 Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing very unique and interesting.



    ReplyDelete
  16. Incredible things you've generally imparted to us. Simply
    continue written work this sort of posts. The time which was
    squandered in going for educational cost now it can be utilized for
    studies. Thanks.
    토토사이트

    ReplyDelete
  17. I am so glad I am not working with C+ or C# languages anymore. I had the worst time during my computer science bachelor's, I always needed extra tuition or Cheap Assignment Services. But now after I changed my major I am doing better.

    ReplyDelete
  18. Awesome! Its pleasure to visit here,This blog is good to sharing the information which is useful for many of them.
    Click here if you are looking for calendar 2022 printers online.

    ReplyDelete
  19. C++ and Java have revolutionized the world of programming, and I don't think these languages will have any alternatives in the future. The easiest way to work on writing projects in these programming languages is to use Assignment Writing Services.

    ReplyDelete
  20. The geography assignment refers to the subject of geography dealing with the physical, political, natural and man-made aspects of the world. This assignment includes topography, mapping etc for the students of Arts stream. Geography assignment help proves to be beneficial as it aims at incorporating the detailed and current news of the world taking in account of every change that is happening like, global warming, air pollution and others.

    ReplyDelete
  21. Your blog has always attracted me and this particular post left me speechless. It is one of the best pieces of writing I have seen. Good job…..
    lenovo thinkplus k3

    ReplyDelete
  22. Very good points you wrote here...Great stuff...I think you've made some truly interesting points. Keep up the good work. Today I share a most latest blog on the topic of d8 dice online. Visit the blog and Roll your die now!

    ReplyDelete
  23. Awesome post well-written and nice to read.
    Learn here

    ReplyDelete
  24. Porting C++ and OpenGL applications to Dreamcast offers a unique chance to explore a distinct platform with its challenges and rewards.
    amazon resume service

    ReplyDelete
  25. Empower your blockchain vision with our expert app design company. We specialize in crafting user-centric interfaces for blockchain applications, seamlessly blending cutting-edge technology with intuitive design to deliver exceptional user experiences in the decentralized world.

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. Thanks for sharing this insightful post on porting C++ and OpenGL applications to the Dreamcast. It's crucial to be aware of the potential pitfalls in such endeavors. I appreciate your thorough breakdown of the "gotchas" one might encounter during the process. This information will undoubtedly prove invaluable for developers venturing into Dreamcast development. On a separate note, if you're ever in need of a change of scenery in Dubai, don't forget to check out the Best Veneers in Dubai for a stunning smile makeover!

    ReplyDelete
  28. There's a foundational commitment to integrity, with each piece carefully researched and presented with honesty.

    green marble in Al Nahda

    ReplyDelete
  29. pg ดีที่สุดเกมออนไลน์ PG SLOT สล็อตบนโทรศัพท์เคลื่อนที่ แบบใหม่ตอนนี้ ของโลก สมัครเล่น SLOT วันนี้รับโบนัส แรกเข้า 100% ในทันทีทันใด โบนัส 50% สำหรับสมาชิกใหม่

    ReplyDelete
  30. This blog was great, and I enjoyed reading it. If you wrote it yourself, that is great and deserves appreciation; however, to make your blogs more professional and informative, I believe you should hire a professional writer. By the way, I'm a professional photographer and content creator. When I was having trouble a few weeks ago with the same issue as you and could not figure it out, I decided to hire dissertation experts, and guess what? They were very helpful and gave me ideas for top-notch photography dissertation topics. To improve the value and information of your content, I recommend getting in touch with them.

    ReplyDelete
  31. Porting C++ and OpenGL applications to the Dreamcast presents several challenges, including differences in hardware architecture, limited system resources, and unique graphical constraints. Developers often encounter issues with memory management, rendering performance, and adapting modern OpenGL code to the Dreamcast’s proprietary graphics API. These gotchas require careful optimization and code adjustments to maintain functionality and visual quality. Additionally, when considering design elements like logos or icons within the game, digitizing for embroidery can be an unexpected yet creative crossover. Incorporating digitized designs into physical merchandise allows fans to celebrate the Dreamcast experience beyond the screen,



    ReplyDelete
  32. Porting a game engine to the Dreamcast sounds like a challenging task! I can relate to the process of overcoming roadblocks, as I had some issues with my online History class recently. Fortunately, I found Online History Class Help to assist me in keeping up with the material. It's always great to have resources available when facing challenges, whether in game development or education!

    ReplyDelete